For redirecting to the login page when a user isn't logged in and
attempts to access a "logged in user" only url.. I did the following...

I originally made my CreateProfileAction implement CommandDriven and
made the link from the main page href="createprofile!default.action",
but then I wanted the user to be redirected to the login page if they
weren't logged in or their session expired so this is what I did...

I overrided the doDefault method like so..
public String doDefault() throws Exception {
        checkUserLoggedIn(); return INPUT;
}

and created a checkUserLoggedIn() method like so...

private void checkUserLoggedIn() throws ResultException {
        if (session == null || session.get("screenname") == null) {
        throw new ResultException(LOGIN,"You must logged before creating
a profile.");
        }
}

I also put the checkUserLoggedIn() call at the beginning of the
doExecute() method.

And I put a login redirect.action in my actions.xml file.

And it works perfectly... if the user bookmarked the
createprofile!default.action url and tries to get to it without logging
in it redirects them to the login page.

Is there a better way to do this..? and/or any docs that explain the
method I used or any other method?  Should I add this technique to the
wiki?
Ta,
Raj.





-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
The most comprehensive and flexible code editor you can use.
Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
www.slickedit.com/sourceforge
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to