Java Reference
In-Depth Information
Listing 3-53. Using <c:param>
<body>
<c:import url='/WEB-INF/jsp/header.jsp'>
<c:param name='user'
value='${sessionScope.userName}'/>
</c:import>
<%-- body content --%>
<c:import url='/WEB-INF/jsp/footer.jsp'/>
</body>
The <c:url>Action
The
<c:url>
action builds a URL with the proper rewriting rules applied. It can format a URL and
store it in a variable specified by the
var
attribute.
Here's the syntax without body content:
<c:url value [context] [var] [scope]/>
Here's the syntax with body content to specify query string parameters:
<c:url value [context] [var] [scope]>
<c:param> actions
</c:url>
value
, which is the URL to be processed.
<c:param>
subtags can also be specified within the body of
<c:url>
for adding
to the URL query string parameters, which will be properly encoded if necessary.
The only required attribute is
The attributed of <c:url> are listed in the Table
3-22
.
Table 3-22.
<c:url> Attributes
Name
Type
Description
value
String
URL to be processed.
context
String
Name of the context when specifying a relative URL resource that belongs to a
foreign context.
var
String
Name of the exported scoped variable for the processed URL.
scope
Scope for
var
.
String
Listing 3-54 shows the simple usage of
<c:url>
.
Listing 3-54. Using <c:url>
<c:url var="homePage" scope="session"value="
http://www.yourbookstore.com
" />