Home Jsp Passing Parameters in jsp
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Passing Parameters in jsp

Advertisement
This section illustrates you how to pass parameters in jsp.

Passing Parameters in jsp

     

This section illustrates you how to pass parameters in jsp.

JSP can access the HTTP request object. It provides getParameter() method for retrieving parameter values by name. Parameters can be passed by using a tag <jsp:param>. It has two attributes name and value. We are providing you an example.

 

 

 

 

Here is the code of passingParameter.jsp

<jsp:forward page="parameter.jsp">
<jsp:param name="param1" value="Anusmita"/>
<jsp:param name="param2" value="Rohini,Delhi"/>
</jsp:forward>

Here is the code of parameter.jsp

<%@ taglib prefix="d" uri="http://java.sun.com/jsp/jstl/core" %>
<h2>This page had a parameter forwarded to it:</h2><br>
<b><%= request.getParameter("param1") %><br>
<%= request.getParameter("param2") %></b>

In the above example, the tag <jsp:forward> forwards the request object containing the client request from one jsp file to another file. We are passing the parameters using the tag <jsp:param> which contain names param1, param2 and their values. These names and  values of <jsp:param> tag are passed to the parameter.jsp page.

Here is the output

Download Source code

 

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 20, 2008

Related Tutorials

Ask Questions?    Discuss: Passing Parameters in jsp   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Apratibha Bhattacharya
July 4, 2011
please help

i m working on a project named "payroll system".i want to edit all the information of a particular employee through JSP & mysql.when i will click on edit button for a particular employee then the jsp page will be prompted retrieving all the existing data from the database in the corresponding text field. please help me.it's urgent.
DMCA.com