Yes I need. Because in the S2 configuration file I have to specify all the parameters of the query string one by one. In my app, I don't know the name and number of these parameters. So I am building a Servlet Redirect Action Result in an interceptor like this:
public String intercept(ActionInvocation invocation) throws Exception { ActionContext context = invocation.getInvocationContext(); Map session = context.getSession(); String action = invocation.getProxy().getActionName(); String namespace = invocation.getProxy().getNamespace(); if ( ( action.equals("login") || action.equals("doLogin") ) && namespace.equals("/") ) return invocation.invoke(); Object user = session.get("user"); if ( user == null ) { if ( session.get("_prev_uri_") == null ) { String method = invocation.getProxy().getMethod(); ServletActionRedirectResult result = new ServletActionRedirectResult(namespace, action, method); Map params = context.getParameters(); Iterator it = params.entrySet().iterator(); Map.Entry entry = null; while ( it.hasNext() ) { entry = (Map.Entry) it.next(); result.addParameter((String) entry.getKey(), entry.getValue()); } session.put("_prev_uri_", result); } // etc... I tried using a "redirect" type result in the xml config, and appending the query string to the url, but struts2 ignores it. The query string was obtained with the HttpServletRequest class. (I was logging it and it was correct). Any suggestion? On Feb 12, 2008 1:54 PM, Dave Newton <[EMAIL PROTECTED]> wrote: > 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] > > > > > > -- 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]