You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Reynolds <ji...@gmail.com> on 2006/10/30 19:46:11 UTC

Request Processor Struts2

Hello,

Newbie with WW, so hopefully this is not a silly question. In Struts
1.x I used to extend the request processor, and check for a user with
a certain object in the session. If it did not exist, I would put it
in, and at the same time, send to the front login if it did not exist.
This was how I handled my session management.

Now I am getting underway with Struts2, and noticed that the
RequestProcessor no longer exists.

So my question is: How do I handle this type of setup in Struts 2? I
noticed that there is a Interceptor that may be for this task, but I
am unsure. Do I extend the interceptor and handle my logic there, or
is there a simpler way.

Any examples, links would be appreciated.

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


RE: Request Processor Struts2

Posted by Juan Espinosa <pc...@adinet.com.uy>.
In the mailreader there is an example. you can do it with an interceptor


package mailreader2;

import com.opensymphony.xwork2.interceptor.Interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.Action;
import java.util.Map;
import org.apache.struts.apps.mailreader.dao.User;

public class AuthenticationInterceptor implements Interceptor  {

    public void destroy () {}

    public void init() {}

    public String intercept(ActionInvocation actionInvocation) throws
Exception {

        Map session = actionInvocation.getInvocationContext().getSession();

        User user = (User) session.get(Constants.USER_KEY);

        boolean isAuthenticated = (null!=user) &&
(null!=user.getDatabase());

        if (!isAuthenticated) {
            return Action.LOGIN;            
        }
        else {
            return actionInvocation.invoke();
        }

    }
} 

-----Mensaje original-----
De: Jim Reynolds [mailto:jim.jreynold@gmail.com] 
Enviado el: Lunes, 30 de Octubre de 2006 03:46 p.m.
Para: user@struts.apache.org
Asunto: Request Processor Struts2

Hello,

Newbie with WW, so hopefully this is not a silly question. In Struts 1.x I
used to extend the request processor, and check for a user with a certain
object in the session. If it did not exist, I would put it in, and at the
same time, send to the front login if it did not exist.
This was how I handled my session management.

Now I am getting underway with Struts2, and noticed that the
RequestProcessor no longer exists.

So my question is: How do I handle this type of setup in Struts 2? I noticed
that there is a Interceptor that may be for this task, but I am unsure. Do I
extend the interceptor and handle my logic there, or is there a simpler way.

Any examples, links would be appreciated.

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



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.17/505 - Release Date: 27/10/2006



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