tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: Accessing the ServletOutputStream via RequestInterceptors
Date Fri, 08 Dec 2000 17:24:33 GMT
Alex Garrett wrote:

> Hello, all,
>
> I'm trying to find a way to modify the content of a servlet after the servlet
> has completed all of its processing but before it actually gets sent to the
> browser (obviously).
>
> Here's the context. Our web site stores all its content in XML. All servlets,
> jsps, and static files return this XML and what I'd like to do is turn it all
> into HTML on the fly without each servlet, etc., having to worry about doing the
> transformation itself. My naive first idea was to set the content-type to
> text/cml (CML is the name of the markup language) and have a
> CmlToHtmlInterceptor (extends BaseInterceptor) with a afterBody method that
> would check the content-type and if it's text/cml, retrieve the contents (maybe
> from a ByteBuffer), run it through an XSL engine, turning it into HTML and
> sending that back after changing the appropriate headers (content-type,
> content-length, etc.).
>

I've got two suggestions for you to consider that would make life a lot easier:

* Look at Tomcat 4.0, which implements the new Servlet 2.3 Spec.
  In particular, the 2.3 API supports the concept of a Filter that can
  be used to pre-process and post-process requests.  One of the
  primary use cases that motivated this design was performing things
  like XSLT transformations after the fact.  And (as an added bonus),
  filters are portable -- not Tomcat specific like interceptors or Valves
  (the Tomcat 4.0 equivalent).

* Consider using the Cocoon publishing framework (which you can get
  at <http://xml.apache.org/cocoon>).  It is designed to deal with sites
  that are based on XML content and corresponding transformations.

Under any circumstance, you should upgrade to at least Tomcat 3.2 -- there have
been
a very large number of bug fixes, as well as performance improvements.

Craig McClanahan

Mime
View raw message