struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken McWilliams <ken.mcwilli...@gmail.com>
Subject Re: S2: How to tell if a response has been committed from an interceptor?
Date Wed, 06 Jan 2016 19:51:10 GMT
Well you go down the chain create the result and then back up the chain.
So when going back up the response should already be committed.

see: https://struts.apache.org/docs/writing-interceptors.html

//modified code from above link to clarify
    public String intercept(ActionInvocation invocation) throws Exception {
       //do stuff before response, going down the chain
       String result = invocation.invoke();
       //do stuff after response, going back up the chain, can't do what
you seem to be trying to do here...
       return result;
    }

That aside, "Cannot create a session" isn't a good message because you
shouldn't be trying to create a session at all! It's part of the containers
responsibility to do that. You just ask for it. So the real cause of the
issue might be something else.

On Wed, Jan 6, 2016 at 11:41 AM, Greg Lindholm <greg.lindholm@gmail.com>
wrote:

> Inside an Interceptor I'm getting an exception
>
> java.lang.IllegalStateException: Cannot create a session after the response
> has been committed
> I have access to the ActionInvocation as this is passed into doIntercept()
> public String doIntercept(ActionInvocation invocation) throws Exception
>
> My question is: from the ActionInvocation how do I find out if the response
> has been committed?
>
> Can I get the HttpServletResponse? So I can call response.isCommitted() ?
>
> How?
>
> Thanks,
> Greg
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message