aspose file tools*
The moose likes JSP and the fly likes how to know whether the browser is IE or netscape Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how to know whether the browser is IE or netscape" Watch "how to know whether the browser is IE or netscape" New topic
Author

how to know whether the browser is IE or netscape

Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
In Jsp How to know whether the browser is IE or netscape orsomething else.


Thanks,
Mathews
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Check out the user-agent header.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
user agent header means??? where to find that
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
Hi
You can go to,
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/
and look at the User-Agent request header returned by the browser in the HttpServletRequest object, which is accessible to JSPs via inbuilt object named- request.
Please try go google on User-Agent format to see how to really detect the browser from that string...
Regards
Maulin
Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
Thanks a lot....
if i am running on IE request.getHeader("User-Agent") returns
Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
And in netscape am getting
Mozilla/4.7 [en] (WinNT; I).
Now How to compare This and take a decision.should we check the whole string and accordingly do the operation???smallconfussion....
jyothsna kumari
Ranch Hand

Joined: Jul 21, 2003
Posts: 108
hai,
by using this u can know what browser the client is using-
window.navigator.appName. this returns the name of the browser.

jyothsna
Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
where we have to call this window.navigator.appName what is the Syntax for that.
jyothsna kumari
Ranch Hand

Joined: Jul 21, 2003
Posts: 108
hai,
u can call this function and see.
<SCRIPT LANGUAGE="JavaScript">
function aaa() {
alert(window.navigator.appName);
}
</script>
in the alert box u get the type of browser.
jyothsna
Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
thanks for the very fast response......but i have to use the same in jsp.so how to use in jsp
jyothsna kumari
Ranch Hand

Joined: Jul 21, 2003
Posts: 108
place the above code before the body tag of a jsp page
and call the function on onload of the body tag.
tried to paste the code but some error is commimg.
Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
I tried that onLoad of the page......It is giving Exact Result.But i have use same functionality using java,jsp
jyothsna kumari
Ranch Hand

Joined: Jul 21, 2003
Posts: 108
u want the browser type in u'r java class?
if yes then u can get the type from jsp page
and set in a session variable and pass it to u'r
java class.
if no,then pls give me some details so that i may
help u.
jyothsna
Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
Thanks Jyothsana.......Now how to call window.open() for netscape.
This is working with IE but not with Netscape...
window.open("browsertest.jsp","","alwaysRaised=yes,dependent=yes,height=200,width=300,menubar=no,resize=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no");
Mathias Nilsson
Ranch Hand

Joined: Oct 13, 2003
Posts: 107

this works in netscape and in explorer.
// Mathias


SCJP2 , MCP( 70-229 ) , Preparing For SCWDC
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to know whether the browser is IE or netscape