Change Servlet User Agent
I want to 开发者_JS百科show PC users the mobile version of arbitrary websites. I'm thinking that I want to retrieve the page using a mobile user agent, then pass the page along to the user.
First of all, would that work?
Second, how? Surely I can't just use <%@include file="http://...."%>
, because that would just show PC users the PC version of the web site. I don't think I want to make a custom HTTP client, not if there's a better way?
For reading webpages, that should work. The user would request the page from you, you'd interecept, change the user agent to mobile, get the webpage, and then return it. A proxy of sorts.
Unless you perform as a proxy, you might have problems when the user tries to navigate, as the buttons and forms will refer to the site directly, and bypass your user-agent modification.
精彩评论