如何在用户注册成功之后,显示“你已经注册成功!”并使用“定时功能”跳转到登陆页面呢?

hhgg123 2007-05-20 02:42:21
register.jsp
<%@page contentType="text/html; charset=GB2312"%>

<html>
<head>
<title>register</title>

</head>
<body bgcolor="#ffffff">
<p align="center">新用户注册
<form name="thisForm" action="insert.jsp" method="GET" accept-charset="UTF-8" onsubmit="return formCheck()">
<script language="JavaScript" type="text/JavaScript">
function formCheck(){
number=new RegExp("05[0-3][0-9]");
if(thisForm.userID.value==""){
alert("请输入你的学号!");
return false;
userID.focus();
}else{
if(thisForm.userID.value.match(number)==null){
alert("格式输入错误,你必须输入这样的格式0538,前两位数字必须为05,后面两位必须从1--40");
userID.value="";
return false;
userID.focus();
}
}
if(thisForm.userName.value==""){
alert("请输入你的姓名!");
return false;
userName.focus();
}
if(thisForm.password.value!=thisForm.pass.value){
alert("两次输入的密码不一致,请再次输入!");
password.value="";
pass.value="";
return false;
password.focus();

}
return true;
}</script>
<p align="center">
<table>
<tr>
<td align="right">学号:</td>
<td>
<input type="text" name="userID"/>
</td>
</tr>
<tr>
<td align="right">注册名:</td>
<td>
<input type="text" name="userName"/>
</td>
</tr>
<tr>
<td align="right">密码:</td>
<td>
<input type="password" name="password"/>
</td>
</tr>
<tr>
<td align="right">请再次输入密码:</td>
<td>
<input type="password" name="pass"/>
</td>
</tr>
<tr>
<td><input type="submit" name="sub" value="提交"></td>
<td><input type="reset" name="res" value="重写">
</tr>


</table>
</form>
</body>
</html>


登录文件是:login.jsp,如何在如何在用户注册成功之后,显示一条信息,如“你已经注册成功!”,并且在经过几秒后自动跳转到login.jsp页面呢?求教!
...全文
1920 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
dr_lou 2007-05-23
  • 打赏
  • 举报
回复
servlet里面response到不同的页(比如登陆成功或失败)
成功页加上<meta http-equiv="refresh" content="3;url=index.jsp">
url是你要跳转的页
gongyali2005 2007-05-23
  • 打赏
  • 举报
回复
<meta http-equiv="refresh" content="3;url=index.jsp">
正解!
backhamx7 2007-05-23
  • 打赏
  • 举报
回复
楼上的是正解
dodozhu 2007-05-23
  • 打赏
  • 举报
回复
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP '2.jsp' starting page</title>
<script language="javascript">
var count = 5;//记数器

function countdown()
{
count--;

if(count == 1)
{
window.location.href='3.jsp';
}

if(document.layers)
{
document.layers.showtime.document.write(count);
document.layers.showtime.document.close();
}
else if(document.all)
{
showtime.innerHTML=count+" 秒后自动返回 ...";
}

setTimeout("countdown()",1000);
}
</script>

</head>
<body bgcolor="#F4F6F6" onLoad="countdown();">
<center>
<span id="showtime"></span>
</center>
您已经注册成功
</body>
</html>
===============================================================================
你直接copy过去就可以用了
zhj92lxs 2007-05-23
  • 打赏
  • 举报
回复
<meta http-equiv="refresh" content="3;url=index.jsp">让网页自动刷新
临远 2007-05-20
  • 打赏
  • 举报
回复
<html>
<head>
<meta http-equiv="refresh" content="3;url=index.jsp">
<script>
alert('注册成功');
</script>
<head>
<body>
</body>
</html>
tanghaijie595 2007-05-20
  • 打赏
  • 举报
回复
<head>
<meta http-equiv="refresh" content="3;url=index.jsp">
<head>

<body>
显示字样......
</body>
yanransoft 2007-05-20
  • 打赏
  • 举报
回复
setTimeout("doRedirect()",3000);//redirect to other page after 3 seconds
D_ragon 2007-05-20
  • 打赏
  • 举报
回复
<script language="javascript">
function doReload()
{
location.href="login.jsp";
}
setTimeout("doReload()",3000);
//三秒钟后重定向到login.jsp
</script>
试一下应该可以!!
hhgg123 2007-05-20
  • 打赏
  • 举报
回复
但我这个在register.jsp里成功注册后,会先跳转到insert.jsp文件里,该文件的作用是将用户输入的数据写入数据库里,
insert.jsp代码如下:
<%@page contentType="text/html; charset=GB2312"%>
<%@page import="jspdes.*,java.sql.*"%>
<html>
<head>
<title>insert record</title>
</head>
<%!Connection con;%>
<%!Statement stat;%>
<%!ResultSet rs;%>
<%!String sql;%>
<body bgcolor="#ffffff">
<%!String ID;%>
<%!String name;%>
<%!String pas;%>
<%request.setCharacterEncoding("gb2312"); %>
<%ID=request.getParameter("userID");%>
<%name=new String(request.getParameter("userName").getBytes("ISO8859_1"));%>
<%pas=request.getParameter("password");%>



<%
try {
con = DBConnection.getConnection();
stat=con.createStatement();
sql="insert into T_USER values('"+ID+"','"+name+"','"+pas+"')";
stat.execute(sql);

}
catch (Exception e) {
e.printStackTrace();
}
%>

</body>
</html>
能用jsp 在insert.jsp 里实现转向login.jsp的功能吗?
gongqi727 2007-05-20
  • 打赏
  • 举报
回复
用javascript 写 fun() , 在成功后调用fun() ,fun()函数实现现实“你已经注册成功!”,然后做一个延时操作,在到login.jsp。
hhgg123 2007-05-20
  • 打赏
  • 举报
回复
up!

81,115

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧