Java Reference
In-Depth Information
The value of the Condition field must be enclosed in ${} , this denotes this value as a
JSTL expression . In our particular example, we are looking for a request parameter
named displayConditionalText , whose value is true . If (and only if) the request
parameter is present and has the expected value, the text inside the <c:if> tag will
be rendered in the generated HTML page from our JSP.
In the above screenshot, param is a JSTL implicit object to obtain the value of a
request parameter, param.displayConditionalText is equivalent to request.
getParameter("displayConditionalText") , as we can see, using the implicit
object allows us to save quite a bit of typing, and it makes our expression a lot more
readable. There are a lot of JSTL implicit objects, the most common ones are param ,
applicationScope , sessionScope , requestScope , and pageScope . As we already
saw, param allows us to easily retrieve request parameters, the others in the list
allow us to retrieve attributes in the application, session, request, and page scopes,
respectively, they all use the dot notation we saw in the param implicit object, with
the key used to store the attribute following the dot, and return the object attached to
the appropriate scope with the said key.
To see all implicit JSTL objects, simply invoke code completion ( Ctrl
+space ) between the two curly braces in a JSTL expression ( ${} )
in the NetBeans JSP editor.
Back to our example, the Variable Name field is optional; if entered, it will be used
to store the value of the conditional expression in a Boolean variable. The Scope field,
is also optional, if a value is selected, this will be the scope of the variable entered
in the Variable Name field; if no value is selected for the Scope field, and a value is
entered for the Variable Name field, then the variable will have a default scope of
Search WWH ::

Custom Search