Java Reference
In-Depth Information
Using EL Implicit Objects
Of the EL implicit objects listed in Table 3-3 , applicationScope , pageScope , requestScope , and
sessionScope are meant for specifying scope. These are used to access scoped attributes, that is,
to access data from JavaBeans, maps, arrays, and lists that have been stored as attributes in any of
the four scopes: page, request, session, and application.
The other implicit objects listed in Table 3-3 are used to access request parameters, request
headers, cookies, context-initialization parameters, and pageContext objects. This section illustrates
the usage of some of the EL implicit objects.
Accessing Request Parameters
Listing 3-24 illustrates a simple form used to submit the request parameters through form.jsp .
Listing 3-24. form.jsp
1.<body>
2.<form action="books" method="post">
3.<input type="hidden" name="action" value="books"/>
4.<p>Book Title: <input type="text" name="bookTitle"></p>
5.<p>Author 1 Name: <input type="text" name="authorName"></p>
6.<p>Author 2 Name: <input type="text" name="authorName"></p>
7.
8.<input type = "submit"/>
9.</form>
10.</body>
In Listing 3-24, the name property of the <input> tag is the same: authorName .
Listing 3-25 illustrates the usage of the EL implicit objects param and paramValues to retrieve the
request parameter and display the result on the result.jsp page.
Listing 3-25. result.jsp
1.<p>Book Title: ${param.bookTitle}<br>
2.Author 1: ${paramValues.authorName[0]}<br>
3.Author 2: ${paramValues. authorName[1]}
4.</p>
Line 1 : This uses the EL implicit object param to get the Book title.
Line 2 to Line 3 : This code uses the EL implicit object paramValues to get the
Author 1 and Author 2 names.
Accessing the Header
The EL implicit objects header and headerValues give you access to the header values that can be
obtained using the request.getHeader() and request.getHeaders() methods.
 
Search WWH ::




Custom Search