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"/>

<c:url> With Session scope

<c:url var="url" value="/index.jsp" context="/JSTLExample" scope="session"/>

Required Libraries

You need to download

  1. Tomcat 7
  2. JSTL 1.2

Following jar must be in classpath

  1. jstl-1.2.jar

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"%>

<title>JSTL <c:url> Example With <c:param></title>


	<!--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" />



Your email address will not be published. Required fields are marked *