File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes best way to send xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "best way to send xml " Watch "best way to send xml " New topic

best way to send xml

Priyanka Chaurishia

Joined: Oct 12, 2011
Posts: 9
Hello There,

I want to do a http post using an object.

So I have method like this :
public Response update(DomainClass scheduledTask) {

now with unit testing I am successfully able to do the update:

String newTask = "<DomainClass >"
+ "<field1>test.jar</field1>"
+ "</DomainClass >";

URL postUrl = new URL("http://server//update/update1");

HttpURLConnection connection = (HttpURLConnection) postUrl
connection.setRequestProperty("Content-Type", "application/xml");
OutputStream os = connection.getOutputStream();

I want to send the same object thru jsp any ideas how to do that ? converting form fields to xml string is way to go... but are there existing tools for that? I am looking here what people do usually?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

This doesn't seem like anything that JSP would be used or useful for.

[Asking smart questions] [About Bear] [Books by Bear]
Priyanka Chaurishia

Joined: Oct 12, 2011
Posts: 9
Than what is suggested approach... how will you send an xml ?What techs would you use ? Now I can write whole code to convert form data into xml string but I want to use some existing framework to do this .So how would you approach this ?
Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 524
Can you explain higher level functionality what you are trying to achieve? There may be some other way to do the same thing.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
A simple and efficient approach would use File Transfer Protoccol (FTP) to send an XML-based file. An alternative would be to send the data as a message via messaging system.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

You could even use code which looked a lot like what you wrote to upload the XML via HTTP POST, if that's the requirement. However the statement that JSP isn't the right place to put such code is still correct.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
File size is an important aspect to consider. XML-based data files greater than 1 GB typically are best sent via FTP. A small XML document can be sent effectively via HTTP or JMS-based message.
Priyanka Chaurishia

Joined: Oct 12, 2011
Posts: 9
Thanks for inputs guys. I think metadata exchange on both layers () is the way to go . Still trying to figure out how to do this.
I agree. Here's the link:
subject: best way to send xml
It's not a secret anymore!