*
The moose likes Servlets and the fly likes servlet and xslt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet and xslt" Watch "servlet and xslt" New topic
Author

servlet and xslt

bernd pier
Ranch Hand

Joined: Jun 21, 2002
Posts: 30
hey,
again i don`t know if this is the right forum, but here we go.
my goal is to have a servlet that read data from a mysql databank and display it with xml.
i have a java application wich transform the mysql data with dom parser and write them to an xslt file.
when i run the app from a konsole everything is fine, but i don`t know how to display the data in a browser.
any help is welcome
thanx bernd
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by bernd pier:
i have a java application wich transform the mysql data with dom parser and write them to an xslt file.
thanx bernd

Hi,
May I know why its writing to an xslt file instead of xml file.
May be you can try this forum http://www.coderanch.com/forums/f-31/XML for questions related xml,xslt etc.,


Spritle Software Blogs
Byron Estes
Ranch Hand

Joined: Feb 21, 2002
Posts: 313
The default content type for a response coming from an HttpServelet is "text/html". What you'll need to do to display xml in the browser is somethig like the following...
..more code..
response.setContentType("text/xml");
java.io.PrintWriter out = response.getWriter();
out.println(xmlDumpedToAString);
Note: The println() takes a String parameter. You'll probably need to have some code to transform your object (...I'm assuming DOM) into a string representation.
Hope this helps,


Byron Estes<br />Sun Certified Enterprise Architect<br />Senior Consulant<br />Blackwell Consulting Services<br />Chicago, IL<br /><a href="http://www.bcsinc.com" target="_blank" rel="nofollow">www.bcsinc.com</a>
bernd pier
Ranch Hand

Joined: Jun 21, 2002
Posts: 30
thanx for your help,
excuse this late reply, but i`m just having my holiday`s.

of course, i want to put the datas into a DOM object and then into a xml file.a tutorial or example to show me how could be helpfull.
so long
bernd
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet and xslt