Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to read the response coming from XML file in jsp  RSS feed

 
Ankita Jha
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • 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
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • 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.
 
veeresh soni
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
  • 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.....
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!