Getting started with JSP

Source: Internet
Author: User
JSP uses JSP forward action 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

<HTML>
<Head>
<Title> forward test </title>
! Supportemptyparas]>
</Head>
! Supportemptyparas]>
<Body bgcolor = "# ffffff">
<! -- Jump to 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 ("this is the output on the jsp2.jsp page"); %>
</Bo # @ 62;
</Html>
! Supportemptyparas]>

Run test1.jsp and you can see the output information in the browser: "This is the output from the jsp2.jsp page. 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


forward test
! Supportemptyparas]>

! Supportemptyparas]>







! Supportemptyparas]>

test2.jsp


forward test
! Supportemptyparas]>

! Supportemptyparas]>

<%
out. println ("this is the output from the jsp4.jsp page" + "
");
out. println ("name:" + request. getparameter ("name") + "
");
out. println ("Address:" + request. getparameter ("Address") + "
");
! Supportemptyparas]>
%>


Run test3.jsp to view the output information in the browser.:

"This is the output from the jsp4.jsp page.
Name: powerman
Address: No. 188, West Beijing street"
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.