神雷子 神雷子
关注数: 27 粉丝数: 205 发帖数: 1,756 关注贴吧数: 14
rs.next()在jsp页面调用出错空指针 这是登录验证代码部分; <%@ page contentType="text/html; charset=gb2312" %> <%@ page import="java.sql.ResultSet,user.user_operation,db.dbconn,java.sql.SQLException" %><html><head></head><body> <jsp:useBean id="user_operation" class="user.user_operation" scope="session"></jsp:useBean> <%int sysuser_rol=0; ResultSet rt=null; int rowCount=0; String sysuser_id=null; try{ sysuser_rol=Integer.parseInt(request.getParameter("sysuser_role")); }catch(Exception e){} String sysuser_nam=request.getParameter("sysuser_name"); String sysuser_passwor=request.getParameter("sysuser_password"); user_operation uop = new user_operation(); rt = uop.getUserOne(sysuser_nam); try{ rt.next(); rowCount=rt.getRow(); }catch(SQLException e){} if(rowCount!=0&&rt.getString("sysuser_password").equals(sysuser_passwor)&&rt.getInt("sysuser_role")==(sysuser_rol)) { session.setAttribute(sysuser_id,rt.getInt("sysuser_id")); response.sendRedirect("index.jsp"); }else{ response.sendRedirect("login.jsp"); }%> </body> </html> 代码结束 其中的user_operation中的getUserOne()经过测试 查询数据库成功 方法没错, 现在在jsp中调用失败 下面是错误的信息提示 type Exception report message An exception occurred processing JSP page /checkLogin.jsp at line 28 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 /checkLogin.jsp at line 28 25: user_operation uop = new user_operation(); 26: rt = uop.getUserOne(sysuser_nam); 27: try{ 28: rt.next(); 29: 30: rowCount=rt.getRow(); 31: Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause java.lang.NullPointerException org.apache.jsp.checkLogin_jsp._jspService(checkLogin_jsp.java:101) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) note The full stack trace of the root cause is available in the Apache Tomcat/7.0.52 logs.
1 下一页