我写的一个超级简单的登陆页面,没找到错误的地方,大家帮忙看看
dibao_ligon.htm
--------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
.style6 {font-size: 12px}
.style7 {font-size: 16px}
.style8 {font-size: 36px}
-->
</style>
</head><body>
<form name="form1" method="post" action="dibao_login.jsp">
<table width="800" border="1" align="center" bordercolor="#666666">
<tr bgcolor="#3366CC">
<th width="800" height="600" bordercolor="#999999" bgcolor="#FFFF00" scope="col"><span class="style1"></span><span class="style6"> </span>
<p class="style7"> </p>
<p> </p>
<p class="style8">欢迎使用城市低保信息管理系统</p>
<p class="style8"> </p>
<p class="style8"> </p>
<table width="224" border="1" cellpadding="0" cellspacing="0">
<tr class="style6">
<td width="40">用户</td>
<td width="168"><input name="username" type="text" size="24"></td>
</tr>
<tr class="style6">
<td>密码</td>
<td><input name="password" type="text" size="24"></td>
</tr>
</table>
<p class="style6">
<input type="submit" name="Submit" value="登陆">
</p>
<p class="style6"> </p></th>
</tr>
</table>
</form>
</body>
</html>
---------------------------
dibao_login.jsp
-----------------------------------------
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="DBcon.dbconn"%>
<jsp:useBean id="DBcon"scope="page"class="DBcon.dbconn"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!-- TemplateBeginEditable name="doctitle" -->
<title>城市低保信息管理系统</title>
<!-- TemplateEndEditable --><style type="text/css">
<!--
.style6 {font-size: 12px}
.style7 {font-size: 16px}
.style8 {font-size: 36px}
-->
</style>
<!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
</head>
<body>
<%
String username=request.getParameter("username");
String password=request.getParameter("password");Connection conn = null;
conn = DBcon.getConn() ;
ResultSet rs=DBcon.executeQuery("select * from user where user_name='"+username+"'and password='"+password+"'");
if(!rs.next())
{
response.sendRedirect("dibao_login.htm");
rs.close();
conn.close();
}
else
{
response.sendRedirect("edit_fam_tb.jsp");
rs.close();
conn.close();
}
%>
</body>
</html>
----------------------------
<%@ page import="DBcon.dbconn"%>
<jsp:useBean id="DBcon"scope="page"class="DBcon.dbconn"/>
这里面引用自己写的连接类,一直在正常使用肯定没问题.
dibao_ligon.htm
--------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
.style6 {font-size: 12px}
.style7 {font-size: 16px}
.style8 {font-size: 36px}
-->
</style>
</head><body>
<form name="form1" method="post" action="dibao_login.jsp">
<table width="800" border="1" align="center" bordercolor="#666666">
<tr bgcolor="#3366CC">
<th width="800" height="600" bordercolor="#999999" bgcolor="#FFFF00" scope="col"><span class="style1"></span><span class="style6"> </span>
<p class="style7"> </p>
<p> </p>
<p class="style8">欢迎使用城市低保信息管理系统</p>
<p class="style8"> </p>
<p class="style8"> </p>
<table width="224" border="1" cellpadding="0" cellspacing="0">
<tr class="style6">
<td width="40">用户</td>
<td width="168"><input name="username" type="text" size="24"></td>
</tr>
<tr class="style6">
<td>密码</td>
<td><input name="password" type="text" size="24"></td>
</tr>
</table>
<p class="style6">
<input type="submit" name="Submit" value="登陆">
</p>
<p class="style6"> </p></th>
</tr>
</table>
</form>
</body>
</html>
---------------------------
dibao_login.jsp
-----------------------------------------
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="DBcon.dbconn"%>
<jsp:useBean id="DBcon"scope="page"class="DBcon.dbconn"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!-- TemplateBeginEditable name="doctitle" -->
<title>城市低保信息管理系统</title>
<!-- TemplateEndEditable --><style type="text/css">
<!--
.style6 {font-size: 12px}
.style7 {font-size: 16px}
.style8 {font-size: 36px}
-->
</style>
<!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
</head>
<body>
<%
String username=request.getParameter("username");
String password=request.getParameter("password");Connection conn = null;
conn = DBcon.getConn() ;
ResultSet rs=DBcon.executeQuery("select * from user where user_name='"+username+"'and password='"+password+"'");
if(!rs.next())
{
response.sendRedirect("dibao_login.htm");
rs.close();
conn.close();
}
else
{
response.sendRedirect("edit_fam_tb.jsp");
rs.close();
conn.close();
}
%>
</body>
</html>
----------------------------
<%@ page import="DBcon.dbconn"%>
<jsp:useBean id="DBcon"scope="page"class="DBcon.dbconn"/>
这里面引用自己写的连接类,一直在正常使用肯定没问题.
解决方案 »
- hibernate的hql查询语句问题
- struts token 重复提交
- JSP调用DLL(jsp引用javabean的问题)
- 如何打开项目中的JSP文件?(急!!!!!!!!!!!!!!!!!!)
- 紧急求助!!!紧急求助!!!紧急求助!!!紧急求助!!!
- 文件问题!(只有30分了)
- 谁用过jfreereport或jaxperreport做过报表?各位大哥帮忙呀!!!--就20分了
- 解决方法 : 配置错误引起 Tomcat 启动时窗口一闪而过, 如何看错误信息
- asp的变量传到jsp里面
- 小白请教大神们一个JSP关于session的问题
- web程序中使用扫描枪
- JSP开发中,有没有第三方表格控件,可以放查询出来的数据?
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause java.lang.NullPointerException
org.apache.jsp.dibao_005flogin_jsp._jspService(dibao_005flogin_jsp.java:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.16 logs.
我在这个数据库里的表可以插入,我如查询fam 表则rs.next()为false,如查询user表则提示java.lang.NullPointerException
各位有遇到过这种情况不,同一库中表都可插入,查询的话有的rs.next()为false,有的则提示java.lang.NullPointerException
如果是ACCESS数据库,就不要使用诸如user,username====用户名,有冲突!!!好象我也有过类似的经历,但具体有点忘记了,现在考试忙,没有时间搞这个东西,有时间在来吧,祝君好运!!
加空格'and select * from user where user_name = 'zhangsan' and password='123';
你自己的问题
你的Servlet配置好了么?
"select * from user where user_name='"+username+"' and password='"+password+"'"
试试 注意 username+"' and 要有一个空格