首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

<jsp:forward page="details.jsp"/>报错,该如何处理

2013-09-11 
jsp:forward pagedetails.jsp/报错%--Document: voteCreated on : 2011-9-15, 15:56:46Author: Admi

<jsp:forward page="details.jsp"/>报错
<%-- 
  Document : vote
  Created on : 2011-9-15, 15:56:46
  Author : Administrator
--%>

<%@page contentType="text/html" pageEncoding="GB2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">

<%@page language="java" import="java.sql.*"%>
<jsp:useBean id="connDbBean" scope="page" class="vote.VoteConn"/>
<%
  String rb = request.getParameter("type");
  if(rb != null && rb != "") {
  String sql = "update vote Set c_num=c_num+1 where id=" + rb;
  connDbBean.executeUpdate( sql );
  }
%>
<jsp:forward page="details.jsp"/>



报错:
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: An exception occurred processing JSP page /vote.jsp at line 20

17: connDbBean.executeUpdate( sql );
18: }
19: %>
20: <jsp:forward page="details.jsp"/>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)


root cause 

org.apache.jasper.JasperException: An exception occurred processing JSP page /details.jsp at line 28

25: <%
26: // 获取总票数
27: ResultSet tmpRs = connDbBean.executeQuery("select sum(c_num) As totalnum from vote");
28: tmpRs.next();
29: tot_num = tmpRs.getInt("totalnum");
30: tmpRs.close();
31: ResultSet rs = connDbBean.executeQuery("select * from vote");


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:706)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:677)
org.apache.jsp.vote_jsp._jspService(vote_jsp.java:79)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)


root cause 

java.lang.NullPointerException
org.apache.jsp.details_jsp._jspService(details_jsp.java:86)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)


javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:706)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:677)
org.apache.jsp.vote_jsp._jspService(vote_jsp.java:79)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.26 logs.


--------------------------------------------

Apache Tomcat/6.0.26

[解决办法]
<%--
Document : vote
Created on : 2011-9-15, 15:56:46
Author : Administrator
--%>

<%@page contentType="text/html" pageEncoding="GB2312"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

试下
<%@page language="java" import="java.sql.*"%>
<jsp:useBean id="connDbBean" scope="page" class="vote.VoteConn"/>
<%
String rb = request.getParameter("type");
if(rb != null && rb.isEmpty()) {
String sql = "update vote Set c_num=c_num+1 where id=" + rb;
connDbBean.executeUpdate( sql );
}
%>
<jsp:forward page="details.jsp">

</jsp:forward>
[解决办法]
root cause 

org.apache.jasper.JasperException: An exception occurred processing JSP page /details.jsp at line 28

25: <%
26: // 获取总票数
27: ResultSet tmpRs = connDbBean.executeQuery("select sum(c_num) As totalnum from vote");
28: tmpRs.next();
29: tot_num = tmpRs.getInt("totalnum");
30: tmpRs.close();
31: ResultSet rs = connDbBean.executeQuery("select * from vote");
root cause 

java.lang.NullPointerException

tmpRs为null了

[解决办法]
肯定报错啊 你一旦访问这个页面就直接跳转了不会判断的,你用了标准动作
我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.myexception.cn/j2se/33144.html
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行