You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Clint Popetz <cl...@cpopetz.com> on 2006/08/03 21:57:56 UTC

Nested request in

Hi,

Under jsp 2.0 (jstl 1.2), is there any way to force <c:import>, or
perhaps the requestDispatcher.include() in particular, to set up a new
request scope when the resource is in the same context?  I'm using
<c:import> to do sort of a lightweight tiles replacement for a page
menu, and the imported servlet execution is stomping on some of my
request variables that my controller sets up for the view.  So, for
example:

Controller does request.setAttribute("someModel",x);

jsp does <c:import>

imported controller does request.setAttribute("someModel",y)

jsp for imported controller is happy (finds y)

import returns

jspi for original controller finds y instead of x under "someModel",
and bad things happen.

I'd really like the imported servlet to see a wrapped/cloned request,
in which it muck with anything, but that the original request context
is untouched.  I don't know if this prohibited by the jsp spec though.

Thanks,
-Clint

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Nested request in

Posted by Clint Popetz <cl...@cpopetz.com>.
On 8/3/06, Kris Schneider <kr...@dotech.com> wrote:
> For the same context, <c:import> is the equivalent of
> RequestDispatcher.include, so the request scope is essentially shared. Is
> it possible for you to refactor either the included servlet or your
> controller to avoid the stomping?

Not easily.  But I just checked around, and the Spring MVC controller
had a bit of code to check for the presence of
javax.servlet.include.request_uri in the request and save away a copy
of the request attributes, restoring them after view rendering, so
that's what I'll do.

-Clint

> Clint Popetz wrote:
> > Hi,
> >
> > Under jsp 2.0 (jstl 1.2), is there any way to force <c:import>, or
> > perhaps the requestDispatcher.include() in particular, to set up a new
> > request scope when the resource is in the same context?  I'm using
> > <c:import> to do sort of a lightweight tiles replacement for a page
> > menu, and the imported servlet execution is stomping on some of my
> > request variables that my controller sets up for the view.  So, for
> > example:
> >
> > Controller does request.setAttribute("someModel",x);
> >
> > jsp does <c:import>
> >
> > imported controller does request.setAttribute("someModel",y)
> >
> > jsp for imported controller is happy (finds y)
> >
> > import returns
> >
> > jspi for original controller finds y instead of x under "someModel",
> > and bad things happen.
> >
> > I'd really like the imported servlet to see a wrapped/cloned request,
> > in which it muck with anything, but that the original request context
> > is untouched.  I don't know if this prohibited by the jsp spec though.
> >
> > Thanks,
> > -Clint
>
> --
> Kris Schneider <ma...@dotech.com>
> D.O.Tech       <http://www.dotech.com/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Nested request in

Posted by Kris Schneider <kr...@dotech.com>.
For the same context, <c:import> is the equivalent of 
RequestDispatcher.include, so the request scope is essentially shared. Is 
it possible for you to refactor either the included servlet or your 
controller to avoid the stomping?

Clint Popetz wrote:
> Hi,
> 
> Under jsp 2.0 (jstl 1.2), is there any way to force <c:import>, or
> perhaps the requestDispatcher.include() in particular, to set up a new
> request scope when the resource is in the same context?  I'm using
> <c:import> to do sort of a lightweight tiles replacement for a page
> menu, and the imported servlet execution is stomping on some of my
> request variables that my controller sets up for the view.  So, for
> example:
> 
> Controller does request.setAttribute("someModel",x);
> 
> jsp does <c:import>
> 
> imported controller does request.setAttribute("someModel",y)
> 
> jsp for imported controller is happy (finds y)
> 
> import returns
> 
> jspi for original controller finds y instead of x under "someModel",
> and bad things happen.
> 
> I'd really like the imported servlet to see a wrapped/cloned request,
> in which it muck with anything, but that the original request context
> is untouched.  I don't know if this prohibited by the jsp spec though.
> 
> Thanks,
> -Clint

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org