如何从JSP页面返回index.html(登录页面)?

时间:2012-08-07 08:45:49

标签: java html jsp web-applications servlets

我从这里开始:

enter image description here

使用该代码:

<!DOCTYPE html>
<html>
<head><title>Bank application</title>
<link rel="stylesheet"
      href="./css/styles.css"
      type="text/css"/>
</head>
<body>
<table class="title">
  <tr><th>Web Bank application</th></tr>
</table>

<br/>
<fieldset>
  <legend>Login Page - please enter your Username and Password</legend>
  <form action="loginPage"> 
    Username: <input type="text" name="username"><br>
    Password : <input type="text" name="password"><br>
    <input type="submit" value="Login">
  </form>
</fieldset>

<br/>
<br/>
<br/>

<fieldset>
  <legend>Registration</legend>
  <form action="register"> 
    First name: <input type="text" name="firstName"><br>
    Last name : <input type="text" name="lastName"><br>
    Address   : <input type="text" name="address"><br>
    ID-number : <input type="text" name="idnumber"><br>
    User-Name : <input type="text" name="userName"><br>
    Password  : <input type="text" name="password"><br>
    <input type="submit" value="Register">
  </form>
</fieldset>

<br/>
<br/><br/><br/><br/><br/><br/>
</body></html>

当我从一个页面移动到另一个页面时,我到达这里:

enter image description here

使用该代码:

<!DOCTYPE html>
<html>
<head><title>Authentication failed - a problem has occurred!</title>
<link rel="stylesheet"
      href="./css/styles.css"
      type="text/css"/>
</head>
<body>
<h1>Sorry , but you are not registered to our bank!</h1>

<fieldset>
  <legend>Please press here to continue</legend>
  <form action="goingBack"> 
    <input type="submit" value="Press here">
  </form>
</fieldset>

</body></html>

我想回到index.html - 我在程序启动时看到的第一页(上面的第一张图片)。

我该怎么做?我怎样才能转回index.html

此致

2 个答案:

答案 0 :(得分:2)

只需添加指向上一页HTML中上一页的链接:

<!DOCTYPE html>
<html>
<head><title>Authentication failed - a problem has occurred!</title>
<link rel="stylesheet"
      href="./css/styles.css"
      type="text/css"/>
</head>
<body>
<h1>Sorry , but you are not registered to our bank!</h1>

<fieldset>
  <legend>Please press here to continue</legend>
  <form action="goingBack"> 
    <input type="submit" value="Press here">
  </form>
</fieldset>

 <a href="index.jsp">Go Back</a> <!-- add this -->

</body></html>

答案 1 :(得分:1)

你只需要javascript。要在5秒后重定向到/index.html

setTimeout('window.location='index.html';', 5000);

setTimeout()是一个javascript函数,用于设置计时器以在给定的时间段后触发某些内容。 window.location是一个变量,允许您更改当前页面的URL(从而重定向)。

相关问题