You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Becky Norum <bn...@coe.neu.edu> on 2003/03/28 02:24:51 UTC
Re: java.lang.IllegalStateException: Cannot forward after response
hasbeen committed
Thanks for all the reponses.
It's actually a piece of code within a custom tag, so the scope probably
isn't an issue.
The tag checks to see if the user is a member of the group s/he is
trying to access. So, probably, some HTML response is output before the
tag is called. (because a header file is included via jsp:include), but
the tag is called at the top of the JSP page.
So I hear y'all saying to call the tag before writing HTML, but that
would require some significant rearranging. Plus, sometimes it works
just fine - actually, when I call the page directly it works, but when I
do a forward it doesn't.
So do I need to call the page directly rather than forward?
Thanks so much,
Becky
On Thu, 2003-03-27 at 19:55, Alexandre Jaquet wrote:
> what's your scope definition ? (in the struts-conf)
>
> --
> Alexandre Jaquet
>
> ----- Original Message -----
> From: "Becky Norum" <bn...@coe.neu.edu>
> To: <st...@jakarta.apache.org>
> Sent: Friday, March 28, 2003 1:47 AM
> Subject: java.lang.IllegalStateException: Cannot forward after response
> hasbeen committed
>
>
> >
> > Does anyone know what the following exception means?
> >
> > javax.servlet.jsp.JspException: java.lang.IllegalStateException: Cannot
> > forward after response has been committed
> >
> > It seemed to be related to something in this area of code:
> >
> > // ModuleConfig config = (ModuleConfig)
> > pageContext.getRequest()
> > // .getAttribute(org.apache.struts.Globals.MODULE_KEY);
> > // try {
> > // pageContext.forward(config.getPrefix() + page);
> > // } catch (Exception e) {
> > //
> >
> > Thanks!
> >
> > Becky
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
--
Becky Norum
Database Administrator
Center for Subsurface Sensing and Imaging Systems (CenSSIS)
Northeastern University
http://www.censsis.neu.edu
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: java.lang.IllegalStateException: Cannot forward after response
hasbeen committed
Posted by Scott Barr <sc...@exergonic.com.au>.
What you're doing sounds like a really good candidate for either
a) Filters and Container Managed Security
The CMS can manage your course level security (eg. are you logged on),
and the Filter can manage the finer levels (can the user execute this
action?)
or
b) the security filter project (haven't used this myself)
It really is well worth the initial effort.
Scott
www.exerogic.com.au
On Fri, 2003-03-28 at 11:54, Becky Norum wrote:
> Thanks for all the reponses.
>
> It's actually a piece of code within a custom tag, so the scope probably
> isn't an issue.
>
> The tag checks to see if the user is a member of the group s/he is
> trying to access. So, probably, some HTML response is output before the
> tag is called. (because a header file is included via jsp:include), but
> the tag is called at the top of the JSP page.
>
> So I hear y'all saying to call the tag before writing HTML, but that
> would require some significant rearranging. Plus, sometimes it works
> just fine - actually, when I call the page directly it works, but when I
> do a forward it doesn't.
>
> So do I need to call the page directly rather than forward?
>
> Thanks so much,
>
> Becky
>
>
>
> On Thu, 2003-03-27 at 19:55, Alexandre Jaquet wrote:
> > what's your scope definition ? (in the struts-conf)
> >
> > --
> > Alexandre Jaquet
> >
> > ----- Original Message -----
> > From: "Becky Norum" <bn...@coe.neu.edu>
> > To: <st...@jakarta.apache.org>
> > Sent: Friday, March 28, 2003 1:47 AM
> > Subject: java.lang.IllegalStateException: Cannot forward after response
> > hasbeen committed
> >
> >
> > >
> > > Does anyone know what the following exception means?
> > >
> > > javax.servlet.jsp.JspException: java.lang.IllegalStateException: Cannot
> > > forward after response has been committed
> > >
> > > It seemed to be related to something in this area of code:
> > >
> > > // ModuleConfig config = (ModuleConfig)
> > > pageContext.getRequest()
> > > // .getAttribute(org.apache.struts.Globals.MODULE_KEY);
> > > // try {
> > > // pageContext.forward(config.getPrefix() + page);
> > > // } catch (Exception e) {
> > > //
> > >
> > > Thanks!
> > >
> > > Becky
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: java.lang.IllegalStateException: Cannot forward after response
hasbeen committed
Posted by Becky Norum <bn...@coe.neu.edu>.
On Thu, 2003-03-27 at 22:38, Craig R. McClanahan wrote:
> There is a fundamental rule in the servlet API that things included with a
> RequestDispatcher.include() call (which is what <jsp:include> does under
> the covers) cannot modify the HTTP headers of the response. Since you
> need to modify those headers to do a redirect, that's going to be a
> problem for your use case.
>
> How about doing the include with <%@ include file="..." %> instead? This
> causes the included logic to become part of the calling page (sort of like
> a #include directive in C/C++), so it can do what you describe (as long as
> it's in the page near the top so you haven't overflowed the output buffer
> yet). As an extra added bonus, it's a little less overhead to do it this
> way, too :-).
>
> Craig
*sheepish look*
I doublechecked my pages and turns out I am using <%@ include file="header.jsp" %>.
Thanks for the info - I didn't realise the OH issue or the underlying include
workings.
I can work around this issue - but I'm just getting curious/concerned that I'm
doing something fundamentally wrong that will bring up issues later..
re: the output buffer - does that include the header file or just this
particular JSP? The header file can get big.. but again, it works fine before
I follow a certain sequence of actions and return to the first page..
Thanks again,
Becky
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: java.lang.IllegalStateException: Cannot forward after response
hasbeen committed
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Thu, 27 Mar 2003, Becky Norum wrote:
> Date: 27 Mar 2003 20:24:51 -0500
> From: Becky Norum <bn...@coe.neu.edu>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: java.lang.IllegalStateException: Cannot forward after
> response hasbeen committed
>
> Thanks for all the reponses.
>
> It's actually a piece of code within a custom tag, so the scope probably
> isn't an issue.
>
> The tag checks to see if the user is a member of the group s/he is
> trying to access. So, probably, some HTML response is output before the
> tag is called. (because a header file is included via jsp:include), but
> the tag is called at the top of the JSP page.
>
> So I hear y'all saying to call the tag before writing HTML, but that
> would require some significant rearranging. Plus, sometimes it works
> just fine - actually, when I call the page directly it works, but when I
> do a forward it doesn't.
>
> So do I need to call the page directly rather than forward?
>
> Thanks so much,
>
There is a fundamental rule in the servlet API that things included with a
RequestDispatcher.include() call (which is what <jsp:include> does under
the covers) cannot modify the HTTP headers of the response. Since you
need to modify those headers to do a redirect, that's going to be a
problem for your use case.
How about doing the include with <%@ include file="..." %> instead? This
causes the included logic to become part of the calling page (sort of like
a #include directive in C/C++), so it can do what you describe (as long as
it's in the page near the top so you haven't overflowed the output buffer
yet). As an extra added bonus, it's a little less overhead to do it this
way, too :-).
> Becky
>
Craig
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org