jsp页面跳转问题
如何在JSP页面中实现在指定的时间段后再跳转!
如:在登录页面中登录,如果密码错误,在error页面中抱错,然后在5秒钟后再跳转到到登录页面!
------解决方案-------------------- <%@ page language= "java " import= "java.util.* " pageEncoding= "GBK "%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<title> My JSP 'error.jsp ' starting page </title>
<script language= "javascript ">
var count = 5;//记数器
function countdown()
{
count--;
if(count == 1)
{
window.location.href= 'login.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>
------解决方案--------------------response.setHeader( "Refresh ", "5;url=login.jsp ");
------解决方案--------------------呵呵,比较喜欢2楼的做法