You shouldn't have to have a form bean.  Here's the global forward I use for
the logout action:

        <forward name="forward.logout" path="/exec/logout"/>

Here's my action mapping for my logout action (Struts 1.0.2, with Tiles):

        <action path="/logout"
type="com.sprintpcs.ptt.controller.authentication.LogoutAction">
            <forward name="forward.success" path="template.login"/>
        </action>

The action class is short n' sweet (my abstract ActionSupport class
overrides Action's perform() method and then calls the abstract execute()
method):

public class LogoutAction extends ActionSupport {
     public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException {
        HttpSession session = request.getSession();
        if (session != null) {
            session.removeAttribute(USER_OBJECT_SESSION_ATTRIBUTE_KEY);
            session.invalidate();
        }
        return mapping.findForward(SUCCESS);
    }
}

So, then, all you need to do to let the user logout is provide a simple link
like this:

   <html:link forward="forward.logout"><bean:message
key="key.logout"/></html:link>

That should do it!

Hope this helps,

chris



> -----Original Message-----
> From: Darren McGuinness [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 30, 2002 10:17 AM
> To: [EMAIL PROTECTED]
> Subject: action mapping question
> 
> 
> Hi,
> 
> Having a few problems getting my application working 
> properly. Basically
> I've got a logon.jsp page which posts to logon.do action, which then
> validates and if successfull outputs search.jsp (shows in the 
> browser as
> /logon.do ).
> 
> then on search.jsp i have 2 forms, one to search.do and one 
> to logoff.do
> 
> here's my action mapping for logoff:
> 
>   <action   path="/logoff"
>               type="struts1.action.LogoffAction"
>               name="logoffForm"
>               input="/logon.do"
>               scope="request">
>             <forward name="success" path="/logon.jsp"/>
>             <forward name="failure" path="/logon.jsp"/>
>     </action>
> 
> first of all, i dont want to use a bean for the logoff action but it
> complains otherwise, so for now i've used a form with a 
> attribute dummy
> with get/set/reset/validate  methods....is there a way not to 
> have to do
> this? if i dont have a form, I get an exception complaining the form
> bean is null.....
> 
> second, what should 'input' be? if i leave it as "/logon.do" then it
> works, but also if i put it as "/tapssearch.jsp" it works......so what
> should it be? and how can i set action-mapping to accept 
> input from any
> page, seeing as for example i'll want to be able to log-off 
> from any one
> of the pages(bar the logon one of course!) So that i dont 
> have to write
> an action mapping for every page that has a logoff form....
> 
> cheers
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 

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

Reply via email to