jsp中rt.next();为空指针出错 在线等待回答
这是登录验证代码部分;<%@pagecontentType="text/html;charset=gb2312"%><%@pageimport="java.sql.Res...
这是登录验证代码部分;
<%@ 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.
请大神帮我看看 这个到底是怎么回事? 在哪错了 或者缺少什么必要的语句!
谢谢大家了
2014/6/10 10:30
等待回答..... 展开
<%@ 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.
请大神帮我看看 这个到底是怎么回事? 在哪错了 或者缺少什么必要的语句!
谢谢大家了
2014/6/10 10:30
等待回答..... 展开
2个回答
2014-06-10
展开全部
whlie(rt.next())
追问
好的我改一下对了我想问你,我的数据库连接和方法都没有进行关闭操作,有没有问题
我修改了同样是那句话空指针
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询