|
Java学習者论坛
严重: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at com.chen.User.UserBeanCl.checkUser(UserBeanCl.java:34)
at org.apache.jsp.login_jsp._jspService(login_jsp.java:110)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
login.jsp显示错误的行为 if行
if(ubc.checkUser(u,p)){
response.sendRedirect("main.jsp");
}else{
response.sendRedirect("login.jsp");
}
at com.chen.User.UserBeanCl.checkUser(UserBeanCl.java:34)显示的行为 st =conn.createStatement();
public boolean checkUser(String u,String p){ //驗证用户是否存在
boolean b=false;
try {
conn= ConnDB.getCon(); //到數据库中去验证用户
st =conn.createStatement();
rs=st.executeQuery("select password from tb_user where username='"u"' ");
if(rs.next())
{
if(rs.getString(1).equals(p))
{
b=true;
}
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{ //关闭打开的各种资源
this.close();
}
return b;
}
欢迎来到Java学習者论壇,转载请注明地址:http://www.javaxxz.com. |
|