异常为:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
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.NullPointerException
org.apache.jsp.board1_jsp._jspService(org.apache.jsp.board1_jsp:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
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)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
--------------------------------------------------------------------------------
Apache Tomcat/5.5.9
代码:<%@page contentType="text/html;charset=GB2312"%>
<%request.setCharacterEncoding("GB2312");%>
<jsp:useBean id="bean" scope="page" class="test.dbcon"/>
<%
int count=0,lastp=1,numf,numl,prep,nextp,pageno=1,id;
ResultSet rs=null,rs1=null;
if(request.getParameter("pageno")==null)
pageno=0;
else
pageno=Integer.parseInt(request.getParameter("pageno"));
out.print(pageno);
rs1=bean.executeSQL("select*from message");
while(rs1.next())
count++;
lastp=(int)Math.ceil((double)count/5);
if(pageno==0||pageno>lastp)
pageno=lastp;
numf=pageno*5-4;
numl=numf+4;
if(pageno==1)
prep=1;
else
prep=pageno-1;
if(pageno==lastp)
nextp=lastp;
else
nextp=pageno+1;
%>
<font size=7 color=green>专家留言板</font>
<hr>
<center>
<form action=board1.jsp method=post>
<table border=0>
<tr>
<td>目前页次:<font color=red><%=pageno%></font>/
<font color=blue><%=lastp%></font></td>
<td><a href=board1.jsp?pageno=<%=prep%>>[上一页]</a></td>
<td><a href=board1.jsp?pageno=<%=nextp%>>[下一页]</a></td>
<td><a href=board1.jsp?pageno=1>[第一页]</a></td>
<td><a href=board1.jsp>[最后一页]</a></td><td>输入页次:
<input type=text size=3 name=pageno></td>
<td><input type=submit name=SEND value=送出></td>
<td><a href=password1.jsp><font color=red size="5">
<i>站长专用</i></font></a></td>
</tr>
</table>
</form>
<%
String name,email,subject,time,sex,memo;
rs=bean.executeSQL("select*from message where id between"+numf+"and"+numl);
while(rs.next())
{
name=rs.getString(1);
email=rs.getString(2);
subject=rs.getString(3);
time=rs.getString(4);
sex=rs.getString(5);
memo=rs.getString(6);
out.print("<center>");
out.print("<table border=1>");
out.print("<tr><td bgcolor=yellow>姓名</td><td>"+name+"</td></tr>");
out.print("<tr><td bgcolor=yellow>E-mail</td><td>"+email+"</td></tr>");
out.print("<tr><td bgcolor=yellow>时间</td><td>"+time+"</td></tr>");
out.print("<tr><td bgcolor=yellow>主题</td><td>"+subject+"</td></tr>");
out.print("<tr><td valign=top bgcolor=yellow>留言</td><td>"+memo+"<img src="+sex+"></td></tr>");
out.print("</table><p>");
}
rs.close();
%>
<hr>
<center><a href=message1.html>我要留言</a>
<a href=board1.jsp>查看留言</a>
</body>
</html>