I check for MSIE instead of 'compatible' because I thought browsers like Opera
might also have compatible in the string. Here are the strings I get returned on
two systems (NT and Win 95)
I get this returned for Netscape:
Mozilla/4.73 [en] (WinNT; U)
Mozilla/4.08 [en] (Win95; I;Nav)
and this for Internet Explorer:
Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)
Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)
I would be interested in learning what some of the less common browsers are
returning...
Donald
This is the JSP I used:
<html>
<head><title>Browser Test</title></head>
<body>
<p><%= request.getHeader("User-Agent") %></p>
</body>
</html>
Nestor Florez wrote:
> Does that really work? I thought that the IE browser had in there something
> like
> "Mozilla compatible".
>
> Nestor :-)
>
> -----Original Message-----
> From: Donald Vandenbeld [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 17, 2000 12:55 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Web Browser detection in JSP
>
> I am using something like this in my controller servlet:
>
> boolean nav = false;
> boolean ie = false;
> String browser = request.getHeader("User-Agent");
> if (browser.indexOf ("Mozilla") && (!browser.indexOf("compatible"))) nav =
> true;
> if (browser.indexOf ("MSIE")) ie = true;
>
> Donald
>
> "P.J. Tenn" wrote:
>
> > Hello,
> >
> > I am surprised this wasn't already have been posted and answered, but I
> > searched the archives of this mailing list and could not find any info on
> > this ...
> >
> > At any rate, is there a way to detect whether someone is using Netscape or
> > IE using JSP? I know this can be done easily in JavaScript using code
> along
> > the lines of:
> >
> > var browser = navigator.appName;
> > var Nav = (browser == "Netscape");
> > var IE = (browser == "Microsoft Internet Explorer);
> >
> > However, I need to set boolean variables within the scriptlet <% ... %>
> tags
> > based on whether Netscape or IE is being used.
> > Thanks in advance!!!
> >
> > P.J.
> >
> >
> ===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets