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

How to display XML documents using JSP?

Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
I'm trying to provide data to clients by providing them a URL to my jsp page.

The JSP page will get all the data from a table in database and display the data as an xml.

The data created okay and client's program can access it fine.

The problem is when I try to open the JSP page in the browser, it doesn't look like XML at all. I think it's because the "open" and "close" tag in XML documents.

How could I handle this so people can view the data in their browser?

Thanks in advance for the advice.

- Rudy -
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61412
    
  67

XML isn't a display format, so it's not clear at all what you mean by "display the XML".

What is it you are trying to show them?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61412
    
  67

Are you setting the content type to "text/xml"?
Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
I'm trying to display data from a table in DB and display it in XML format
so the jsp page should print out something like:



How can i set the content type to text/xml?

Thanks for the help.
- Rudy -
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
For this you can create an XML file and make a link to that. Browser will show it as it would be.
 
 
subject: How to display XML documents using JSP?