Java Reference
In-Depth Information
LISTING 21.5
Continued
5: <body>
6: <ul>
7: <li>Accept: <%= request.getHeader(“Accept”) %>
8: <li>Accept-Encoding: <%= request.getHeader(“Accept-Encoding”) %>
9: <li>Connection: <%= request.getHeader(“Connection”) %>
10: <li>Content-Length: <%= request.getHeader(“Content-Length”) %>
11: <li>Content-Type: <%= request.getHeader(“Content-Type”) %>
12: <li>Cookie: <%= request.getHeader(“Cookie”) %>
13: <li>Host: <%= request.getHeader(“Host”) %>
14: <li>Referer: <%= request.getHeader(“Referer”) %>
15: <li>User-Agent: <%= request.getHeader(“User-Agent”) %>
16: </u1>
17: </body>
18: </html>
In lines 7-15 of the environment.jsp page, each line contains a call to getHeader()
that retrieves a different HTTP request header. Figure 21.5 shows an example of the out-
put. The values reported for each header depend on your web server and the web browser
you're using, so you won't see the same values for User-Agent, Referer, and other
headers.
FIGURE 21.5
Using servlet
variables on a JSP
page.
Using Scriptlets
You also can use Java statements in JSP—calling methods, assigning values to variables,
creating conditional statements, and so on. These statements begin with the <% tag and
end with the %> tag. More than one statement can be enclosed within these tags.
Statements that appear inside a page are called scriptlets . You can use any of the servlet
variables that were available for expressions.
 
Search WWH ::




Custom Search