Are you sure you need to do it like this? You can use OGNL expressions in
your S2 configuration file to do things like set a URL to redirect to etc.

Dave

--- Filipe David Manana <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I am trying to use an action that returns directly instances of the
> Result class, due to the nature of my application where the result is
> dynamically decided by some logic.
> 
> My action class method is:
> 
>   public Result doLogin() throws Exception
>    {
>       // etc...
>       if ( !validUser )
>       {
>          addActionError("Authentication failed. Invalid
> username/password provided.");
>          return new ServletDispatcherResult("/jsp/login.jsp");
>       }
> 
>       // valid user
>       session.put("user", userName);
> 
>       ServletActionRedirectResult result =
> (ServletActionRedirectResult) session.get("_prev_uri_");
> 
>       if ( result == null )
>       {
>          result = new ServletActionRedirectResult("/home", "home",
> "execute");
>       }
> 
>       return result;
>   }
> 
>   My struts.xml:
> 
>   <action name="doLogin" class="actions.LoginAction" method="doLogin">
>   </action>
> 
>   After executing the action's method I always get a
> NullPointerException from ServletActionRedirectResult :S
> 
> exception
> 
> javax.servlet.ServletException: java.lang.NullPointerException
> 
> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
> 
>
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
> 
>
org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)
> 
> root cause
> 
> java.lang.NullPointerException
> 
>
org.apache.struts2.dispatcher.ServletActionRedirectResult.execute(ServletActionRedirectResult.java:184)
> 
>
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
> 
>
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
> 
>
actions.CaptureLastURIRequestedInterceptor.intercept(CaptureLastURIRequestedInterceptor.java:48)
> 
>
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
> 
>
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
> 
>
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
> 
>
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
> 
>
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
> 
> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
> 
>
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
> 
>
org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)
> 
> Am I missing something?
> 
> cheers
> 
> -- 
> Filipe David Manana,
> [EMAIL PROTECTED]
> 
> Obvious facts are like secrets to those not trained to see them.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to