Reputation: 8067
We have a web application (made in struts 1.2 and backend is hibernate) used by the users via desktop browsers. But when some of the users access the same using mobile(Android) browser, content of the screen becomes smaller. Hence the user needs to zoom it for using the app from their mobile, zooming brings scroll bars in the screen and makes it difficult for the users.
Is there some way to toggle the screens based on the browser (i.e. Desktop brwoser or Mobile browser) request? Please let me know the best possible way to achieve this.
One way I thought of is to check the user-agent
header, get the browser details and display the page accordingly but again I want the best possible way to achieve this.
Hence what I can think as of now is to have two jsp files for each screen: one for desktop browser and one for mobile browser. I don't wanna touch the existing layout for desktop users, hence rather than opting for a modification in existing jsp, planning to add new jsp files for mobile.
1) Is there any other better approach to check the for browser details(i.e. whether desptp or mobile) other than relying on the request header user-agent ?
2) Will it be a good idea to have two jsp files for two different browsers? If not then how to toggle in a single jsp without any risk of disturbing the existing stuff?
3) What are the possible issues we may face in implementing this?
4) Any better idea of achieveing the same (may be in a entirely different way than what i am planning as of now)
Please let me know about this.
Regards,
Upvotes: 0
Views: 173
Reputation: 36227
I think the best way is what you have suggested in your question. Get PHP to check the user agent and if its mobile (android/iphone) etc then perform a redirect to the mobile version of the site. It's what I do and works flawlessly.
Upvotes: 1