Home Jsp Passing Parameters in jsp



Passing Parameters in jsp
Posted on: August 20, 2008 at 12:00 AM
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

 

Related Tags for Passing Parameters in jsp:
chttpjspideparametersobjectmethodsedgetrequestvivaluetagparameternameusingidjsforievaluesramsseeitdescantrieceinpassasmpartrcajesmeobjproparamsspessquestmeterarccvinvattssrithstaccessalujepro


More Tutorials from this section

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

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.