Servlets and XML: Made for Each Other
By Doug Tidwell2005-05-18
Our first sample servlet
To get things started, we'll write a 10-line servlet that generates an XML document. As we build our XML-aware servlets, we'll follow three steps:
- Set the content type to
text/xml. - Create the XML document.
- Write the XML document back to the client.
In most of our servlets, most of our effort will be in the second step. We might create an XML document from a database query, we might generate it based on an HTTP parameter passed to us from the client, or we might use some other kind of data retrieval or generation method. In our examples here, we'll focus on HTTP parameters and database queries.
Tutorial Pages:
» Our first sample servlet
» A very basic servlet
» Generating XML fragments
» Interfacing with a database
» Summary
» Resources
First published by IBM DeveloperWorks
