JSP Learning Notes (vi)-----passing parameters between multiple JSP pages

Source: Internet
Author: User
js| Notes | Page 1. How do I pass parameters across multiple JSP pages? You need to use the built-in scope object session of the JSP. Using its two methods setattribute (), getattribute ()
2. The following example implements the function of passing the 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 hobby<input type=text name=hobby>
<input type=submit value=submit>
</form>
</html>

5.3.jsp
<html>
your name is:<%=session.getAttribute("username")%>
<br>
your hobby is:<%=request.getParameter("hobby")%>
<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.