The param of java-jsp action elements

Source: Internet
Author: User

Related information:
"21-Day Learning Java Web Development"

Summary of results:
1. Used to transfer parameters, generally with <jsp:include>, <jsp:forward> joint use.
2.<jsp:param name= "parameter value" value= "parameter value"/>
3.name is used to set the name of the parameter. Value is used to set the values of the parameters.

<jsp:include> action elements paired with <jsp:param> action elements

contentdemo.jsp (single parameter)

1 <%@ page language= "java" contenttype= "text/html; charset=gb2312 "%>2 3 <p> parameters received </p>4 <%5    String strage = Request.getparameter ("Age");   receive parameter 6 %>7 <%--output parameter content--%>8 <%= "The Age parameter value is:" +strage%>
View Code

param1.jsp

  1  <%@ Page language= "java" contenttype= "text/html; charset=gb2312 "%> 2   3   <title> contains JSP files and passes parameters </title> 5   6  <body> 7  Use the include action element to include a JSP file and pass parameters <br> <jsp:include page= " contentdemo.jsp "> 9  <jsp:param name=" age "value=" "/>10  </jsp:include>11  </body> 12   
View Code

CONTENTDEMO2.JSP (multi-parameter)

1<%@ page language= "java" contenttype= "text/html; charset=gb2312 "%>23<p> Parameters received </p>4<%5String strName = request.getparameter ("name");//Receive Parameters6String strage = Request.getparameter ("Age");//Receive Parameters7String strsex = request.getparameter ("Sex");//Receive Parameters8%>9<%--Output parameter Content--%>Ten<%= "Name parameter value is:" +strname%> One<%= "Age parameter value is:" +strage%> A<%= "Sex parameter value is:" +strsex%>
View Code

params.jsp

1<%@ page language= "java" contenttype= "text/html; charset=gb2312 "%>234<title> include JSP files and pass multiple parameters </title>56<body>7Use the include action element to include a JSP file and pass multiple parameters <br>8<jsp:include page= "contentdemo2.jsp" >9<jsp:param name= "name" value= "Jame"/>Ten<jsp:param name= "age" value= "/>" One<jsp:param name= "Sex" value= "man"/> A</jsp:include> -</body> -
View Code

<jsp:forward> action elements paired with <jsp:param> action elements

forwardeddemo.jsp (single parameter)

1<%@ page language= "java" contenttype= "text/html; charset=gb2312 "%>234<title> jump to the page </title>56<body>78<p> Parameters received:</p>9<%TenString strage = Request.getparameter ("Age");//Receive Parameters One%> A<%--Output parameter Content--%> -<%= "Age parameter value is:" + strage%> -</body> the
View Code

paramforward.jsp

  1  <%@ Page language= "java" contenttype= "text/html; charset=gb2312 "%> 2   3   <title> jump and pass parameters </title>   6  <body> 7  Use the forward action element to jump to another JSP file and pass the parameter <br> 8  <jsp:forward page= " forwardeddemo.jsp "> 9  <jsp:param name=" age "value=" "/>10  </jsp:forward>11  </body> 12   
View Code

FORWARDEDDEMO2.JSP (multi-parameter)

1<%@ page language= "java" contenttype= "text/html; charset=gb2312 "%>234<title> jump to the page </title>56<body>78<p> Parameters received:</p>9<%TenString strName = request.getparameter ("name");//Receive Parameters OneString strage = Request.getparameter ("Age");//Receive Parameters AString strsex = request.getparameter ("Sex");//Receive Parameters -%> -<%--Output parameter Content--%> the<%= "Name parameter value is:" + strName%> -<%= "Age parameter value is:" + strage%> -<%= "Sex parameter value is:" + strsex%> -</body> +
View Code

paramforward2.jsp

1<%@ page language= "java" contenttype= "text/html; charset=gb2312 "%>234<title> jump and pass parameters </title>56<body>7Use the forward action element to jump to another JSP file and pass parameters <br>8<jsp:forward page= "forwardeddemo2.jsp" >9<jsp:param name= "name" value= "name"/>Ten<jsp:param name= "age" value= "/>" One<jsp:param name= "Sex" value= "man"/> A</jsp:forward> -</body> -
View Code

The param of java-jsp action elements

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.