JSP learning notes (6) -- passing parameters between multiple JSP pages

Source: Internet
Author: User

1. How to pass parameters between multiple JSP pages? Use the JSP built-in scope object session. Using its two methods setattribute (), getattribute ()

2. The following example implements the function of passing parameters of the first JSP page to the third page.

3. The Code is as follows: 1.jsp

<HTML>

<Form method = get action = 2.jsp>

What's your name <input type = text name = username>

<Input type = submit value = submit>

</Form>

</Html>

 

4. 2.jsp

<HTML>

<Form method = post action = "3.jsp? Pass = 11 ">

<%

String name = request. getparameter ("username ");

Session. setattribute ("username", name );

%>

Your name is: <% = request. getparameter ("username") %>

<Br> what's your holobby <input type = text name = holobby>

<Input type = submit value = submit>

</Form>

</Html>

 

5. 3.jsp

<HTML>

Your name is: <% = session. getattribute ("username") %>

<Br>

Your holobby is: <% = request. getparameter ("holobby") %>

<Br>

Your password is: <% = request. getparameter ("pass") %>

<Br>

</Form>

</Html>

 

 

 

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.