JSTL c:param Core Tag

The JSTL <c:param> Core Tag is used with <c:url> and <c:redirect> tags to add the parameters.

Syntax: <c: param name =”paramName” value=”paramValue” />

c:param tag attributes:

Attribute Description Required
name It specify the name of the request parameter to set in the URL. Yes
value It specify the value of the request parameter to set in the URL. No

Example:

test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 
<html>
	<head>
		<title>c:param JSTL core tag example</title>
	</head>
	<body>
		<c:url value="/hello.jsp" var="helloUrl">
			<c:param name="userName" value="jai"></c:param>
		</c:url>
		<h4><a href="${helloUrl}">Click here</a></h4>
	</body>
</html>

hello.jsp:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 
<html>
	<head>
		<title>c:param JSTL core tag example</title>
	</head>
	<body>
		<h3>This is a c:param JSTL core tag example.</h3>
		UserName: <%= request.getParameter("userName")%>
	</body>
</html>

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>test.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 41 first
 
Click on the link.
jsp example 41 second
 
Download this example.
 
Next Topic: JSTL c:redirect Core Tag with example.
Previous Topic: JSTL c:url Core Tag with example.

Related Topics:

JSTL c:out Core Tag with example.
JSTL c:set Core Tag with example.
JSTL c:remove Core Tag with example.
JSTL c:catch Core Tag with example.
JSTL c:if Core Tag with example.
JSTL c:choose , c:when and c:otherwise Core Tags with example.
JSTL c:import Core Tag with example.
JSTL c:forEach Core Tag with example.
JSTL c:forTokens Core Tag with example.
JSTL c:url Core Tag with example.
JSTL c:param Core Tag with example.
JSTL c:redirect Core Tag with example.