Use JSP forward action in JSP to redirect pages.
Syntax:
<JSP: Forward page = "{relativeurl | <% = expression % >}"/> or
<JSP: Forward page = "{relativeurl | <% = expression % >}">
<JSP: Param name = "parametername"
Value = "{parametervalue | <% = expression % >}"/>+ </jsp: Forward>
This action allows you to forward the request to another page. It has only one attribute, page. Page should contain a relative URL. This can be a static value or a value that can be calculated when it is requested, as shown in the following two examples:
<JSP: Forward page = "/utils/errorreporter. jsp"/>
<JSP: Forward page = "<% = somejavaexpression %>"/>
! Supportemptyparas]>
Here is a specific example: Use forward in test1.jsp to jump to the test2.jsp page.
test1.jsp
forward test
! Supportemptyparas]>
! Supportemptyparas]>
! Supportemptyparas]>
test2.jsp
forward test
! Supportemptyparas]>
! Supportemptyparas]>
<% Out. println ("this is the output from the jsp2.jsp page"); %>
! Supportemptyparas]>
RUN test1.jsp. You can see the output information of "This is the output from the jsp2.jsp page" in the browser. But what if you pass parameters on the test1.jsp and test2.jsp pages? The get method is not only inconvenient but also insecure. In fact, we can use the Para attribute provided for forward in jsp1.1 to solve this problem. Test3.jsp and test4.jsp are used to describe.
! Supportemptyparas]>
Test1.jsp
<HTML>
<Head>
<Title> forward test </title>
! Supportemptyparas]>
</Head>
! Supportemptyparas]>
<Body bgcolor = "# ffffff">
<JSP: Forward page = "/test4.jsp">
<JSP: Param name = "name" value = "powerman"/>
<JSP: Param name = "Address" value = "188 Beijing West Street"/>
</Jsp: Forward>
</Body>
</Html>
! Supportemptyparas]>
Test2.jsp
<HTML>
<Head>
<Title> forward test </title>
! Supportemptyparas]>
</Head>
! Supportemptyparas]>
<Body bgcolor = "# ffffff">
<%
Out. println ("this is the output from the jsp4.jsp page" + "<br> ");
Out. println ("name:" + request. getparameter ("name") + "<br> ");
Out. println ("Address:" + request. getparameter ("Address") + "<br> ");
! Supportemptyparas]>
%>
</Body>
</Html>
Run test3.jsp and you can see in the browser:
"This is the output from the jsp4.jsp page.
Name: powerman
Address: No. 188, West Beijing street"
Output Information