Home Jsp Simple-jsp-example Passing Parameters to Another JSP Page



Passing Parameters to Another JSP Page
Posted on: October 6, 2010 at 12:00 AM
By using the include action we can pass the parameters to another jsp page. We can do this by doing using the . This tag is used as a child tag.

Passing Parameters to Another JSP Page

    

By using the include action we can pass the parameters to another jsp page. We can do this by doing using the <jsp:param>. This tag is used as a child tag. It can temporarily override a request parameter or it can temporarily introduce a new request parameter when calling a jsp page. This param tag can be attached to a query string by adding ?param1=name1&param2=name2 at the last of URL string.

In this program we are retrieving the parameter by using the getParameter("String str"). This method can be used to capture the values in the jsp post from the html form or the jsp page.

 

The code of the program is given below:

 

<html>
    <head></head>
    <body>
    <jsp:include page="RetrievingParameters.jsp" >
        <jsp:param name="name2" value="James" />
        <jsp:param name="name3" value="Bill" />
    </jsp:include>
    Pass the value:
    Name1: <%= request.getParameter("name1") %><br>
    Name2: <%= request.getParameter("name2") %><br>
    Name3: <%= request.getParameter("name3") %><br><br>
   </body>
    </html>

 

 Retriever:
    Name1: <%= request.getParameter("name1") %><br>
    Name2: <%= request.getParameter("name2") %><br>
    Name3: <%= request.getParameter("name3") %><br>

The output of the program is given below:

Download this example

 

Related Tags for Passing Parameters to Another JSP Page:


More Tutorials from this section

Ask Questions?    Discuss: Passing Parameters to Another JSP Page  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.