主题:关于jsp叶面跳转
程序如下
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*"%>
<%request.setCharacterEncoding("gb2312");%>
<jsp:useBean id="linejdbc" scope="page" class="examinline.DBConnectionBean" />
<%linejdbc.setdrivername();%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>管理员登陆</title>
<link href="../img/cssexamin.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>
<script language='JavaScript' type='text/JavaScript' src='/img/fun.js'></script>
<%
String userid="";
String password="";
if (request.getParameter("userid")!=null) userid=request.getParameter("userid");
if (request.getParameter("password")!=null) password=request.getParameter("password");
if (userid!="" & password!="")
{
Connection conn = linejdbc.getopenConnection();
PreparedStatement s = conn.prepareStatement("select * from admin where name=? and password=?");
s.setString(1,userid);
s.setString(2,password);
ResultSet result = s.executeQuery();
if(result.next())
{
session.setAttribute("name",result.getString("name"));
%>
[color=FF0000]<script language="JavaScript">
MM_goToURL('parent','./main.jsp');//如正确自动转向main.jsp
</script> [/color] <%
}
else
{
out.print(" <center><span class='banquan'>用户ID不存在或密码错误!</span></center>");
}
}
else
{
%>
<script language="JavaScript" type="text/JavaScript" src="../img/youno.js"></script>
<body>
<div align="center">
<p class="banquan"> </p>
<p class="banquan"> </p>
<p class="banquan">管理员登陆</p>
<form action="login.jsp" method="post" name="formloginD" id="formloginD">
<table width="30%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><p align="center"><span class="banquan">I</span><span class="style1">..</span><span class="banquan">D:</span>
<input name="userid" type="text" class="textborder" id="userid" style="color: #333300; border: 1px solid #99FF66; padding: 0; background-color: #FFFFFF" size="15" onChange="numericCheck()">
</p>
<p align="center"> <span class="banquan">密</span> <span class="banquan">码:</span>
<input name="password" type="password" class="textborder" id="password" style="color: #333300; border: 1px solid #99FF66; padding: 0; background-color: #FFFFFF" size="15">
</p></td>
</tr>
</table>
<span class="banquan"> </span>
<p>
<input type="submit" name="Submit" value="确定">
</p>
</form>
<p class="banquan"> </p>
</div>
</body>
<%
}
%>
</html>
能正常连接数据库进行身份验证,ID和密码不正确时也可以正常提示,当正确时却打开不了下一页面main.jsp,只出现空页,我觉得是这一部分代码有问题,要是这里错要怎么改啊?
%>
<script language="JavaScript">
MM_goToURL('parent','./main.jsp');//如正确自动转向main.jsp
</script>
<%
那个fun.js里面的内容是:
123456
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
大家帮忙看看,谢谢! 有点乱...
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*"%>
<%request.setCharacterEncoding("gb2312");%>
<jsp:useBean id="linejdbc" scope="page" class="examinline.DBConnectionBean" />
<%linejdbc.setdrivername();%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>管理员登陆</title>
<link href="../img/cssexamin.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>
</head>
<script language='JavaScript' type='text/JavaScript' src='/img/fun.js'></script>
<%
String userid="";
String password="";
if (request.getParameter("userid")!=null) userid=request.getParameter("userid");
if (request.getParameter("password")!=null) password=request.getParameter("password");
if (userid!="" & password!="")
{
Connection conn = linejdbc.getopenConnection();
PreparedStatement s = conn.prepareStatement("select * from admin where name=? and password=?");
s.setString(1,userid);
s.setString(2,password);
ResultSet result = s.executeQuery();
if(result.next())
{
session.setAttribute("name",result.getString("name"));
%>
[color=FF0000]<script language="JavaScript">
MM_goToURL('parent','./main.jsp');//如正确自动转向main.jsp
</script> [/color] <%
}
else
{
out.print(" <center><span class='banquan'>用户ID不存在或密码错误!</span></center>");
}
}
else
{
%>
<script language="JavaScript" type="text/JavaScript" src="../img/youno.js"></script>
<body>
<div align="center">
<p class="banquan"> </p>
<p class="banquan"> </p>
<p class="banquan">管理员登陆</p>
<form action="login.jsp" method="post" name="formloginD" id="formloginD">
<table width="30%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><p align="center"><span class="banquan">I</span><span class="style1">..</span><span class="banquan">D:</span>
<input name="userid" type="text" class="textborder" id="userid" style="color: #333300; border: 1px solid #99FF66; padding: 0; background-color: #FFFFFF" size="15" onChange="numericCheck()">
</p>
<p align="center"> <span class="banquan">密</span> <span class="banquan">码:</span>
<input name="password" type="password" class="textborder" id="password" style="color: #333300; border: 1px solid #99FF66; padding: 0; background-color: #FFFFFF" size="15">
</p></td>
</tr>
</table>
<span class="banquan"> </span>
<p>
<input type="submit" name="Submit" value="确定">
</p>
</form>
<p class="banquan"> </p>
</div>
</body>
<%
}
%>
</html>
能正常连接数据库进行身份验证,ID和密码不正确时也可以正常提示,当正确时却打开不了下一页面main.jsp,只出现空页,我觉得是这一部分代码有问题,要是这里错要怎么改啊?
%>
<script language="JavaScript">
MM_goToURL('parent','./main.jsp');//如正确自动转向main.jsp
</script>
<%
那个fun.js里面的内容是:
123456
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
大家帮忙看看,谢谢! 有点乱...