Hi all,

I'm trying to get a clarification on an ambiguity in the Servlet
specification 2.3. Consider a setup like this:

 JSP
 |--------------------------------------------------|
 |                                                  | 
 |--------------------------------------------------|
     /-\
      |                       |
      | Dispatched Request    |  ResponseWrapper     
        |                       |
                             \_/
  MVC Controllerservlet
 |--------------------------------------------------|
 |                                                  | 
 |--------------------------------------------------|
     /-\
      |                       |
      | Initial Request       |  ResponseWrapper      
        |                       |
                             \_/
  Filter 
 |--------------------------------------------------|
 |                                                  |  
 |--------------------------------------------------|
     /-\
      |                       |
      | Initial Request       |  Underlying Response     
        |                       |
                             \_/
  Browser 
 |--------------------------------------------------|
 |                                                  | 
 |--------------------------------------------------|

A client browser issues a request to the Servlet container. The request goes
to a Controllerservlet which dispatches to a JSP. 

Additionally, a filterchain is activated. The configured filter is supposed
to manipulate the response, e.g. cache, compress, modify. Therefore it hands
out a HttpServletResponseWrapper with a derived ServletOutputStream class
which writes the contents of the JSP to e.g. a ByteArrayOutputStream. The
filter can then take the results of the request, manipulate them and write
them to the original response.

This is a likely approach for most of the "Examples of Filtering Components"
(SRV.6.1.1). When trying to implement a filter like this I recognized, that
Servlet containers differ in their interpretation of "The forward Methid"
(SRV.8.4). The statement "Before the forward method of the RequestDispatcher
interface returns, the response content must be sent and committed, and
closed by the servlet container" is applied to the ServletResponseWrapper by
some implementations (e.g. Resin), to the underlying original response by
others (Tomcat, WebLogic).  

In plain words that means: Once a dispatch is issued in Tomcat and WebLogic,
e.g. when using Struts or any other MVC approach, one can forget about
filters as the container commits the underlying response. If a filter is
activated, the user will get a "blank browser" as the content went to the
ServletResponseWrapper, the commit to the (empty) original response. In
Resin it works as I would have expected, but I'm not sure which
interpretation is correct.

I would be glad for opinions on this, clarifications on SRV.8.4 and the
intent behind this. As Tomcat is the reference implementation I guess that
other containers are likely to follow the interpretation made here. Please
let me know if you find my explanation incomplete or unclear. If someone
would like to have a simple reproducer for this behaviour let me know as
well, I have one prepared already.

Best Regards,

Daniel



<<<<<<<<<<<<<<<<<<<<<<<<<<<
sitewaerts GmbH
Hebelstraße 15
D-76133 Karlsruhe

Tel: +49 (721) 920 918 0
Fax: +49 (721) 920 918 29
http://www.sitewaerts.de
>>>>>>>>>>>>>>>>>>>>>>>>>>>



--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to