tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nacho <>
Subject RE: Content Type and RequestDispatcher
Date Mon, 19 Jun 2000 12:41:12 GMT
Hola ALEX:
> The thing is that I have set the headers >before< i use the
> RequestDispatcher.forward() method.  I'm still not sure why this is
> happening.  I'll give your suggestion a try...

After a carefully reading of the servlet spec ( which i'm confusing with
the Jsp spec in the point about include & forward ) this what it says
about including and forward:

8<------------------------------------------ Include Spec reference
8.3 Include
The include method of the RequestDispatcher interface may be called at
any time. The
target servlet has access to all aspects of the request object, but can
only write information to the
ServletOutputStream or Writer of the response object as well as the
ability to commit a
response by either writing content past the end of the response buffer
or explicitly calling the
flush method of the ServletResponse interface. The included servlet
cannot set headers or
call any method that affects the headers of the response. Any attempt to
do so should be ignored.

8<------------------------------------------Forward spec reference
8.4 Forward
The forward method of the RequestDispatcher interface may only be called
by the calling
servlet if no output has been committed to the client. If output exists
in the response buffer that has
not been committed, it must be reset (clearing the buffer) before the
target servlet's service
method is called. If the response has been committed, an
IllegalStateException must be
The path elements of the request object exposed to the target servlet
must reflect the path used to
obtain the RequestDispatcher. The only exception to this is if the
was obtained via the getNamedDispatcher method. In this case, the path
elements of the
request object reflect those of the original request.
Before the forward method of the RequestDispatcher interface returns,
the response must
be committed and closed by the servlet container.

as you can read you only can do a forward if there aren't anything
commited in the response...and if ther is something in the response it's
reseted before forwarding....

Hope this clarifies some of this discusion, but i'm really confused (
Craig are you there :-) ) .

Saludos ,
Ignacio J. Ortega

View raw message