Win a copy of Spring Boot in Practice this week in the Spring 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:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Consume XML in JSP from a URL

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please let me know the best approach in the below scenario :

I have a URL which returns an XML. I want to use this URL in a JSP page get the output XML, store it in a string and apply some CSS over it.

Please let me know the best way to approach this.

Thanks,
Satya.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best way to approach the problem is to develop a freestanding Java class that opens the URL and reads the stream into an XML parser.

Once you are able to parse the XML add methods to extract whatever you need from it.

Note that none of the above involves JSP because code inside a JSP just complicates things. Get it running as a utility class first.

If you have not done any XML processing, go do Sun's XML tutorial first.

Bill
 
Satya Sri
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't want to make a URLConnection and then open the URL as the Application that i have presently has got some thread stuck issues with opening URL connections from the Weblogic App server that it already hosted on.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then how do you plan on getting the XML into your application?
 
Satya Sri
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is the question that i had. I have a URL and can get the XML by hitting the URL, but i do not want to make a URLConnection. So is there any other approach to get the XML other than using URLConnection ?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it's only available as a web resource (URL) and you don't want to access it as a web resource, I don't know what other options you have.

Can you explain the treading issue that you're having?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic