cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Engelhart <>
Subject Re: Question about RequestDispatcher
Date Mon, 28 Aug 2000 12:27:27 GMT
<italic><fontfamily><param>Helvetica</param>Hello Michael,</fontfamily></italic><fontfamily><param>Helvetica</param><color><param>0000,0000,0000</param>

<italic></italic></color><italic>do I understand it correctly that
in this case the RequestDispatcher</italic><color><param>0000,0000,0000</param>

<italic></italic></color><italic>simply takes the request he got from
the client and forwards it to</italic><color><param>0000,0000,0000</param>

<italic></italic></color><italic>cocoon? If yes, then how does the
client get the cocoon-generated</italic><color><param>0000,0000,0000</param>


<italic></italic></color><italic>1) cocoon sends it directly to the

<italic></italic></color><italic>2) cocoon sends it back to the servlet
that used the RequestDispatcher</italic><color><param>0000,0000,0000</param>

<italic></italic></color><italic>As far as I understand from the RequestDispatcher
documentation case 2)</italic><color><param>0000,0000,0000</param>

<italic></italic></color><italic>is applicable. So, how would I read
the response in my servlet? Do I</italic><color><param>0000,0000,0000</param>

<italic></italic></color><italic>just open an input stream?</italic><color><param>0000,0000,0000</param>

<italic></italic></color><italic>thanks for any pointers,</italic><color><param>0000,0000,0000</param>


Hi Ulrich,

Yes, you are correct.  The RequestDispatcher forwards both the request and the response to
the new URI (which can be anything really, a servlet, xsp, jsp, plain html, etc) but it does
not return it back to the servlet for processing.  the request/response pair is forwarded
and the servlet continues processing although you should generally call return (see below).

The client gets the cocoon-generated result directly from the XSP.  You actually should have
you code do something like this:

RequestDispatcher rd = request.getRequestDispatcher("/xsp/myxsp.xml");

rd.forward(request, response);


if you don't call "return" the rest of your code get's processed even though it doesn't do
anything visible like generate output but instead eatsup CPU cycles and resources potentially.
 Also you can not have already opened an output stream with the  servlet or it will throw
an exception.

I haven't done what you're trying to do with the response object (I've only used a fowarded
response object to do a redirect) but since the request and response are forwarded to the
XSP, you should be able to do everything you have done using a servlet from within an XSP.


View raw message