HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Exception in JSP: /jdtw/vote/showquestion.jsp:3330:     ResultSet rs,rs1,rs2;
31:     String question = null,item = null,sql1;
32:     String sql = "SELECT Question,QuestionID from VQuestions where IsVisable = 1 ";
33:     rs = stmt.executeQuery(sql);
34:   
35:     int questionid = 0,itemid = 0;
36:  int i=0,j; //题目及选项标号
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause java.lang.NullPointerException
org.apache.jsp.jdtw.vote.showquestion_jsp._jspService(showquestion_jsp.java:85)
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:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
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.16 logs.
--------------------------------------------------------------------------------Apache Tomcat/5.5.16
是连接数据库的问题还是什么问题???小弟初学,望各位大虾推小弟一把......

解决方案 »

  1.   

    showquestion.jsp的内容是:
    <%@page contentType="text/html;charset=GBK"%>
    <%@page import="java.sql.*"%>
    <jsp:useBean id="DBConn" scope="page" class="dreamtime.dreamnews.DBConnection"/>
    <html>
    <head>
    <title>
    在线答题
    </title>
    <LINK href="style.css" rel=stylesheet>
    </head>
    <body>
    <% 
    Connection conn=null; //连接对象
    Statement stmt=null,stmt1=null; //语句对象

    try
    {
       conn = DBConn.getConn();
       stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
       stmt1 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    }
    catch(Exception e)
    {
       out.println(e.getMessage());
    }   
    %>
    <form action = vote/thanks.jsp method="post">  <%
        ResultSet rs,rs1,rs2;
        String question = null,item = null,sql1;
        String sql = "SELECT Question,QuestionID from VQuestions where IsVisable = 1 ";
        rs = stmt.executeQuery(sql);
      
        int questionid = 0,itemid = 0;
    int i=0,j; //题目及选项标号

    try
    {
          while(rs.next())
          {
            i++;
        question = rs.getString(1);
            questionid= rs.getInt(2);
            out.print("<TABLE borderColor=#999999 cellSpacing=0 cellPadding=0 width=100% border=0><tr><td><font size='1' color='red'><strong>"+" "+i+"."+" "+question+"</strong></font></td></tr>");
            sql1 = "SELECT Item,ItemID From VItems Where QuestionID ="+questionid;
            rs1 = stmt1.executeQuery(sql1);
        j = 0;
            while(rs1.next())
            {
             j++;
         item = rs1.getString(1);
             itemid = rs1.getInt(2);
             %>
             <td > <font size="1" color="blue">[<%=j%>]<input type=radio value="<%=itemid%>" name="<%=questionid%>" <%if(j<2) {out.print(" checked "+j);}%>><%=item%></font></td></tr>
             <%
            }
            out.print(" </table><p>");
          }
        }
        catch(Exception e)  
        {
          out.println(e.getMessage());
        }%><hr>
    <div align=center><INPUT class=buttonface type=submit value=提交 name=Submit>
                      <INPUT class=buttonface type=reset value=重选 name=Submit2>
    </div>
    </form></body>
    </html>