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

Pass values to XML

Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

I am using Jersey to implement REST Web Services in my project. Currently i am trying a simple application where i post values from a FORM and process it to produce a XML output.

The Resource code is


The create_output_xml.xml page is


When i try to run it, the values get posted and XML page is displayed but with no values.
I knew that i didn't pass the value, but i dont know how to pass these values to the xml so that it'll be displayed in output instead of ${}.


Never try to be a hard-worker. Be a smart-worker.
My Blog
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Have you tried setting the corresponding attributes in the servlet request object?
See the javax.servlet.ServletRequest interface API documentation for details on how to set attributes in the reqeust obejct.
Best wishes!
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

^^
So do i need to create XML using JAXB and pass it to client?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
I came to think of something:
The output page is not a JSP, so I don't think things like ${description} and ${summary} will be substituted even if you have the corresponding attributes set in the request.
You should use some templating framework, like Apache Tiles http://tiles.apache.org/, or some other mechanism to replace the placeholders with values.
Best wishes!
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

^^

Thanks for the reply...

I got further simpler way to achieve that. Just created a bean with all values to be added in XML and pass it as a Object. Then, the Jersey will take care of the rest. It created the XML!!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Pass values to XML