Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTPConnection MIDlet in Ch.7 of SCMAD Exam guide

 
Jane Joseph
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sathya, Ko Ko

I'm executing the HTTP Connection (Listing 7.1) from the book on Nokia S40 emulator. On Launching the MIDlet get the message, "HTTPMIDlet running. Nothing to display". The url I'm using is http://google.com. I am also printing some values set in the HTTPConnection as given below-
lastModified: 0
host : google.com
encoding: null
url: http://google.com
port: 80
content type: text/html; charset=UTF-8
got content type: text/html; charset=UTF-8
total bytes read: 1391
got data:[B@d590dbc

Is this output as expected? Probably it would open the web page while running on the actual device. (Currently do not have an S40 device handy)

Regards,

 
Sathya Srinivasan
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The connection and messaging examples provided in the book are to show how to use the API and aren't really full applications. In this case, you are getting the "Nothing to display" message because no screen instance is instantiated and associated with the Display within the MIDlet. In essence, this MIDlet has no user interface, and hence the message.

Also, the MIDlet by itself does not act as a browser and hence getting the HTTP data doesn't mean it can be displayed. A more practical scenario working on the same example would be if you have an RSS feed in a website, you can get the contents of the feed, parse the XML, and display it in a way you want to.

So, the result you saw was expected.
 
Jane Joseph
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your explanation.

I believe google website has a RSS feed. Though I do not know much about getting the contents, parsing the XML and displaying it on my UI on mobile. Am looking up for some info on the same. By chance you have some links/tutorials for the same, I'll be glad if you could share it.

Regards,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic