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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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

Reply via email to