JSTL Redirect : Redirect « JSTL « Java Tutorial






<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/core-rt" prefix="c-rt" %>
<%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>



<c:if test="${pageContext.request.method=='POST'}">
  <c:if test="${param.reg!=null}">
    <c:redirect url="http:www.java2s.com" />
  </c:if>

  <h3 color="red">Sorry, we have no one registered with that
    name.</h3>
</c:if>


<html>
  <head>
    <title>Welcome</title>
  </head>

  <body>
    Please login.<br>
    <form method="POST">
      <table>
        <tr>
          <td width="100%" colspan="2" bgcolor="#0000FF">
            <p align="center">
              <b>
                <font color="#FFFFFF" size="4">Login</font>
              </b>
            </p>
          </td>
        </tr>

        <tr>
          <td width="26%">Login Name</td>

          <td width="74%">
          <input type="text" name="uid" size="20" />

          </td>
        </tr>

        <tr>
          <td width="26%">Password</td>

          <td width="74%">
            <input type="password" name="pwd" size="20" />
          </td>
        </tr>

        <tr>
          <td width="100%" colspan="2">
            <p align="center">
              <input type="submit" value="Login" name="Login" />

              <input type="submit" value="Register" name="reg" />
            </p>
          </td>
        </tr>
      </table>

      <P>&#160;</p>
    </form>

  </body>
</html>
  Download:  JSTLRedirect.zip( 1,559 k)








24.27.Redirect
24.27.1.JSTL Redirect