struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Musachy Barroso" <musa...@gmail.com>
Subject Re: S2 Losing Session in interceptor
Date Mon, 05 May 2008 15:39:47 GMT
If the session is expired, adding the messages to it won't help much.
Why don't you forward to the login page, instead of redirecting, and
put those messages in the request context?

musachy

On Mon, May 5, 2008 at 11:09 AM, JRD <danger_jon@hotmail.com> wrote:
>
>  Hey there, I have built an interceptor to store and retrieve ActionErrors
>  using the session for redirect-action results.  The weird thing is I seem to
>  lose the values the first time it is run through.
>
>  private static final String KEY="org.etc...";
>
>  public String intercept(ActionInvocation actionInvocation) throws Exception
>  {
>     ActionContext actionContext = actionInvocation.getInvocationContext();
>     Map session = actionContext.getSession();
>
>     if (session.containsKey(KEY)) {
>         Collection actionErrors = (Collection) session.remove(KEY);
>         if (actionInvocation.getAction() instanceof ValidationAware) {
>             ((ValidationAware)
>  actionInvocation.getAction()).setActionErrors(actionErrors);
>         }
>     }
>
>     String result = actionInvocation.invoke();
>
>     if (actionInvocation.getResult() instanceof ServletActionRedirectResult
>  && actionInvocation.getAction() instanceof ValidationAware) {
>         if (action.hasActionErrors()) {
>             session.put(KEY, action.getActionErrors());
>         }
>     }
>
>     return result;
>  }
>
>  So say I have an invalid session (or timeout).  I catch the exception and
>  then chain to an action that will build the error message and redirect back
>  to the login page.  When I step through the interceptor it will be fired
>  twice.  The first time it is being fired by the action that built the error
>  message.  Everything looks ok and it adds the action errors to the session.
>  The second time is for the action that displays the login page but when that
>  interceptor is fired, the session that is returned is empty.
>
>  This only happens the first time I do this, if I continue to throw
>  exceptions everything works as I had expected.
>
>  All help is appreciated,
>  Jonathan
>  --
>  View this message in context: http://www.nabble.com/S2-Losing-Session-in-interceptor-tp17063809p17063809.html
>  Sent from the Struts - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>  For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Mime
View raw message