• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

how to read the response coming from XML file in jsp

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ranchers,

Need help,

My jsp page is calling httpbased api ,which take input in the form of xml file and returns response in xml file.
My worry is how will i read this response in jsp...

can any one provide me with a sample code for the same....any help will be highly appreciated ...its a bit urgent

Thanks,
Ankita
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know 2 ways:
1. Parse XML file using some parsing API, get data from it, display the data with HTML markup - better do first 2 things (parsing & retrieving data) in servlet & forward data to JSP for display.
2. Apply XSLT on XML to generate HTML markup.

First one is easy, IMO.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you should use xStream but it is not highly recomanded but if your xml file tags is fix then it is ok to use xStream class.

xStream.fromXML(stringXML) this will return object and you can store information using pojo and use that according to your need.
 
Ankita Jha
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please give me some sample code for calling http based api with xml file as request and reading the response from xml file in jsp.....
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

xStream



The OP never said the XMLs being passed to and fro were classes serialized as XML.

My jsp page is calling



Your JSP page should not call such things. It is a view. Do not parse XML in a JSP. The next person to maintain the code will thank you

Parse the XML with staX and attach whatever you want to display into one of the scopes.

please give me some sample code for calling http based api with xml file as request and reading the response from xml file in jsp.....



No one can do this. The calls can be web service over SOAP calls / Web services without SOAP / REST based invocations / Post based invocations that do not follow standards / Mutipart invocations that do not follow any standard etc etc. A client like the commons HTTP client *might* help. But unless you provide more information, the help you receive will be limited
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic