The JSTL url tag is just an alternative method of writing the call to the response.encodeURL() method. The only real advantage the url tag provides is proper URL encoding, including any parameters specified by children param tag.
JSTL <C:URL> Tag Example:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <head> <title>JSTL URL Tag Example</title> </head> <body> <c:url value="https://www.dineshonjava.com" var="tutorialLink"> <c:param name="author" value="Dinesh"></c:param> </c:url> <c:import url="${tutorialLink}"></c:import> </body> </html>
As you can see above, <c:url> tag is being used to store the value of url in a variable tutorialLink.
In <c:import> tag, the url attribute will have following value.
https://www.dineshonjava.com?author=Dinesh
Attributes of <c:url> tag are:
1. value:This attribute provides URL to be processed.
2. var: This attribute provides name of the exported scoped variable for the processed url. The type of the scoped variable is String.
3. context: This attribute provides name of the context when specifying a relative URL resource that belongs to a foreign context.
4. scope: This attribute provides the scope for var.