|
e1061. Getting a Request Header in a JSP Page
A JSP page can access the information in the request header by using
the implicit object request.
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.
e1062.
Implementing a Redirect in a JSP Page
e1063.
Generating an XML Document from a JSP Page
© 2002 Addison-Wesley.
|