Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can servlets sent XML files?

 
Jim Smithian
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks.

Jim
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic