File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes How can servlets  sent  XML files? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How can servlets  sent  XML files?" Watch "How can servlets  sent  XML files?" New topic

How can servlets sent XML files?

Jim Smithian

Joined: Sep 21, 2004
Posts: 18
I am writhing some servlets which allows users to store and retrieve information in MySQl database. I am using TOMCAT 5.0.28 and J2EE.
I have the following questions:

1-How can I put the result of SQL queries into a XML file and validate it? I have the DTD file.

2- How can I put XML and XSL files into an html response and send it to the browser? Browser will transform XML into HTML using my XSL file.

Can anybody explain to me or refer me to somewhere where I can find how to do those.


Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
1. If your database doesn't do this for you, you'll have to do it yourself the good-ol' fashioned way (with code).

2. There's a directive that is used in the XML response which indicates to the client that it should transform the XML document instance. Use something akin to "< ?xml-stylesheet type="text/xsl" href="example.xsl" ?>" to do this (at the top of your XML response. Be sure you set the content type to whatever mime type xml is "text/xml" maybe?

I agree. Here's the link:
subject: How can servlets sent XML files?
jQuery in Action, 3rd edition