JSTL c:url Core Tag

The JSTL <c:url> Core Tag is used to format or encode a url into a string variable. This variable can be used anywhere in the jsp instead of using url directly.

Syntax:

<c:url value="Url" var="varNmae"/>

c:url tag attributes:

Attribute Description Required
value It specify the base URL. Yes
context / followed by the name of a local web application. No
var Name of the variable to expose the processed URL. No
scope Scope of the variable to expose the processed URL. No

Example:

test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


	
		c:url JSTL core tag example
	
	
		
		

Click here

hello.jsp


	
		c:url JSTL core tag example
	
	
		

This is a c:url JSTL core tag example.

web.xml


	
  
          test.jsp
  	


Output:

jsp example 40 first
 
Click on the link.
jsp example 40 second
 
Download this example.
 
Next Topic: JSTL c:param Core Tag with example.
Previous Topic: JSTL c:forTokens Core Tag with example.