John Swanteson wrote:

> Hello,
>
> I have been developing servlets for some time and have come accross the
> need for an environment variable not provided
> with a get... method (i.e. getQueryString) in the HTTPRequest object.  I
> would like to obtain HTTP_USER_AGENT so I know the
> browser the user is using.  I know I can use the System.getenv method but I
> don't want to use a depreciated method.
>
> Does the Servlet API provide a general way of accessing a specific web
> server/browsers environment variables or do we
> only have access to what they provide has methods in the Request object?
>
> I would appreciate help.
>
> Thank you in advance.
>

Use:

    String userAgent = request.getHeader("User-Agent");

See the HTTP specification (RFC 1945 for HTTP/1.0 or RFC 2068 for HTTP/1.1) to
see what protocol headers are provided.

Note -- in a servlet world, this is not an "environment" variable, and not
available via any System.getXxx function, because it changes on every
request.  Read the servlet API spec, or the associated tutorial information,
to understand how servlets work.

Craig McClanahan

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to