tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Bazeley" <j...@ecnetwork.co.nz>
Subject RE: Need help identifying the browser a user is using
Date Wed, 21 Mar 2001 21:42:35 GMT
Watch out for Opera users.

Opera can send headers pretending to be whatever the user likes. 
Just 'cos it says it's IE5 doesn't mean code like

onsubmit="return validate(document.form1)"

is magically supported!

--
john

> -----Original Message-----
> From: Shawn [mailto:shawn@koyuru.com]
> Sent: Tuesday, 20 March 2001 14:51
> To: tomcat-user@jakarta.apache.org
> Subject: Re: Need help identifying the browser a user is using
> 
> 
> I dk if this answers your question but one suggestion I've seen suggests
> testing for IE first and the netscape afterward. (from JAVAServer pages
> H.Bergsten)
>  For example...
> <%@ page language="java" contentType="text/html" %>
> <html>
> <body bgcolor="white">
> 
> <% if (request.getHeader("User-Agent").indexOf("MSIE") != -1) { %>
>   You're using Internet Explorer.
> <%
>    } else
>      if (request.getHeader("User-Agent").indexOf("Mozilla") != 1) {
> %>
>   You're using Netscape.
> <% } else { %>
>   You're using a browser I don't know about.
> <% } %>
> 
> </body>
> </html>
> ----- Original Message -----
> From: "Gerard Monsen" <gerim@1finder.com>
> To: <tomcat-user@jakarta.apache.org>
> Sent: Tuesday, March 20, 2001 11:09 AM
> Subject: Need help identifying the browser a user is using
> 
> 
> >       I'd like my servlet to return content based on the
> > browser the user is using.  I know that at least Netscape
> > and IE identify themselves using the "user-agent" field.
> > However, their syntax between them and at least between
> > two different versions of Netscape are very different.
> > For example:
> >
> > Netscape 4.76:
> > user-agent: Mozilla/4.76 [en] (WinNT; U)
> >
> > Netscape 6.0:
> > user-agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; m18) 
> Gecko/20001108
> Netscape6/6.0
> >
> > IE 4.0:
> > user-agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
> >
> > So, you can see that Netscape 4.76 only identifies itself
> > as Mozilla, Netscape 6.0 identifies itself at the end of the
> > line, and IE 4.0 identifies itself in the parenthesis.  Who knows
> > how other versions (IE 5.0, Netscape 3.1, etc.) and other
> > browsers identify themselves?
> >
> >        Does anyone have a simple class that knows all of the
> > peculiarities of these browsers can parse the user-agent field
> > correctly?  Any help you can give would be very appreciated.
> >
> > Gerard Monsen
> > 1Finder.com
> 
> 

Mime
View raw message