Passing Parameters using

Request parameters can be passed by using

Passing Parameters using <jsp: param>


Request parameters can be passed by using <jsp: param>

This tag contains two attributes: 1) name 2) value.  This tag is mostly used as a child tag enclosed inside any  action tag.  The tag which is enclosing this tag in this example is <jsp: forward >. This tag forwards the request object containing the client request from one jsp file to another file. The targeted file can be a Html file, jsp file or any other servlet file. This tag contains only one parameter page = "relativeURL". This relativeURL represents the file to which the request will be forwarded. 

We can pass the parameter names and values to the forwarded file by using a <jsp: param> tag. We can use multiple <jsp: param> tag inside the <jsp: forward> tag if we have to pass more than one parameter to the target file. The name attribute specifies the parameter name and takes a string literal as a value. These parameters are evaluated at request time. 

In this example we are passing a parameters to a file by using <jsp: forward> tag. Inside this tag we have used the tag <jsp: param>. This tag is used to pass the name and values to the targeted file. These parameters will be retrieved by the targeted file by using request.getParameter() method. In this way we can pass and retrieve the parameters. 

The code of the program is given below:



<jsp: forward page="ssParameters.jsp">
  <jsp: param name="myParam" value="Amar Patel"/>
  <jsp: param name="Age" value="15"/>
</jsp: forward>


This page had a parameter forwarded to it:<br>
<b>Name:</b> <%= request.getParameter("myParam") %><br>
<b>Age:</b> <%= request.getParameter("Age") %>

Output of the Program:


Download this example.

Share on Google+Share on Google+

Passing Parameters using

Posted on: February 9, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Passing Parameters using   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
kedar pethe
April 16, 2011

Excellent website. Full focused information. Keep it up!!!!!
March 3, 2012
Dynamic values for parameters

Can the parameter values be made dynamic, such that they are enclosed in <% %> and a variable be passed.
June 18, 2012
why end tag for jsp:param

i like to get the need of </jsp:param> tag usage
October 12, 2012
A question

I have a question, I wanna pass an object, for example a map, using jsp:param, is it possible? how can I do it?