Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to know whether the browser is IE or netscape

 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Jsp How to know whether the browser is IE or netscape orsomething else.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64985
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the user-agent header.
bear
 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
user agent header means??? where to find that
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where we have to call this window.navigator.appName what is the Syntax for that.
 
jyothsna kumari
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

this works in netscape and in explorer.
// Mathias
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic