Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet and xslt

 
bernd pier
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.,
 
Byron Estes
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
bernd pier
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic