JSTL c:param Core Tag

The JSTL Core Tag is used with and tags to add the parameters.
Syntax: 

c:param tag attributes:

AttributeDescriptionRequired
nameIt specify the name of the request parameter to set in the URL.Yes
valueIt 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:


Click on the link.



No comments: