Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

best way to send xml

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 67620
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This doesn't seem like anything that JSP would be used or useful for.
 
Priyanka Chaurishia
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you explain higher level functionality what you are trying to achieve? There may be some other way to do the same thing.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 26963
84
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic