各位大虾,请帮我看看这个问题出在哪 javaweb程序,类实现登录处理,但是有错误, 错误代码如下:

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:500)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:428)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.NullPointerException
com.Deal.checkManager(Deal.java:13)
org.apache.jsp.deal_jsp._jspService(deal_jsp.java:76)
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:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
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.32 logs.

jsp页面:
<form id="form1" name="form1" method="post" action="deal.jsp" onSubmit="return check()">

用户名:
<input name="username" type="text" id="username"/></td>

密 码:
<input type="password" name="password" id="password"/></td>
</tr>

deal.jsp页面
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030" import="java.sql.*" errorPage=""%>
<jsp:useBean id="deal" class="com.Deal" scope="page"/>
<%
String manager=request.getParameter("username");
String pwd=request.getParameter("password");
if(manager!=null&&pwd!=null){
int rtn=deal.checkManager(manager,pwd);

if(rtn==0){
out.println("<script>alert('登录失败!');</script>");
}else{
out.println("<script>alert('登录成功!');</script>");
}
}
%>
deal.java类

package com;
import com.ConnDB;
import java.sql.*;
public class Deal {
public int checkManager(String name,String inpwd) {
int flag = 0;
ConnDB conn=new ConnDB();
String sql = "SELECT * FROM admin where username='" +
name + "'";
ResultSet rs = conn.executeQuery(sql);
try {
if (rs.next()) {
}
}else{
flag = 0;
}
} catch (SQLException ex) {
flag = 0;
}
conn.close();
return flag;
}
}
deal.java类写的不全,但是没有错误,就是字数放不下了
请别复制答案给我,谢谢哈,真需要帮助
我估计问题问题出错是调用包的问题

String manager=request.getParameter("username");
String pwd=request.getParameter("password");
你的username或者password没接到值吧,,你看看传的时候是不是你名称写错了什么的
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-06-11
String sql = "SELECT * FROM admin where username='" +name + "'";
这句话有问题吧,name这个变量在哪?如果已经有了,就可以直接写成
String sql = "SELECT * FROM admin where username="+name ;
第2个回答  2012-06-10
com.Deal.checkManager(Deal.java:13)
其实最好的方法还是调试下
第3个回答  2012-06-10
是空指针异常啊 你那个类deal 是空 所以就报异常啦 !
第4个回答  2012-06-11
rs.next() 没值吧
相似回答