aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "best way to send xml " Watch "best way to send xml " New topic
Author

best way to send xml

Priyanka Chaurishia
Greenhorn

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

I want to do a http post using an object.

So I have method like this :
@POST
@Consumes("application/xml")
@Path("/update/update1")
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
.openConnection();
connection.setDoOutput(true);
connection.setReadTimeout(5000);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/xml");
OutputStream os = connection.getOutputStream();
os.write(newTask.getBytes());

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
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Priyanka Chaurishia
Greenhorn

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: 509
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
Bartender

Joined: Oct 14, 2005
Posts: 18655
    
    8

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
Greenhorn

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: http://aspose.com/file-tools
 
subject: best way to send xml