Servlet Example

The following example demonstrates the process of creating a simple servlet to perform an XML transformation that ultimately produces an HTML page, which is returned to the client browser. The role of the servlet in this operation is that of a controller object; the real work to access the database, create XML, and transform the XML to HTML is being done by the objects the servlet has created. The result is a servlet focused on the task of creating a presentation component and delivering it to the browser that has generated the request.

The servlet retrieves the query to execute from an initialization parameter in the servlet web.xml file (shown in the next code example). The transformation is performed using an XSLT script located ...

Get J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.