File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes sending xml to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "sending xml to servlet" Watch "sending xml to servlet" New topic
Author

sending xml to servlet

David Westbrook
Greenhorn

Joined: Dec 18, 2008
Posts: 16
hey all,

I have an xml document containing data in html page, and I would like to send that to a servlet.

I'm thinking I can do it one of two ways.

ONE:



I have seen supposedly working examples of this, but they were IE specific, and I'm looking for something that complies w/w3c.

and then on servlet I do something like:




I have a feeling that I need to alter the setRequestHeader, so any suggestions would be helpful.

The other way I think would be possible would be to turn the xml doc into a string and send it like this:



and then do something on servlet like:




problem w/this is xmldoc doesn't have toString().

Any help (thoughts, comments, examples, good references) would be appreciated.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41867
    
  63
As to the client side in the browser, any code that does this will have some IE-specific stuff; that's just how XMLHttpRequest is implemented. But that's generally abstracted away by the thinnest layer on top of it; see this for code that works in all browsers.


Ping & DNS - my free Android networking tools app
David Westbrook
Greenhorn

Joined: Dec 18, 2008
Posts: 16
I have it working perfectly. I will post more details when I get the time. Check back in a couple of days if you're interested.
[ January 02, 2009: Message edited by: David Westbrook ]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4658
    
    5

Glad to hear that you have it working. One thing you might want to consider, XML compresses well, there is lots of redundancy, so the built in Java gzip code can save a lot of time and bandwidth.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sending xml to servlet