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:param name="param1" value="Anusmita"/>
<jsp:param name="param2" value="Rohini,Delhi"/>
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
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.