高手指点啊!!! ResultSet rs=SqlBean.executeQuery(sql1);赋值不上啊
这是代码:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page contentType="text/html; charset=gb2312"%>
<%@ page language="java" import="java.sql.*,mypackage.*"%>
<jsp:useBean id="SqlBean" scope="page" class="mypackage.SQLServerConnBean"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>2列左侧固定右侧自适应宽度+头部+尾部——<a href="http://www.aa25.cn">标准之路www.aa25.cn</a></title>
<link href="layout.css" rel="stylesheet" type="text/css" />
<meta name="Keywords" content="标准之路,www.aa25.cn,网页标准布局,DIV+CSS" />
<meta name="" content="标准之路,www.aa25.cn,网页标准布局,DIV+CSS" />
<meta name="author" content"×××,有问题请到www.68css.cn网站留言" />
<meta name="Description" content="本套网页标准布局模板是由标准之路(www.aa25.cn)制作完成,如果您要转载,请保留版权" />
</head>
<body>
<div id="container">
<div id="header">
<div align="center">
<table width="453" height="92" border="0">
<tr>
<td width="447">政法学院成绩查询</td>
</tr>
</table>
</div>
</div>
<div id="mainContent">
<div id="sidebar">
<table width="200" height="211" border="0">
<tr>
<td>
<p> </p>
<p>
<%
String id=request.getParameter("textfield");
String pw =request.getParameter("textfield2");
String sf=request.getParameter("radiobutton");
if("t".equals(sf))
{
String sql = "select * from teacher where teano='"+id+"' and pwt='"+pw+"'";
SqlBean.OpenConn();
ResultSet rs=SqlBean.executeQuery(sql);
//如果记录集非空,表明有匹配的用户名和密码,登陆成功
if ( rs.next())
{
session.setAttribute("id",id);
response.sendRedirect("teacher.jsp");
}
else
{
response.sendRedirect("/loginwrong.jsp");
}
}
else
{
String sql1 = "select * from student where sno='" + id + "' and pw= '" + pw + "'";
SqlBean.OpenConn();
ResultSet rs=SqlBean.executeQuery(sql1);
if ( rs.next ( ) )
{
session.setAttribute("id",id);
response.sendRedirect("stu/students.jsp");
}
else
{
response.sendRedirect("/loginwrong.jsp");
}
}
%>
</body>
</html>
这是报错信息:
Exception report
message
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:522)
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.check_jsp._jspService(check_jsp.java:126)
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.
[解决办法]
报的是常见的空指针异常啊。
[解决办法]
rs 是空的 @@@
[解决办法]
:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page contentType="text/html; charset=gb2312"%>
<%@ page language="java" import="java.sql.*,mypackage.*"%>
<jsp:useBean id="SqlBean" scope="page" class="mypackage.SQLServerConnBean"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>2列左侧固定右侧自适应宽度+头部+尾部——<a href="http://www.aa25.cn">标准之路www.aa25.cn</a></title>
<link href="layout.css" rel="stylesheet" type="text/css" />
<meta name="Keywords" content="标准之路,www.aa25.cn,网页标准布局,DIV+CSS" />
<meta name="" content="标准之路,www.aa25.cn,网页标准布局,DIV+CSS" />
<meta name="author" content"×××,有问题请到www.68css.cn网站留言" />
<meta name="Description" content="本套网页标准布局模板是由标准之路(www.aa25.cn)制作完成,如果您要转载,请保留版权" />
</head>
<body>
<div id="container">
<div id="header">
<div align="center">
<table width="453" height="92" border="0">
<tr>
<td width="447">政法学院成绩查询</td>
</tr>
</table>
</div>
</div>
<div id="mainContent">
<div id="sidebar">
<table width="200" height="211" border="0">
<tr>
<td>
<p> </p>
<p>
<%
String id=request.getParameter("textfield");
String pw =request.getParameter("textfield2");
String sf=request.getParameter("radiobutton");
if("t".equals(sf))
{
String sql = "select * from teacher where teano='"+id+"' and pwt='"+pw+"'";
SqlBean.OpenConn();
ResultSet rs=SqlBean.executeQuery(sql);
//如果记录集非空,表明有匹配的用户名和密码,登陆成功
if ( rs.next())
{
session.setAttribute("id",id);
response.sendRedirect("teacher.jsp");
}
else
{
response.sendRedirect("/loginwrong.jsp");
}
}
else
{
String sql1 = "select * from student where sno='" + id + "' and pw= '" + pw + "'";
SqlBean.OpenConn();
ResultSet rs=SqlBean.executeQuery(sql1);
if ( rs.next ( ) )
{
session.setAttribute("id",id);
response.sendRedirect("stu/students.jsp");
}
else
{
response.sendRedirect("/loginwrong.jsp");
}
}
%>
</body>
</html>
这是报错信息:
Exception report
message
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(JspServletWrapperwww.163xyx.com.java:522)
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.check_jsp._jspService(check_jsp.java:126)
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.
什么情况啊??好迷茫。。。。。。
[解决办法]
。。。。首先、你确定你的 connection 是不是连接上了。
其次、确定你的PreparedStatement 或者 Statement 不为空,创建成功了。。。
然后、你在看看。。还抱吗。。。
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html