jQuery in Action, 3rd edition
The moose likes Java Micro Edition and the fly likes Sending XML to a mobile phone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Sending XML to a mobile phone" Watch "Sending XML to a mobile phone" New topic

Sending XML to a mobile phone

Raymond Ong
Ranch Hand

Joined: Jul 17, 2005
Posts: 46

I have made a servlet that sends an XML data via an HttpServletResponse object. With this approach I can send the XML data to a browser or an HttpClient object which uses the getResponseBody() method. Problem is, it does not work with the MIDP2 HttpConnection object using the openInputStream(). Has anyone tried sending XML data to a mobile phone?

Please see code below for doPost().

Thanks a lot.

code based on : http://www.javazoom.net/services/newsletter/xmlgeneration.html
[ November 08, 2005: Message edited by: Raymond Ong ]
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Well for J2ME calling a Servlet, the out.write() would be the straight XML String. Meaning you don't add the XML Object to the HTTPResponse Object, but it is the response itself. I have done this many times with URLConnection and J2ME.

Personally when it comes to this, I just send straight text and forget about the XML. It all depends on the size of the data being sent back. Most of the time I try to keep it really small so there is less time.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Raymond Ong
Ranch Hand

Joined: Jul 17, 2005
Posts: 46
Since I really can't get my previous code to work, looks like i'm gonna stick to sending plain text xml.

Thanks a lot.
I agree. Here's the link: http://aspose.com/file-tools
subject: Sending XML to a mobile phone
It's not a secret anymore!