The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


servlet finding the browser used...

Posted by Jeff Kinsey on September 04, 2000 at 10:06 AM

The SnoopServlet that comes as part of the JSDK download has an example of getting HTTP header data. The servlet cycles through the request header names and displays their value. What you are looking for is the following:

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

I found the above on the Java Developers Connection...

> Friends,

> I come from Perl/CGI background and will like to know some of the equivalents iof Perl/CGI in Java Servlets. Specifically, I want to find out what's the browser that the user is using to visit/invoke the servlet. In CGI the browser can be found out by using the environment variable called 'HTTP_USER_AGENT' via call $ENV{'HTTP_USER_AGENT'}. What's it's equivalent in Java Servlet ?


Salil V Gangal


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us