JSTL c:url Example With c:param Tag

JSTL <c:url> tag is used for storing a url into a variable with proper url rewriting, mostly <c:url> is used with <c:param> tag for adding parameter inside a <c:url>.
You can see required attributes for <c:url> and <c:param> tags on the below example.
<c:url> With Request scope
<c:url var="url" value="/index.jsp" context="/JSTLExample" scope="request"/>
${requestScope.url}
<c:url> With Session scope
<c:url var="url" value="/index.jsp" context="/JSTLExample" scope="session"/>
${sessionScope.url}
Required Libraries
Syntax allowed for <c:param> tag
<c:param name="parametername" value="parametervalue"/>
Following are the attributes needed for <c:param> tag
name: To specify the name of the parameter.
value: To specify the value of the parameter.
JSTL <c:url> Example With <c:param> Tag
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <html> <head> <title>JSTL <c:url> Example With <c:param></title> </head> <body> <!--JSTL <c:url> Tag Example With <c:param>--> <c:url value="/index.jsp" context="/JSTLExample" var="url" scope="request"> <c:param name="username" value="rockey" /> <c:param name="password" value="password123" /> </c:url> ${requestScope.url} </body> </html>