![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e1061. Getting a Request Header in a JSP PageA JSP page can access the information in the request header by using the implicit objectrequest .
This example retrieves a few items in the request header:
The request method is <%= request.getMethod() %> The request URI is <%= request.getRequestURI() %> The request protocol is <%= request.getProtocol() %> The browser is <%= request.getHeader("user-agent") %>This example retrieves all the items in the request header: <% java.util.Enumeration names = request.getHeaderNames(); while (names.hasMoreElements()) { String name = (String)names.nextElement(); out.println(name+": "+request.getHeader(name)); } %>See also eX X.
e1063. Generating an XML Document from a JSP Page
© 2002 Addison-Wesley. |