| [ directory ] |
Throughout the book both Servlets and JSPs have been treated as complementary technologies that you should use when building Web Applications. This is true, but in some cases it may be desirable to use another styling language besides JSP. For instance, the standardized XML styling mechanism is the eXtensible Stylesheet Language Transformations (XSLTs). XSLT is popularly used with many XML projects including Java XML projects. Should you be working on a project with a group of XML/XSLT developers, it makes little sense to completely drop XSLT in favor of learning JSP. The better solution would be to stick with XML/XSLT and build a Filter takes care of the transformations.
Such a Filter is not difficult to build and it could easily operate by intercepting requests to all resources of a certain extensionsay, *.xml. Instead of showing resources ending in XML, the Filter could automatically apply an XSLT stylesheet and return the transformed content. If you are familiar with XSLT, the Filter could additionally do a check to see if the client can do transformations (most current browsers do). If that is the case, then the Filter could simply give the raw XML and XSLT to a client and avoid doing a server-side transformation altogether.
A JSP Replacing Filter will not be demonstrated by this book. It goes against the primary theme, and the topic itself deserves discussing many more unrelated topics for completeness. The important point to take away from this section is that Filters are part of the Servlet specification and are not tied to JSP. Should it be desired to use a JSP replacing technology for style, Filters are an ideal choice for the Web Application implementation.
| [ directory ] |