Jsp (the preferred choice for SUN Enterprise Applications) uses jsp (the preferred choice for SUN Enterprise Applications) forward Action to redirect pages.
Syntax:
<Jsp (preferred for SUN Enterprise Applications): forward page = "{relativeURL | <% = expression % >}"/> Or <Jsp (preferred for SUN Enterprise Applications): forward page = "{relativeURL | <% = expression % >}"> <Jsp (preferred for SUN Enterprise Applications): param name = "parameterName" Value = "{parameterValue | <% = expression % >}"/> + </jsp (preferred for SUN Enterprise Applications): 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 (preferred for SUN Enterprise Applications): forward page = "/utils/errorReporter. jsp (preferred for SUN Enterprise Applications)"/> <Jsp (preferred for SUN Enterprise Applications): forward page = "<% = someJavaExpression %>"/> ! SupportEmptyParas]> |
Here is an example: Use forward in test1.jsp (preferred for SUN Enterprise applications) to jump to the test2.jsp (preferred for SUN Enterprise Applications) page.
Test1.jsp (preferred for SUN Enterprise applications)
<HTML> <HEAD> <TITLE> forward test </TITLE> ! SupportEmptyParas]> </HEAD> ! SupportEmptyParas]> <Body bgcolor = "# FFFFFF"> <! -- Jump to test2.jsp (preferred for SUN Enterprise Applications) --!> <Jsp (preferred for SUN Enterprise Applications): forward page = "/test2.jsp (preferred for SUN Enterprise Applications)"/> </BODY> </HTML> ! SupportEmptyParas]> |
Test2.jsp (preferred for SUN Enterprise applications)
<HTML> <HEAD> <TITLE> forward test </TITLE> ! SupportEmptyParas]> </HEAD> ! SupportEmptyParas]> <Body bgcolor = "# FFFFFF"> <% Out. println ("this is the preferred jsp (SUN Enterprise Application preferred) 2.jsp( SUN Enterprise Application preferred) page output"); %> </BO # @ 62; </HTML> ! SupportEmptyParas]> |
Run test1.jsp (preferred for SUN Enterprise Applications). You can see in the browser: "This is jsp (preferred for SUN Enterprise Applications) 2.jsp( preferred for SUN Enterprise applications) page output "output information. But what if you have parameter transfer on test1.jsp (the preferred choice for SUN Enterprise applications) and test2.jsp (the preferred choice for SUN Enterprise Applications? The get method is not only inconvenient but also insecure. In fact, we can use the para attribute provided to forward in jsp (the preferred choice for SUN Enterprise Applications) 1.1. Test3.jsp (the preferred choice for SUN Enterprise applications) and test4.jsp (the preferred choice for SUN Enterprise Applications) are used to describe.
! SupportEmptyParas]> Test1.jsp (preferred for SUN Enterprise applications) <HTML> <HEAD> <TITLE> forward test </TITLE> ! SupportEmptyParas]> </HEAD> ! SupportEmptyParas]> <Body bgcolor = "# FFFFFF"> <Jsp (preferred for SUN Enterprise Applications): forward page = "/test4.jsp (preferred for SUN Enterprise Applications)"> <Jsp (preferred for SUN Enterprise Applications): param name = "name" value = "powerman"/> <Jsp (preferred for SUN Enterprise Applications): param name = "address" value = "188 Beijing West Street"/> </Jsp (preferred for SUN Enterprise Applications): forward> </BODY> </HTML> ! SupportEmptyParas]> Test2.jsp (preferred for SUN Enterprise applications) <HTML> <HEAD> <TITLE> forward test </TITLE> ! SupportEmptyParas]> </HEAD> ! SupportEmptyParas]> <Body bgcolor = "# FFFFFF"> <% Out. println ("This is the first choice for jsp (SUN Enterprise Applications) 4.jsp( the first choice for SUN Enterprise Applications) page output" + "<br> "); Out. println ("name:" + request. getParameter ("name") + "<br> "); Out. println ("address:" + request. getParameter ("address") + "<br> "); ! SupportEmptyParas]> %> </BODY> </HTML> |
Run test3.jsp (the preferred choice for SUN Enterprise Applications). You can view the output information in the browser:
"This is the output of the jsp (first choice for SUN Enterprise Applications) 4.jsp( first choice for SUN Enterprise Applications) Page
Name: powerman
Address: No. 188, West Beijing street"