"cristi" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hello all
>
> I have a web application where I need to use in a second request the
> HttpServletRequest object sent to the same servelet in the first
> request.
>
> Here is what my servlet looks like :
>
> public void doGet( HttpServletRequest request, HttpServletResponse 
> response )
> {
>     /*
>     some code here detecting if this request
>     is the first one. This code initializes
>     isFirstRequest
>     */
>
>    if( isFirstRequest )
>    {
> session.setAttribute( "FIRST_REQUEST_OBJECT", request );
> request.getRequestDispatcher("somepage.jsp").forward(request, response);
>    }
>    else
>    {
> HttpServletRequest oreq = 
> (HttpServletRequest)session.getAttribute("FIRST_REQUEST_OBJECT");
> request.getRequestDispatcher("somepage.jsp").forward(oreq, response);
>    }
>
> }
>
> It seems that it is not safe to do so. What can I do to handle this 
> situation ?
>

According to the spec (section 8.2 for those of you following along at home 
:), the only safe HttpServletRequest to pass is the one that was passed into 
the Servlet, or a child of HttpServletRequestWrapper that wraps the one that 
was passed into the Servlet.

Tomcat happens to be very lenient in inforcing this restriction among 
Servlet-Containers out there.  The other-guys would probably throw an 
exception straight away for attempting something like the above.

> Thx.
> Cristi 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to