Name
<c:url>
Synopsis
The <c:url>
action
applies the
appropriate encoding and conversion rules for a relative or absolute
URL. Specifically, it handles three types of rules: URL encoding of
parameters specified by nested <c:param>
actions (converting special characters to hexadecimal codes);
converting a context-relative path to a server-relative path; and
adding a session ID path parameter for a context- or page-relative
path (“URL rewriting”), if needed
to enable session tracking. The result is either saved in a scoped
variable or added to the current response buffer
(JspWriter
).
Syntax 1: Without a body
<c:url value="url
" [context="externalContextPath
"] [var="var
" [scope="page|request|session|application"]] />
Syntax 2: With a body
<c:url value="url
" [context="externalContextPath
"] [var="var
"] [scope="page|request|session|application"]><c:param> actions
</c:url>
Attributes
Attributename |
Java type |
Dynamic valueaccepted |
Description |
---|---|---|---|
value |
String |
Yes |
A page- or context-relative path, or an absolute URL. |
context |
String |
Yes |
The context-path for an external application in the same container, starting with a slash. |
var |
String |
No |
The variable name. The type is |
scope |
String |
No |
The variable scope. |
Example
<a href="<c:url value="/privacypolicy.jsp" />">Our privacy policy</a>
Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.