JSP forward action to achieve the page's jump function.
Grammar:
<jsp:forward page="{relativeURL|<%= expression %>}"/> 或
<jsp:forward page="{relativeURL|<%= expression %>}">
<jsp:param name="parameterName"
value="{parameterValue|<%= expression %>}"/>+</jsp:forward>
This action allows you to move the request to a different page. It has only one attribute, page. The page should consist of a relative URL. This can be a static value or a value that can be computed at the time of the request, as in the following two examples:
<jsp:forward page="/utils/errorReporter.jsp"/>
<jsp:forward page="<%= someJavaExpression %>"/>
!supportEmptyParas]>
Here's a concrete example: use forward in test1.jsp to jump to the test2.jsp page.
test1.jsp
<HTML>
<HEAD>
<TITLE>forward test</TITLE>
!supportEmptyParas]>
</HEAD>
!supportEmptyParas]>
<BODY BGCOLOR="#FFFFFF">
<!--跳转到test2.jsp--!>
<jsp:forward page="/test2.jsp"/>
</BODY>
</HTML>
!supportEmptyParas]>
test2.jsp
<HTML>
<HEAD>
<TITLE> forward test </TITLE>
!supportEmptyParas]>
</HEAD>
!supportEmptyParas]>
<BODY BGCOLOR="#FFFFFF">
<%out.println("这是jsp2.jsp页面产生出的输出");%>
</BO #@62;
</HTML>
!supportEmptyParas]>
Run test1.jsp, you can see in the browser: "This is the output from the jsp2.jsp page" output information. But what if you have parameters in both the test1.jsp and test2.jsp pages? Get Way bar, not only the total length is limited, the use is now very inconvenient, and sometimes not safe. In fact, we can use the jsp1.1 in the forward to provide the Para properties can be resolved. Now the test3.jsp and test4.jsp to explain.
!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号"/>
</jsp:forward>
</BODY>
</HTML>
!supportEmptyParas]>
test2.jsp
<HTML>
<HEAD>
<TITLE>forward test</TITLE>
!supportEmptyParas]>
</HEAD>
!supportEmptyParas]>
<BODY BGCOLOR="#FFFFFF">
<%
out.println("这是jsp4.jsp页面产生出的输出"+"<br>");
out.println("姓名:"+request.getParameter("name")+"<br>");
out.println("地址:"+request.getParameter("address")+"<br>");
!supportEmptyParas]>
%>
</BODY>
</HTML>
Run test3.jsp, you can see the output information in the browser:
"This is the output produced by the jsp4.jsp page
Name: Powerman
Address: No. 188th West Street, Beijing