I have built a mobile application in J2ME and it reads data from a website.
In WTK (wireless toolkit) everything works now, but when I test the samen app on my mobile (nokia) device, it behaves differently:
It gives another type of html back: it doesn't show a <hr>
tag, but a <开发者_如何学Python;hr/>
tag.
There is a possibility that the remote website i'm trying to read behaves differently for different clients, but I assume this is not the case.
What can this be? Different encoding types for each client or so? I'm not familiar with this.
Perhaps your assumption is incorrect. <hr />
is an XHTML end tag, so the site you're accessing may well be returning a different (XHTML) version of the page when you're requesting from the real device.
The remote site will check the User-Agent header in your request and decide how to render the page depending on what it finds. You can check this by requesting the same page using a program like curl for each of the user agents in question.
EDIT
As commented by QuickRecipesOnSymbianOS, the user agent you're setting might be getting lost on the way to the remote site. Perhaps you can use a site like http://www.useragentstring.com/ to see what's happening.
Another thought was that if you are using a mobile network when accessing the site from the real device, rather than say WIFI, the network operator may have implemented something that changes the HTML returned by the remote site.
精彩评论