aspose file tools*
The moose likes Servlets and the fly likes Identify request coming from mobile or PC 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 "Identify request coming from mobile or PC" Watch "Identify request coming from mobile or PC" New topic
Author

Identify request coming from mobile or PC

Ramesh Sengani
Ranch Hand

Joined: Nov 23, 2011
Posts: 36
Hi,

I am working in project which are in two version one for pc and other for mobile . for both page are different. For that i want to know the http request coming from mobile or PC . Based on that i want to show jsp page.


Please help me..


Thanks in advance
Prashant Chindhade
Ranch Hand

Joined: Jan 19, 2011
Posts: 77
Check this link.

Shehzaad khan
Greenhorn

Joined: May 07, 2012
Posts: 5

Hey Ramesh..

We already had a discussion on the same topic... See my post here

This will surely help you.

regards,
Shahid
Ramesh Sengani
Ranch Hand

Joined: Nov 23, 2011
Posts: 36
thanks sahid

but i have no idea about user agent also.Is that possible to give me one simple example to fetch coming data from request and based on that redirect for mobile or pc
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

As already pointed out, you need to sniff the user-agent string. A little research or testing on your own will show you what returned front he different browsers.

Bear in mind that the user-agent can be spoofed so it's not 100% accurate, but it's all you've got to work with.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19538
    
  16

Even if it's not spoofed, the user agent header is not full proof. My company's website shows me the mobile version when I visit it with Opera on my PC.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ramesh Sengani
Ranch Hand

Joined: Nov 23, 2011
Posts: 36
There is no any garrenty proof solution to identify request which diffrenciate pc and mobile?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

Nope. No foolproof method.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
I wouldn't worry about the spoofing aspect; if people take care to appear as something other than what they are, then they should not be surprised to be treated as something other than what they are.
Ashsih khurana
Greenhorn

Joined: Jul 20, 2013
Posts: 4
You can use MobileESP here a very efficient page and open source solution to your problem.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Identify request coming from mobile or PC
 
Similar Threads
Method to recognise the device from where request is coming
Difference between WML and XHTML
Method to recognise the device from where request is coming
Method to recognise the device from where request is coming
Sending SMS from PC to MOBILE