Building an XML Servlet Handler

In this chapter, we will build a generic servlet to intercept all XML requests within the xmlbook Web application.

The servlet will use the following business rules:

  • It returns a file-not-found error when the requested XML file doesn't exist.

  • The XML file is parsed to determine whether it declares a stylesheet. If a stylesheet has been declared, it's to be applied against the XML file. The results are sent back to the user instead of the original XML file.

  • To speed access, the results of the parsing of the XML file will be cached to memory space. The cache will have one of three values: a filename when the stylesheet is found, false when no stylesheet has been found, or null if the parsing hasn't been performed. ...

Get JSP™ and XML Integrating XML and Web Services in Your JSP™ Application 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.