As I mentioned before, look at the Interceptor interface that is part of
Struts 2.  It will allow you to get control of every request to check
whether the user is logged in and do the right thing if they are.  You can
add parameters to your actions in the struts.xml that can help control the
actions of the interceptor (we use <param name="role">user</param> to
indicate that an authenticated user is required to access the page (i.e.
action)).  Hopefully that will get you pointed in the right direction.
  (*Chris*)

On Mon, Nov 30, 2009 at 2:38 AM, Nguyen Xuan Son <yama...@gmail.com> wrote:

> dear chris
> I think it's ok if we redirect by using the struts.xml file
> but I really confuse in so many other cases
> for example
> when the user is login into the system already but still try to enter to
> login.jsp page
> in that case i think the system should be able to detect that the user is
> holding the session already and redirect the user to home.jsp page
> I really dont know how to solve that with only the struts.xml file
> thank you very much
>
> 2009/11/30 Chris Pratt <thechrispr...@gmail.com>
>
> > if you are returning "success" (or SUCCESS), then you need to define
> > <result
> > type="redirect" name="success">login.jsp</result> (or, since it's the
> > default you could just define <result
> type="redirect">login.jsp</result>).
> > What you defined will only work if you return "input" (or INPUT) from
> your
> > execute or if you action is returning from the input() method.
> >   (*Chris*)
> >
> > On Sun, Nov 29, 2009 at 11:05 PM, Nguyen Xuan Son <yama...@gmail.com>
> > wrote:
> >
> > > Dear
> > > I've tried
> > > <action name="SessionCheck"
> class="com.baibai.action.SessionCheckAction">
> > > <result type="redirect" name="input">login.jsp</result>
> > > </action>
> > >
> > > but nothing happen, it seems that even if i fall into the irrelevant
> > > situation
> > > it doesnt not redirect to the login.jsp page
> > > thank you very much
> > >
> > > 2009/11/30 Saeed Iqbal <saee...@gmail.com>
> > >
> > > > type="redirect"
> > > >
> > > > On Monday, November 30, 2009, Saeed Iqbal <saee...@gmail.com> wrote:
> > > > > Just have redirect near result name=""
> > > > >
> > > > > On Monday, November 30, 2009, Nguyen Xuan Son <yama...@gmail.com>
> > > wrote:
> > > > >> dear all
> > > > >> here i've the detail of struts file
> > > > >> <action name="SessionCheck"
> > > > class="com.baibai.action.SessionCheckAction">
> > > > >> <result name="input">sessionChk.jsp</result>
> > > > >> </action>
> > > > >>
> > > > >> and in the SessionCheckAction.java file i have
> > > > >> public class SessionCheckAction extends ActionSupport{
> > > > >> public String execute() throws Exception {
> > > > >> Map ses = ActionContext.getContext().getSession();
> > > > >>  // check where the the session is null or empty string
> > > > >> if(StringUtils.isNotEmpty((String)
> > > > >> ses.get("context"))&&StringUtils.isNotEmpty((String)
> > > ses.get("role"))){
> > > > >>
> > > >
> > >
> >
> if(ses.get("context").toString().isEmpty()||!ses.get("role").toString().equals("admin")){
> > > > >> // the user is loginned as an administrator
> > > > >>  }
> > > > >> } else {
> > > > >> // the user have not been loggined in or user's role is not an
> > > > administrator
> > > > >>  }
> > > > >>  return SUCCESS;
> > > > >> }
> > > > >> }
> > > > >> in both case, i want to redirect to login.jsp page
> > > > >> i've tried with the struts.xml file but failed
> > > > >> do you have any suggestion,
> > > > >> thank you very much
> > > > >>
> > > > >> --
> > > > >>
> > > =======================================================================
> > > > >> Ritsumeikan University, Asia JinZai Project
> > > > >> Master of Information Science
> > > > >> Nguyen Xuan Son
> > > > >>
> > > > >> Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> > > > ShiteiHaimu
> > > > >> Rien, Room 103
> > > > >> Tel/Fax  : 81-(0)90-3976 2246
> > > > >> Email    : nr000...@ed.ritsumei.ac.jp
> > > > >> Mobile   : 81-(0)90-3976 2246          URL  :
> > http://www.ritsumei.jp
> > > > >>
> > > =======================================================================
> > > > >>
> > > > >
> > > > > --
> > > > > Saeed Iqbal
> > > > > Independant Consultant (Freelance)
> > > > > Struts - J2EE - Application Architect / Developer
> > > > >
> > > >
> > > > --
> > > > Saeed Iqbal
> > > > Independant Consultant (Freelance)
> > > > Struts - J2EE - Application Architect / Developer
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > > > For additional commands, e-mail: user-h...@struts.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > =======================================================================
> > > Ritsumeikan University, Asia JinZai Project
> > > Master of Information Science
> > > Nguyen Xuan Son
> > >
> > > Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> > > ShiteiHaimu
> > > Rien, Room 103
> > > Tel/Fax  : 81-(0)90-3976 2246
> > > Email    : nr000...@ed.ritsumei.ac.jp
> > > Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
> > > =======================================================================
> > >
> >
>
>
>
> --
> =======================================================================
> Ritsumeikan University, Asia JinZai Project
> Master of Information Science
> Nguyen Xuan Son
>
> Add       : Japan, Shiga-Ken, Kusatsu-Shi, Kasayama 3choume 1-18
> ShiteiHaimu
> Rien, Room 103
> Tel/Fax  : 81-(0)90-3976 2246
> Email    : nr000...@ed.ritsumei.ac.jp
> Mobile   : 81-(0)90-3976 2246          URL  : http://www.ritsumei.jp
> =======================================================================
>

Reply via email to