Leong Mun Wai wrote:

> Hi,
>
> I'm trying to implement an XSLT filter in Tomcat 4.0 for a JSP with XML
> content. Any hints on how this can be done?
>

I assume that what you want to do is apply an XSLT transformation on the
*output* of a JSP page (which generates XML), right?  If so, the following
general strategy is what you need:

* You will need to create a wrapper class for the response
  that is handed on to the remainder of the filter chain.  See
  below for more info on what this wrapper must do.

* Implement your Filter's doFilter() method something like this:

    public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {

        HttpServletResponse myResponse =
          new MyServletWrapper(response);
        chain.doFilter(request, myResponse);

    }

The functionality you implement inside the wrapper will need to override the
response.getWriter() method, and copy the output from the ultimate JSP page into
a buffer of some sort.  When the JSP page is completed (i.e. when the "writer"
that you return is flushed and closed, apply the appropriate XSLT
transformation, and then write this output to the "real" response object that
you are wrapping.

On my TODO list is to create some examples of stuff like this, but I haven't
gotten that far yet :-(.

>
> thanks
> Mun Wai
>

Craig McClanahan



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to