struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Lindholm <greg.lindh...@gmail.com>
Subject S2 how to determine if a session exists from an Interceptor
Date Thu, 06 Feb 2014 14:14:44 GMT
I have an Interceptor that wants to put something in the session after the
action has executed.

But if the session doesn't already exist I get an exception:

java.lang.IllegalStateException: Cannot create a session after the response
has been committed
How can I determine if the session already exists from within an
Interceptor?

 public String doIntercept(ActionInvocation invocation) throws Exception
 {
   String result = invocation.invoke();
   Map<String, Object> session =
invocation.getInvocationContext().getSession();
   session.put(key, value); // throws exception if session doesn't exist
   return result;
 }

Thanks
Greg

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