Get your CodeRanch badge!*
The moose likes Servlets and the fly likes Recognize the browser type    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Recognize the browser type    " Watch "Recognize the browser type    " New topic
Author

Recognize the browser type

Rao Devata
Greenhorn

Joined: Jul 21, 2006
Posts: 4
Hi,
We are developing website. In which we want to know the from where
the request is originated. I mean whether it is a request from mobile browser or it is a request from desktop browser.
Our objective is to find out browser type and based on that forwarding the request (mobile browser request or desktop browser request) to the particular jsp page which contains the view for the particular client.

So the question is , how to find browser type. b'cos current mobiles also have html/xhtml enabled browsers. but their screen - size prohibit
to take adwantage of these languages.

Please help us..
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

All you have on the server side is the User-Agent request header.
Some browsers can be configured to spoof that value so it's not 100% reliable.

There are ways, using Javascript, to determine the browser type from the client side, which can be sent to the server in the next request via querystring or post variables.

Say the word and I'll move this thread to our HTML/Javascript forum.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Rashid Mayes
Ranch Hand

Joined: Jan 11, 2006
Posts: 160
At a previous company we used a combination of the user-agent and accepts header to determine micro-browser vs browser. We used a system of pattern matching to determine the best content for the device.

As stated earlier, desktop browsers can spoof header easily. However, I am not aware of the same for microbrowsers.

There are other headers that mark the use of a micro-browser such as

x-wap-client-ip
x-wap-profile
wap-connection
x-bluecoat-via
x-up-devcap-cc

to name a few. It may be a good idea, after determining the browser type and presenting the first page, to include a link to the alternate version. This would help users who are identified incorrectly.

If you decide to got the user agent route, here are a list of user-agents that can help you build and test the identification portion of your code. The list is compiled from visitor statistics on hostj2me.com and organized by frequency.

http://www.hostj2me.com/useragents.htm


BTW, spiders will sometimes spoof usergents when index your site.


Rashid Mayes
http://www.hostj2me.com/ - http://www.worlddeveloper.org/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Recognize the browser type
 
Similar Threads
Method to recognise the device from where request is coming
another design pattern ambiguity
Method to recognise the device from where request is coming
InstantiationException
Method to recognise the device from where request is coming