救命啊,实在找不出来错误在哪儿
jsp页面是这样的:
<%@ page contentType= "text/html; charset=gb2312 " language= "java " errorPage= " " %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN " "http://www.w3.org/TR/html4/loose.dtd ">
<jsp:useBean id= "db " scope= "page " class= "database.sqlBean "/>
<%
String id=(String)request.getAttribute( "id ");
String name=(String)request.getAttribute( "name ");
if(id!= " "&&name!= " ")
{
String sqlStr= "insert into examinees values( '343534 ', 'dukeduke ', '8888 ') ";
db.setConnection( "sun.jdbc.odbc.JdbcOdbcDriver ", "jdbc:odbc:exam ", "sa ", " ");
db.setStatement(sqlStr);
db.update();
db.disConnect();
}
%>
<script language= "JavaScript ">
function check()
{
if(document.form1.id.value== " ")
{
alert( "请输入考生号码 ");
document.form1.id.focus();
return false;
}
else if(document.form1.name.value== " ")
{
alert( "请输入考生姓名 ");
document.form1.name.focus();
return false;
}
}
</script>
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> </title>
</head>
<body>
<div align= "right "> <a href= "examinee_list.jsp " > <strong> 考生列表 </strong> </a>
<a href= "examinee_add.jsp "> <strong> 新增考生 </strong> </a> </div> <p>
<form name= "form1 " onSubmit= "return check(); " method= "post ">
<table width= "50% " border= "1 " cellpadding= "1 " cellspacing= "2 " bgcolor= "#66FFFF ">
<tr>
<td bgcolor= "#0066FF " scope= "col "> 考生号码: </td>
<td scope= "col "> <input type= "text " name= "id "> </td>
</tr>
<tr>
<td bgcolor= "#0066FF "> 考生姓名: </td>
<td> <input type= "text " name= "name "> </td>
</tr>
<tr>
<td align= "center " bgcolor= "#0066FF "> <input type= "submit " value= "添加 " > </td>
<td align= "center "> <input type= "reset " name= "reset " value= "重置 "> </td>
</tr>
</table>
</form>
</body>
</html>
运行以后出现异常:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 3 in the jsp file: /manage/examinee_add.jsp
Generated servlet error:
[javac] Compiling 1 source file
D:\java\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\work\Catalina\localhost\exam_system\org\apache\jsp\manage\examinee_005fadd_jsp.java:44: ??? database ???
database.sqlBean db = null;
^
An error occurred at line: 3 in the jsp file: /manage/examinee_add.jsp
Generated servlet error:
D:\java\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\work\Catalina\localhost\exam_system\org\apache\jsp\manage\examinee_005fadd_jsp.java:46: ??? database ???
db = (database.sqlBean) _jspx_page_context.getAttribute( "db ", PageContext.PAGE_SCOPE);
^
An error occurred at line: 3 in the jsp file: /manage/examinee_add.jsp
Generated servlet error:
D:\java\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\work\Catalina\localhost\exam_system\org\apache\jsp\manage\examinee_005fadd_jsp.java:48: ??? database ???
db = new database.sqlBean();
^
3 ??
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.
路过的各位达人救救小弟一把吧,不胜感激!
[解决办法]
if(id!= " "&&name!= " ")
改为if(!id.equals( " ")&&!name.equals( " "))
你的database.sqlBean有问题,最好先单独的调试一下,再嵌入到你的jsp中
[解决办法]
if(id!= " "&&name!= " ")就有问题if(!id.equals( " ")&&!name.equals( " "))也不行,你还没判断是否为null呢
[解决办法]
支持楼上
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html