I suggest you first master the database to xml step OUTSIDE the servlet environment. Once you can write your xml to a Writer or a String, then you can think about doing it in a servlet. A google search for "java xml tutorial" should lead you to a basic tutorial.
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop