I store the last request before redirecting to the login page in the
session as well. I do not have any authorisation logic in the controlls
though, as I check the rights for a request in a servlet filter (using
JAAS). If a there is a request for a session that has not been logged in
(I check whether an instance of Subject was saved in the session), I
save the whole current request (including the parameters) in the
session. If a login succeedes, I just remove the request from the
session and redirect to it. If the redirect is still not allowed, my
filter will send an unauthorized error.  

If I wanted to add extra parameters with the redirect, I would just take
the request URL (string) and add the paramters to it just before
redirecting.

So, if I get you right, you should do something like:

   public String execute( BaseForm formBean, ControllerContext cctx )
throws Exception
   {
           try
         {
            // Authenticate Code...Throw exception if login failed...

            if ( ! StrUtil.isEmpty( formBean.getRedirect( ) ) )
            {
                        String redir = formBean.getRedirect( );
                        redir = redir + "?param1=blah&param2=moreblah"; 
                        // ofcourse you should do proper checking if
there were 
                        // allready some parameters set, and you might
want to filter others                   

               cctx.setModel( redir );
               return "redirect";
            }
            return SUCCESS;
         }
         catch ( SignInException e )
         {
         }
      }

Good luck,

Eelco

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mike Moulton
Sent: zaterdag 2 augustus 2003 22:23
To: [EMAIL PROTECTED]
Subject: Re: [Mav-user] Login with dynamic redirect



>> Scenario 2,
>>
>> User types http://host/app/protectedCommand.m?p1=v1&p2=v2&p3=v3
>>
>> Same idea, user is redirected to login and then if login is
>> successfull
> they
>> should be redirected through to initially selected command, only this
>> time
>> there are a number of URL paramters that I wish to have set, Does 
>> anyone
>> have a simple way of acheiving this functionality.

David,

In general I usualy have a 'MasterController' that is extended by 
'protectedCommand'. If the master controller determines that 
'protectedCommand' requires a login, and the user is not yet logged in, 
then I re-assemble the url used to access this page, store it in a 
session value and redirect to the login controller. Upon successful 
login the login page looks to see if the session value is set, if so it 
redirects to that page.

Another way is to have your login controller look at the referrer, 
analyze it to see if it came from within your application, if so, save 
it in the session and redirect to it upon successful login.

-- Mike



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01
/01
[INVALID FOOTER]



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
[INVALID FOOTER]

Reply via email to