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.