tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: BugRat Report #57 has been filed.
Date Sun, 03 Sep 2000 23:11:26 GMT
James Cook wrote:

> Craig,
> Do we need to do anything special to take advatange of this in Tomcat 4.0,
> or do we simple pass our wrappered request and response objects in the
> RequestDispatcher.include and RequestDispatcher.forward methods?

The only requirement is that your wrapper classes must be a subclass of the
request and response wrapper classes (usually
javax.servlet.http.HttpServletRequestWrapper or
javax.servlethttp.HttpServletResponseWrapper).  These classes take as an
argument the request or response you are wrapping, and by default delegate
everything to the wrapped class (so you only have to override the methods for
which you want to change the behavior).

So, to wrap the output you might write a class like this:

    public class MyWrappedResponse extends HttpServletResponseWrapper {

        public MyWrappedResponse(HttpServletResponse response) {

        ... override just the methods you want to change ...


and, in your servlet's doGet() or doPost() method you would:

    MyWrappedResponse myResponse = new MyWrappedResponse(response);
    RequestDispatcher rd =
    rd.include(request, myResponse);

Tomcat 4.0 currently supports this behavior (as well as the new servlet filter
stuff), so feel free to give it a try and report any problems.

> jim

Craig McClanahan

See you at ApacheCon Europe <>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat

View raw message