主题:怎么解决初始化问题?不会一打开网页就跳出对话框"密码错误"?
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!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>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<style type="text/css">
<!--
.style1 {
color: #0000FF;
font-size: large;
font-weight: bold;
}
.style2 {
font-size: large;
color: #0000FF;
}
.style5 {
font-weight: bold;
color: #FF0000;
font-family: "黑体", "宋体";
}
.style6 {color: #FF0000; font-weight: bold;}
a:link {
color: #FF0000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FF0000;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
color: #0000FF;
}
body {
background-color: #CCDCF4;
}
-->
</style>
</head>
<body>
<form name="form1" method="post" action="">
<div id="Layer1" class="style1" style="position:absolute; left:253px; top:63px; width:326px; height:91px; z-index:1">
<table width="325" height="67" border="1">
<tr>
<td width="93">用户名</td>
<td width="216"><input type="text" name="name"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" name="hpassword"></td>
</tr>
</table>
</div>
<div id="Layer2" style="position:absolute; left:356px; top:164px; width:116px; height:22px; z-index:2">
<input type="submit" name="Submit" value="提交" >
<input type="reset" name="Submit" value="重置">
</div>
<p class="style1">请登录</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<% request.setCharacterEncoding("gb2312"); %>
<%
String hname=null;
hname=request.getParameter("name");
if(hname==null)
hname="";
byte b[]=hname.getBytes("ISO-8859-1");
hname=new String(b);
%>
<%
String hpassword1=request.getParameter("hpassword");
double str1=0;
if(hpassword1!=null)
str1=Double.parseDouble(hpassword1);
//String hpassword2=request.getParameter("password2");
%>
<%
String connectionURL="jdbc:mysql://localhost:3306/membership?"+"user=root&password=200537";
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(connectionURL);
Statement stmt=con.createStatement();
con.setAutoCommit(false);
ResultSet rs = stmt.executeQuery("select * from member where mname='"+hname+"' and mpassword1='"+str1+"';");
con.commit();
if(rs.next())
{
rs.close();
%>
<script>
alert("登录成功");
window.location="index.htm";
</script>
<%
}
else
{
rs.close();
%>
<script>
alert("用户名或密码错误!");
//window.location="denglu.jsp";
</script>
<%
}
//rs.close();
con.close();
}
catch(SQLException e)
{
%>
<script>
alert("登录失败,请重试!");
</script>
<%
//con.rollback();
}
catch(Exception e){}
//finally{con.close();}
%>
</form>
<h5 class="style2">如果你还没有会员号,请<span class="style5"></span><span class="style6"><a href="zhuce.jsp"> 注册</a></span><span class="style5"></span></h5>
</body>
</html>
怎么解决初始化问题?不会一打开网页就跳出对话框"密码错误"?
<!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>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<style type="text/css">
<!--
.style1 {
color: #0000FF;
font-size: large;
font-weight: bold;
}
.style2 {
font-size: large;
color: #0000FF;
}
.style5 {
font-weight: bold;
color: #FF0000;
font-family: "黑体", "宋体";
}
.style6 {color: #FF0000; font-weight: bold;}
a:link {
color: #FF0000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FF0000;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
color: #0000FF;
}
body {
background-color: #CCDCF4;
}
-->
</style>
</head>
<body>
<form name="form1" method="post" action="">
<div id="Layer1" class="style1" style="position:absolute; left:253px; top:63px; width:326px; height:91px; z-index:1">
<table width="325" height="67" border="1">
<tr>
<td width="93">用户名</td>
<td width="216"><input type="text" name="name"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" name="hpassword"></td>
</tr>
</table>
</div>
<div id="Layer2" style="position:absolute; left:356px; top:164px; width:116px; height:22px; z-index:2">
<input type="submit" name="Submit" value="提交" >
<input type="reset" name="Submit" value="重置">
</div>
<p class="style1">请登录</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<% request.setCharacterEncoding("gb2312"); %>
<%
String hname=null;
hname=request.getParameter("name");
if(hname==null)
hname="";
byte b[]=hname.getBytes("ISO-8859-1");
hname=new String(b);
%>
<%
String hpassword1=request.getParameter("hpassword");
double str1=0;
if(hpassword1!=null)
str1=Double.parseDouble(hpassword1);
//String hpassword2=request.getParameter("password2");
%>
<%
String connectionURL="jdbc:mysql://localhost:3306/membership?"+"user=root&password=200537";
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection(connectionURL);
Statement stmt=con.createStatement();
con.setAutoCommit(false);
ResultSet rs = stmt.executeQuery("select * from member where mname='"+hname+"' and mpassword1='"+str1+"';");
con.commit();
if(rs.next())
{
rs.close();
%>
<script>
alert("登录成功");
window.location="index.htm";
</script>
<%
}
else
{
rs.close();
%>
<script>
alert("用户名或密码错误!");
//window.location="denglu.jsp";
</script>
<%
}
//rs.close();
con.close();
}
catch(SQLException e)
{
%>
<script>
alert("登录失败,请重试!");
</script>
<%
//con.rollback();
}
catch(Exception e){}
//finally{con.close();}
%>
</form>
<h5 class="style2">如果你还没有会员号,请<span class="style5"></span><span class="style6"><a href="zhuce.jsp"> 注册</a></span><span class="style5"></span></h5>
</body>
</html>
怎么解决初始化问题?不会一打开网页就跳出对话框"密码错误"?