RE: How to redirect to login page
[EMAIL PROTECTED] (Reid Pinchback) wrote: Another alternative is used by the workflow extension listed on the Struts resources page. You can create a base action class that does the checking in its perform method, then calls some other method provided by the concrete subclass to do the normal work if the user is already logged in. In that extension package the performAction method is called. I use this pattern (its really just a template method pattern), but I just call it perform() since I pass an extra parameter which is the users credentials object to distinguish it from the original perform. I then mark the original perform final and the new perform abstract and then derived classes must conform to the pattern. Other ideas: have a method minLogonLevel() which derived classes can override to indicate the necessary logon level required for this action. Example use is to have AdministratorAction base class which defines this and then derive administrator actions from it. You can use a similar template method pattern to factor out repetitive database access code, e.g. closing the connection in finally and catching SQLException. Duncan Harris ~~~ Hartford, Cheshire, U.K., Tel: 07968 060418 Looking for STRUTS contract work in the U.K. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: How to redirect to login page
Reid Pinchback wrote: Another alternative is used by the workflow extension listed on the Struts resources page. You can create a base action class that does the checking in its perform method, then calls some other method provided by the concrete subclass to do the normal work if the user is already logged in. In that extension package the performAction method is called. What about extending ActionServlet and put authentification code in the processPreprocess() method ? (http://www.mail-archive.com/struts-user@jakarta.apache.org/msg15542.html) Javadoc of this function is : /** * General purpose preprocessing hook that can be overridden to support * application specific preprocessing activity. This hook can examine * and/or modify the properties of the request and response objects, and * optionally complete the response if it wishes. * p * The default implementation does nothing. */ protected boolean processPreprocess(HttpServletRequest request, HttpServletResponse response) -- C. Bouessay -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: How to redirect to login page
A common approach is to (1) Route all control through an Action, even if all the Action does is forward to the JSP. (2) Have the Action check for a session property or a cookie which indicates whether they have logged in. For (1), a single continue Action can be used for any page that doesn't require other preprocessing. return mapping.findForward(Tokens.CONTINUE); (1) is also an essential element in the new support for modular applications that was introduced in the nightly build last week. -- Ted Husted, Husted dot Com, Fairport NY USA. -- Java Web Development with Struts. -- Tel +1 585 737-3463. -- Web http://www.husted.com/struts/ Sivasankaran, Vijay wrote: Hi, I have three jsp which uses the struts framework first.jsp-second.jsp-third.jsp the second.jsp and third.jsp use the action form data of the first.jsp using html:text tag. All these works fine. But this poses a problem. I want the user to be redirected to first.jsp whenever they access second.jsp and third.jsp directly without going through first.jsp. At present when i access second.jsp or third.jsp directly it errors out. Is there a graceful way in struts to redirect it to first.jsp? Thanks Vijay -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: How to redirect to login page
Set a session variable in first.jsp, then create a custom tag that checks for that session variable and place the custom tag in second.jsp and third.jsp. If the session variable isn't there, forward to first.jsp. The sample app does this exact process with the CheckLogonTag. Go look at how that works. Jeff -Original Message- From: Sivasankaran, Vijay [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 24, 2002 10:18 AM To: '[EMAIL PROTECTED]' Subject: How to redirect to login page Hi, I have three jsp which uses the struts framework first.jsp-second.jsp-third.jsp the second.jsp and third.jsp use the action form data of the first.jsp using html:text tag. All these works fine. But this poses a problem. I want the user to be redirected to first.jsp whenever they access second.jsp and third.jsp directly without going through first.jsp. At present when i access second.jsp or third.jsp directly it errors out. Is there a graceful way in struts to redirect it to first.jsp? Thanks Vijay -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: How to redirect to login page
Jeff Oberlander [EMAIL PROTECTED] wrote: Set a session variable in first.jsp, then create a custom tag that checks for that session variable and place the custom tag in second.jsp and third.jsp. If the session variable isn't there, forward to first.jsp. The sample app does this exact process with the CheckLogonTag. Go look at how that works. Another alternative is used by the workflow extension listed on the Struts resources page. You can create a base action class that does the checking in its perform method, then calls some other method provided by the concrete subclass to do the normal work if the user is already logged in. In that extension package the performAction method is called. I like the architecture used by this package, but I don't like some aspects of the implementation. It invalidates the session if the user hasn't yet logged in (which is a serious pain if the user had logged in, but the session timed out), and it doesn't really have any support for looping back to where you started from by saving and restoring form data. The package also doesn't contain any licensing info, which tends to make the corporate legal eagles tres nervous. Reid - Do You Yahoo!? Yahoo! Auctions Great stuff seeking new owners! Bid now!