• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servlet and xslt

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 https://coderanch.com/forums/f-31/XML for questions related xml,xslt etc.,
 
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic