我在做jsp设计时遇到下面的问题,请各位大虾帮帮忙,谢谢!!!
HTTPStatus500------------------------------------------------------------------------...
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
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 /verify.jsp at line 11
8: String pw=request.getParameter("pw");
9: String sql="select * from user where name='"+user+"' and password='"+pw+"'";
10: ResultSet rs=conn.executeQuery(sql);
11: if(rs.next())
12: {
13: session.setAttribute("rank",rs.getString("rank"));
14: session.setAttribute("id",rs.getString("userid"));
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
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.verify_jsp._jspService(verify_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: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.18 logs.
javabean的部分源程序package dbBean;
import java.sql.*;
public class DBBean
{
private String driverStr = "sun.jdbc.odbc.JdbcOdbcDriver";
private String connStr = "jdbc:odbc:mydbsource";
private Connection conn = null;
private Statement stmt = null;
public DBBean()
{
try {
Class.forName(driverStr);
}
catch(ClassNotFoundException ex) {
System.out.println(ex.getMessage());
}
}
public void setDriverStr(String dstr)
{
driverStr=dstr;
}
public void setConnStr(String cstr)
{
connStr=cstr;
}
public ResultSet executeQuery(String sql)
{
ResultSet rs = null;
try {
conn = DriverManager.getConnection(connStr);
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.out.println(ex.getMessage());
}
return rs;
}
public int executeUpdate(String sql)
{
int result=0;
try{
conn = DriverManager.getConnection(connStr);
stmt = conn.createStatement();
result = stmt.executeUpdate(sql);
}
catch(SQLException ex){
System.out.println(ex.getMessage());
}
return result;
}
public void close()
{
try{
stmt.close();
conn.close();
}
catch(SQLException ex){
System.out.println(ex.getMessage());
}
}
}
这是verify.jsp的源代码,实在找不出来啊。谢谢!!!!!!
<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="conn" class="dbBean.DBBean" scope="session"/>
<jsp:setProperty name="conn" property="connStr" value="jdbc:odbc:bookstore"/>
<%
request.setCharacterEncoding("gb2312");
session.setMaxInactiveInterval(-1);
String user=request.getParameter("user");
String pw=request.getParameter("pw");
String sql="select * from user where name='"+user+"' and password='"+pw+"'";
ResultSet rs=conn.executeQuery(sql);
if(rs.next())
{
session.setAttribute("rank",rs.getString("rank"));
session.setAttribute("id",rs.getString("userid"));
session.setAttribute("name",rs.getString("name"));
rs.close();
conn.close();
%>
<jsp:forward page="home.jsp"/>
<%
}
else
{
rs.close();
conn.close();
%>
<jsp:forward page="login.jsp">
<jsp:param name="warning" value="对不起,您的用户名或密码不正确"/>
</jsp:forward>
<%
}
%> 展开
--------------------------------------------------------------------------------
type Exception report
message
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 /verify.jsp at line 11
8: String pw=request.getParameter("pw");
9: String sql="select * from user where name='"+user+"' and password='"+pw+"'";
10: ResultSet rs=conn.executeQuery(sql);
11: if(rs.next())
12: {
13: session.setAttribute("rank",rs.getString("rank"));
14: session.setAttribute("id",rs.getString("userid"));
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
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.verify_jsp._jspService(verify_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: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.18 logs.
javabean的部分源程序package dbBean;
import java.sql.*;
public class DBBean
{
private String driverStr = "sun.jdbc.odbc.JdbcOdbcDriver";
private String connStr = "jdbc:odbc:mydbsource";
private Connection conn = null;
private Statement stmt = null;
public DBBean()
{
try {
Class.forName(driverStr);
}
catch(ClassNotFoundException ex) {
System.out.println(ex.getMessage());
}
}
public void setDriverStr(String dstr)
{
driverStr=dstr;
}
public void setConnStr(String cstr)
{
connStr=cstr;
}
public ResultSet executeQuery(String sql)
{
ResultSet rs = null;
try {
conn = DriverManager.getConnection(connStr);
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.out.println(ex.getMessage());
}
return rs;
}
public int executeUpdate(String sql)
{
int result=0;
try{
conn = DriverManager.getConnection(connStr);
stmt = conn.createStatement();
result = stmt.executeUpdate(sql);
}
catch(SQLException ex){
System.out.println(ex.getMessage());
}
return result;
}
public void close()
{
try{
stmt.close();
conn.close();
}
catch(SQLException ex){
System.out.println(ex.getMessage());
}
}
}
这是verify.jsp的源代码,实在找不出来啊。谢谢!!!!!!
<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="conn" class="dbBean.DBBean" scope="session"/>
<jsp:setProperty name="conn" property="connStr" value="jdbc:odbc:bookstore"/>
<%
request.setCharacterEncoding("gb2312");
session.setMaxInactiveInterval(-1);
String user=request.getParameter("user");
String pw=request.getParameter("pw");
String sql="select * from user where name='"+user+"' and password='"+pw+"'";
ResultSet rs=conn.executeQuery(sql);
if(rs.next())
{
session.setAttribute("rank",rs.getString("rank"));
session.setAttribute("id",rs.getString("userid"));
session.setAttribute("name",rs.getString("name"));
rs.close();
conn.close();
%>
<jsp:forward page="home.jsp"/>
<%
}
else
{
rs.close();
conn.close();
%>
<jsp:forward page="login.jsp">
<jsp:param name="warning" value="对不起,您的用户名或密码不正确"/>
</jsp:forward>
<%
}
%> 展开
4个回答
展开全部
rs为空,说明执行sql没有获得数据。
检查sql语句在数据库里面能否获得数据。
检查sql语句在数据库里面能否获得数据。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
500错误,很多原因
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
留个邮箱 发你几个自己常用的 比较简洁
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询