--------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause java.lang.NullPointerException
org.apache.jsp.outexam_jsp._jspService(outexam_jsp.java:153)
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:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.几个页面老是出现这种问题了  救命啊        我不是常上csdn 高手能否加我qq 791340493

解决方案 »

  1.   

    java.lang.NullPointerException
    空值被使用,要把你的JSP贴上来看看
      

  2.   

    <%@ page language="java" import="java.util.*" contentType="text/html;charset=GB2312"%>
    <%@ page import="com.lizhe.*"%>
    <%@ page import="java.sql.*"%>
    <%@ page import="javax.sql.*"%><html>
      <head>
        <title>在线考试系统</title>  <style type="text/css">
    <!--
    body,td,th {
    font-size: 9pt;
    }
    -->
      </style>
      </head>
      
      <body>
        <form name="form1" method="post" action="simpleoutsave.jsp">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width='20%'><%@ include file = "left.jsp" %></td>
              <td width='80%'>
              <br>
              <br>
              <table width="100%" border="0" cellspacing="1" cellpadding="1"  bgColor=#595959>
                <tr>
                  <td height="25" colspan="2" bgcolor="#FFFFFF">在线考试系统-选择考试</td>
                </tr>
                <tr bgColor=#d1face>
                  <td width="17%" height="25" >选择试卷编号:</td>
                  <td width="83%"><select name="papertitle" id="papertitle">
                  <%
         DBConnectionManage db = new DBConnectionManage();
         Connection conn = db.getFreeConnection();
         String query = "select * from paper";
         Statement st = null;
         ResultSet rs = null;
         try{
         st = conn.createStatement();
         rs = st.executeQuery(query);
         while(rs.next()){
         out.println("<option value='"+rs.getString("papertitle")+"'>"+rs.getString("papertitle")+"</option>");
         }
         }catch(Exception ex){
        
         }finally{
         st.close();
         rs.close();
         conn.close();
         }
          %>
                  </select></td>
                </tr>
                <tr bgcolor="#FFFFFF">
                  <td colspan="2" align="center"><input type="submit" name="Submit" value="提交">&nbsp;&nbsp;
                  <input type="reset" name="Submit2" value="重置"></td>
                </tr>
              </table></td>
            </tr>
          </table>
          </form>
      </body>
    </html>
     这是outexam.jsp的代码 
      

  3.   

    Connection conn = db.getFreeConnection();
    要放到try{}里面去,catch(){这里打印一下错误信息}另外,所有的JSP,服务器都会先将其翻译成JAVA文件,并暂存到硬盘中
    比如tomcat,会在“work”目录生成其对应的JAVA文件
    你可以在你的工程里搜索下“outexam_jsp.java”文件,该文件153行是出错的地方
    org.apache.jsp.outexam_jsp._jspService(outexam_jsp.java:153)
      

  4.   

    java.lang.NullPointerException
    请确保你所使用的变量非Null
      

  5.   

    著名的java.lang.NullPointerException出现了!
    在tomcat/work/目录下找到outexam_jsp.java这个Servlet文件。
    找到153行看是什么,这样,就可以找到是吧里出异常了!
      

  6.   

    看了一下你的JSP代码,看不出哪里会有null
    但我认为有可能是conn为null
      

  7.   

    断点  debug看看问题出在哪儿,自然就知道怎么解决了!
      

  8.   

    我去找outexam_jsp.java的 文件 发现是 DBConnectionManage db = new DBConnectionManage();
         Connection conn = db.getFreeConnection();
         String query = "select * from paper";
         Statement st = null;
         ResultSet rs = null;
         try{
         st = conn.createStatement();
         rs = st.executeQuery(query);
         while(rs.next()){
         out.println("<option value='"+rs.getString("papertitle")+"'>"+rs.getString("papertitle")+"</option>");
         }
         }catch(Exception ex){
        
         }finally{
         st.close();
         rs.close();
         conn.close();
         }
    里面的st.close()错误了 可是想不明白怎么错了  求大家帮我看看
      

  9.   

    close的顺序 先小后大
    rs.close();
    st.close();
    conn.close();
      

  10.   

    嗯嗯  谢谢 哈  不过现在我的数据库出问题了 发生说“用户 'sa' 登录失败。” 可是我修改sa的密码一直修改不了的 请问怎么办的