Hello O'Reilly,

Monday, July 09, 2001, 12:31:16 PM, you wrote:

ORJ> Hi Oleg,
ORJ> Thanks for your reply.  The only thing missing from your solution (I think!)
ORJ> is how to then forward the user to the original requested page if the login
ORJ> succeeds.
ORJ> Thanks,
ORJ> John

Solution one - store URL to the initial page at session, solution two
- store it in ActionForm and write as hidden parameter to the page.

>> -----Original Message-----
>> From: Oleg V Alexeev [SMTP:[EMAIL PROTECTED]]
>> Sent: 06 July 2001 18:40
>> To:   [EMAIL PROTECTED]
>> Subject:      Re: Redirecting to login page
>> 
>> Hello O'Reilly,
>> 
>> You can check it in Action. Create base SecureAction with check of
>> login -
>> 
>> public class SecureAction extends Action {
>> 
>>        ActionForward securePerform( ... ) {
>>                      return loginForward;
>>        }
>> 
>>        ActionForward perform ( ... ) {
>> 
>>                      if( check user - is logged in? ) {
>>                        return securePerform( ... );
>>                      } else {
>>                        return loginForward;
>>                      }
>>        
>>        }
>> 
>> }
>> 
>> public class TransactionAction extends SecureAction {
>> 
>>        ActionForward securePerform( ... ) {
>>                      // some stuff here
>>                      return nativeForward;
>>        }
>> 
>> }
>> 
>> Friday, July 06, 2001, 8:31:40 PM, you wrote:
>> 
>> ORJ> Hi,
>> ORJ> I have overridden the processActionPerform method to cause the user
>> to be
>> ORJ> redirected to a login page if they are entering a "closed" area and
>> have not
>> ORJ> previously loggged in.  The code below shows my initial attempt.
>> What is
>> ORJ> the accepted way of doing this?  I assume there must be a cleaner
>> way.
>> 
>> ORJ>       boolean isClosedArea = portalMapping.getIsClosedArea();
>> 
>> ORJ>       String userName = (String)session.getAttribute("USERNAME");
>> 
>> ORJ>       if ( isClosedArea  && (userName == null || userName == "") )
>> ORJ>       {
>> ORJ>         // store requestPath so that we can use it when log in is
>> successful
>> ORJ>         session.setAttribute("REQUEST_PATH", mapping.getPath());
>> 
>> ORJ>         return new ActionForward("/loginpage.do");
>> ORJ>       }
>> ORJ>       else
>> ORJ>       {
>> ORJ>         // If REQUEST_PATH is set, then this action was dynamically
>> inserted
>> ORJ> before
>> ORJ>         // original request.  Make sure we redirect to original
>> request when
>> ORJ>         // action completes.
>> ORJ>         String
>> requestPath=(String)session.getAttribute("REQUEST_PATH");
>> ORJ>         if ( requestPath != null && requestPath != "" )
>> ORJ>         {
>> ORJ>           session.setAttribute("REQUEST_PATH", "");
>> 
>> ORJ>           super.processActionPerform(action,mapping, formInstance,
>> request,
>> ORJ> response);
>> ORJ>           return new RedirectingActionForward(requestPath + ".do");
>> ORJ>         }
>> 
>> ORJ>         return super.processActionPerform(action,mapping,
>> formInstance,
>> ORJ> request, response);
>> ORJ>       }
>> 
>> ORJ> Thanks, 
>> 
>> ORJ> John O'Reilly
>> ORJ> Traventec
>> 
>> ORJ> Phone:  +353 91 518786
>> ORJ> Fax:      +353 91 525056
>> ORJ> Email:    [EMAIL PROTECTED]
>> ORJ> www.traventec.com
>> 
>> 
>> 
>> 
>> 
>> -- 
>> Best regards,
>>  Oleg                            mailto:[EMAIL PROTECTED]
>> 




-- 
Best regards,
 Oleg                            mailto:[EMAIL PROTECTED]


Reply via email to