views:

114

answers:

1

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 <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.

+1  A: 

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.

martin clayton
Thanks for your response! In my code I set the User-Agent header to some value. In that way I'm using the same User-Agent in both cases. Do you think this will be overwritten with the real value later maybe?
hsmit
It is entirely possible that the J2ME implementation on your device overwrites whatever User-Agent header you set in your request.
QuickRecipesOnSymbianOS