jsp老是报错
我的jsp程序一直报错,清高手指点!谢谢!<%@pageimport="java.io.*"%><%@pageimport="java.util.*"%><%@pagei...
我的jsp程序一直报错,清高手指点!谢谢!
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*" %>
<%@ page import="oracle.jdbc.driver.*"%>
<html>
<head><title>saveuserinfo</title></head>
<body>
<%
String classpath="sun.jdbc.odbc.JdbcOdbcDriver";
String url="jdbc:odbc:teach";
String username = request.getParameter("username");
String pass = request.getParameter("password");
String email = request.getParameter("email");
String myusername = "s4133201";
String mypassword = "420588";
Connection dbcon = null;
try
{
Class.forName(classpath);
dbcon=DriverManager.getConnection(url,myusername,mypassword);
java.sql.Statement stat=dbcon.createStatement();
String cmd="insert into login values('"+username+ "','" +password+ "','"+ email+ "')";
ResultsSet res;
stat.executeUpdate(cmd);
out.println(<br><br><B>insert successful</B>);}
catch(SQLException e)
{
out.println("SQLException: " + e.getMessage() + "<BR>");
while((e = e.getNextException()) != null)
out.println(e.getMessage() + "<BR>");
}
catch(ClassNotFoundException e)
{
out.println("ClassNotFoundException: " + e.getMessage() + "<BR>");
}
finally
{
//Clean up resources, close the connection.
if(conn != null)
{
try
{
conn.close();
}
catch (Exception ignored) {}
}
}
%>
<b>Click here to look up all users</b>
<form method=get action=http://localhost:8080/demo/test2.jsp>
<input type=submit value=Lists of users>
</form>
</body>
</html>
报错信息如下:
ype Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:591)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.ClassNotFoundException: org.apache.jsp.demo.test11_jsp
java.net.URLClassLoader$1.run(URLClassLoader.java:200)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass( 展开
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*" %>
<%@ page import="oracle.jdbc.driver.*"%>
<html>
<head><title>saveuserinfo</title></head>
<body>
<%
String classpath="sun.jdbc.odbc.JdbcOdbcDriver";
String url="jdbc:odbc:teach";
String username = request.getParameter("username");
String pass = request.getParameter("password");
String email = request.getParameter("email");
String myusername = "s4133201";
String mypassword = "420588";
Connection dbcon = null;
try
{
Class.forName(classpath);
dbcon=DriverManager.getConnection(url,myusername,mypassword);
java.sql.Statement stat=dbcon.createStatement();
String cmd="insert into login values('"+username+ "','" +password+ "','"+ email+ "')";
ResultsSet res;
stat.executeUpdate(cmd);
out.println(<br><br><B>insert successful</B>);}
catch(SQLException e)
{
out.println("SQLException: " + e.getMessage() + "<BR>");
while((e = e.getNextException()) != null)
out.println(e.getMessage() + "<BR>");
}
catch(ClassNotFoundException e)
{
out.println("ClassNotFoundException: " + e.getMessage() + "<BR>");
}
finally
{
//Clean up resources, close the connection.
if(conn != null)
{
try
{
conn.close();
}
catch (Exception ignored) {}
}
}
%>
<b>Click here to look up all users</b>
<form method=get action=http://localhost:8080/demo/test2.jsp>
<input type=submit value=Lists of users>
</form>
</body>
</html>
报错信息如下:
ype Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:591)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.ClassNotFoundException: org.apache.jsp.demo.test11_jsp
java.net.URLClassLoader$1.run(URLClassLoader.java:200)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass( 展开
4个回答
展开全部
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*" %>
<%@ page import="oracle.jdbc.driver.*"%>
可能是包的问题,你导放一个具体自己要的包试试,我以前也有过这样的问题,后来就是换了个具体点的包就测试好了,
比如
原来是:<%@ page import="java.util.*"%>
改:<%@ page import="java.util.Date"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*" %>
<%@ page import="oracle.jdbc.driver.*"%>
可能是包的问题,你导放一个具体自己要的包试试,我以前也有过这样的问题,后来就是换了个具体点的包就测试好了,
比如
原来是:<%@ page import="java.util.*"%>
改:<%@ page import="java.util.Date"%>
展开全部
这个错误有点怪,好象你WEB-INF/WORK目录下面连对应的SERLEL和。CLASS都没有生成,类也没有找到。也可能是你连接数据库的包没导入
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你的 action 页已经存在了吗?
是不是没有完成 test2.jsp
是不是没有完成 test2.jsp
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个错误的原因是你JAVA类文件存放的位置有问题.它说找不到你在JSP中用到的那类文件。
而且,form的属性action最好用相对路径。
而且,form的属性action最好用相对路径。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询