Applying XSL Templates from a Servlet

XSL becomes a powerful tool when you combine it with the power of servlets and Java Server Pages. You can create XML documents within your server-side Java code and use a style sheet to format the XML into something the client understands.

To apply an XSL style sheet to an XML document from a servlet or JSP, you must have an XSL processor installed in your servlet engine's classpath. The Apache Group's Xalan XSL processor (http://xml.apache.org) is an excellent XSL processor and works well in a servlet environment. IBM's LotusXSL processor, available from http://www.alphaworks.ibm.com, is also good.

Listing 23.5 shows a servlet that takes an XML document or a filename from the request object along with a ...

Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.