我的jsp运行之后的异常,麻烦高手指点一下谢谢.我新手.
// <%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* "
errorPage= " " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
</head>
<body>
<jsp:useBean id= "sq " scope= "session " class= "sqlbean.sqlbean "/>
<%
ResultSet rs=sq.executeQuery( "select * from student ");
%>
<table>
<tr> <td bgcolor= "#00FF99 "> id </td> <td bgcolor= "#9900FF "> 姓名 </td> </tr>
<%while(rs.next()){%>
<tr>
<td bgcolor= "#FF0000 "> <%=rs.getString( "id ")%> </td>
<td bgcolor= "#3333FF "> <%=rs.getString( "name ")%> </td>
</tr>
<%}
rs.close();
%>
</table>
</body>
</html>
异常如下:
org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NullPointerException org.apache.jsp.sql_jsp._jspService(sql_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
我感觉我的jsp没有错误啊!为什么就是出不来呢
------解决方案--------------------1. 第一行应该没有 "// "()估计不是这个问题。
2. <jsp:useBean id= "sq " scope= "session " class= "sqlbean.sqlbean "/>
这个class用完整的路径试试。
------解决方案--------------------把sqlbean.sqlbean的代码贴出来看看