Geoff Soutter wrote:
>
> Hi there,
>
> I have a servlet that caches all it's output in a buffer so that I can
> control what gets sent to the browser and when. Now, I want to include the
> generated output of a third party servlet in one of my servlet responses.
>
> I looked at using RequestDispatcher.include(). It lets me call another
> servlet, but it doesn't let me cache the output of that servlet! Ouch!
>
> It looks as if I could do what I wanted if I implemented my own "dummy"
> ServletResponse which just cached the included servlet's into a buffer and
> the extacted it once the include had finished. However, I thought maybe the
> servlet engine may try and cast the ServletResponse back to it's own type
> when you pass it to include()...
>
> Does anyone know if this is "allowed" by the API, or perhaps there is a more
> obvious way that I am missing. I had a quick look at the spec and it didn't
> seem to mention it...
The JSP 1.0 Appendix B has a number of clarifications of the Servlet 2.1
API. It says this about request and response in RD.include/forward:
"A RequestDispatcher object can be used to perform include() and forward()
operations. These methods should only be invoked while processing a service()
request, and the request and a response objects MUST be the request and
response objects that are being processed through the service() method
invocation."
This clarification will most likely be included in the Servlet 2.2 spec,
so your approach will not work.
What you can do is using a URLConnection to get the outout from the third
party servlet and add it to your buffer.
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html