I do exactly the same kind of thing with a site. All actions extend
BaseAction which extends Action, and implement executeAction, not execute.
The (relevant)code for BaseAction:
abstract public class BaseAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
if (isSessionValid(request)) {
return executeAction(mapping, form, request, response);
} else {
return mapping.findForward("showsessionexpired");
}
}
abstract public ActionForward executeAction(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception;
private boolean isSessionValid(HttpServletRequest request){
... // check for presence of session var
}
}
isSessionValid is a function you must define in this class to check for the
presence of a particular var. It forwards to the showsessionexpired
global-forward if not.
Daniel.
> -----Original Message-----
> From: Scott Purcell [mailto:[EMAIL PROTECTED]
> Sent: 23 February 2005 13:56
> To: [email protected]
> Subject: Session Expires Question
>
>
> Hello,
> I am creating a shopping cart application where each web-user has
> a shoppingcart/userobject in their session. The problem is,
> unlike most software I create, there is no userlogin. I would
> like to be able to show them a jsp page that states when their
> session has expired, and that they will have to acquire their
> widgets again.
>
> The main problem I am having is understanding how to do this
> using struts. The way I have built the SW is as follows. I have a
> welcome-file page that goes to an Action instead of just using a
> index.jsp page. The action creates a shopping cart object and
> places it in the session. The problem is that the index.jsp page
> is called everytime they hit 'home' which is the top level product page.
>
> Does anyone have any ideas, or examples of how this could be
> accomplished. Also, I did create a subclass for Action in which I
> check and ensure that the shoppingcart/userobject exists. I just
> can't figure out how to handle this when it goes away.
>
> Any input or help would be appreciated.
>
> Sincerely,
>
> Scott K Purcell
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]