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.
Bill