You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Viplav Kallepu <vi...@gmail.com> on 2007/10/15 18:47:38 UTC

Bookmarking functionality in struts

Hi all,

I am using struts 1.3.8. I was trying bookmarking functionality out of
curiosity.(User will bookmark a page then if he clicks that link he should
be informed to login which is the entry point into application and then he
should be forwarded to the page he bookmarked) . I wish to do it even when
session is expired. Any one who achieved this functionality before please
help me in knowing the solution. I did google but I wasn't able to find any
thing useful. If you can give me any tutorial kind of thing that would be a
great help.

-- 
Regards
Viplav Kallepu

Re: Bookmarking functionality in struts

Posted by Viplav Kallepu <vi...@gmail.com>.
Thanks for the reply Jim I was trying to do whatever you said.. taking ur
idea when session expires what I did was I redirected to login page passing
request.getServletPath(); parameter as redirect param. But problem I had was
every thing in application has to go through the login action class which
put some values in the session. First I will tell you what I did

CODE I wrote for base action class
#########################################
*

if* (authuser == *null*){

String redirectUri = request.getServletPath();

actionRedirect.addParameter("redirectUri", redirectUri);

messages.add("message", *new* ActionMessage("session.expired"));

saveMessages(request, messages);

*return* actionRedirect;

}
########################################

After redirecting to login Jsp the thing I did is

######################################################

String redirectUri = request.getParameter("redirectUri");

System.out.println("redirectUri"+redirectUri);

*if*(redirectUri != *null*)

{

%>

<input type="hidden" name="redirectUri" value="<%=redirectUri%>">

<%

}

%>
######################################################

This I did because I have to go through the login action class as I load all
the session values in that page...

Login Action Class
######################################################

*if*(redirectUri != *null*){

*return* mapping.findForward(redirectUri11);

}
######################################################
and in my struts config.xml what i Wrote was

#######################################################

<action path="/web/jsp/admin/Logon" type="
edu.louisiana.cbit.capture.Admin.action.LogonSubmitAction"

name="LoginActionForm" input="/web/jsp/login.jsp" >

<forward name="success" path="mainlayout.page"/>

<forward name="/web/jsp/Reviewer/AddUser.do"
path="/web/jsp/Reviewer/AddUser.do"/>

<forward name="/web/jsp/admin/ViewUsers.do"
path="/web/jsp/admin/ViewUsers.do"/>

</action>
#######################################################

This is like when I click AddUser which is link
"/web/jsp/Reviewer/AddUser.do" if session donot exist then it is redirected
to the login page passing the value "/web/jsp/Reviewer/AddUser.do". Then in
login action class it is forwarded using
mapping.findForward("/web/jsp/Reviewer/AddUser.do"). and for that action
mapping I am forwarding to appropriate page. Is this the right way to do...
THis will put lot of entries in the config file..other thing is in the
adress bar even if I am redirecting its still showing as If I am in login
page like even if I am in "web/jsp/Reviewer/AddUser.do" its showing as if am
in "web/jsp/Reviewer/Login.do"...Please give me a hint if there is any
better way.

Laurie,

Thanks for the suggestion but unfortunately I was forced to use application
managed security so I have to sort out my own logic to bookmark pages.

Regards
Viplav Kallepu

On 10/15/07, Laurie Harper <la...@holoweb.net> wrote:
>
> You could also consider using container managed security, which handles
> this use case transparently, or one of a number of existing
> authentication frameworks (e.g. Spring Security) which can also take
> care of it.
>
> Basically, the exact solution depends on your requirements, particularly
> with respect to authentication.
>
> L.
>
> Jim Cushing wrote:
> > It's been a while since I've used Struts 1.x, but back in the day, I did
> > implement this type of functionality. Basically, the app would redirect
> > to the login action, with the destination what the user tried to access)
> > as an encoded parameter in the URL. Something like
> > "/login.do?destination=http://...". The login action would look for the
> > "destination" parameter, and send a redirect to that URL if present.
> >
> > I don't have specific code for you (again, it's been a while since I've
> > used Struts 1.x), but that gives you an outline of what you'd need to
> do.
> >
> > On Oct 15, 2007, at 12:47 PM, Viplav Kallepu wrote:
> >
> >> Hi all,
> >>
> >> I am using struts 1.3.8. I was trying bookmarking functionality out of
> >> curiosity.(User will bookmark a page then if he clicks that link he
> >> should
> >> be informed to login which is the entry point into application and
> >> then he
> >> should be forwarded to the page he bookmarked) . I wish to do it even
> >> when
> >> session is expired. Any one who achieved this functionality before
> please
> >> help me in knowing the solution. I did google but I wasn't able to
> >> find any
> >> thing useful. If you can give me any tutorial kind of thing that would
> >> be a
> >> great help.
> >>
> >> --
> >> Regards
> >> Viplav Kallepu
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Regards
Viplav Kallepu

Re: Bookmarking functionality in struts

Posted by Laurie Harper <la...@holoweb.net>.
You could also consider using container managed security, which handles 
this use case transparently, or one of a number of existing 
authentication frameworks (e.g. Spring Security) which can also take 
care of it.

Basically, the exact solution depends on your requirements, particularly 
with respect to authentication.

L.

Jim Cushing wrote:
> It's been a while since I've used Struts 1.x, but back in the day, I did 
> implement this type of functionality. Basically, the app would redirect 
> to the login action, with the destination what the user tried to access) 
> as an encoded parameter in the URL. Something like 
> "/login.do?destination=http://...". The login action would look for the 
> "destination" parameter, and send a redirect to that URL if present.
> 
> I don't have specific code for you (again, it's been a while since I've 
> used Struts 1.x), but that gives you an outline of what you'd need to do.
> 
> On Oct 15, 2007, at 12:47 PM, Viplav Kallepu wrote:
> 
>> Hi all,
>>
>> I am using struts 1.3.8. I was trying bookmarking functionality out of
>> curiosity.(User will bookmark a page then if he clicks that link he 
>> should
>> be informed to login which is the entry point into application and 
>> then he
>> should be forwarded to the page he bookmarked) . I wish to do it even 
>> when
>> session is expired. Any one who achieved this functionality before please
>> help me in knowing the solution. I did google but I wasn't able to 
>> find any
>> thing useful. If you can give me any tutorial kind of thing that would 
>> be a
>> great help.
>>
>> -- 
>> Regards
>> Viplav Kallepu


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Bookmarking functionality in struts

Posted by Jim Cushing <ji...@mac.com>.
It's been a while since I've used Struts 1.x, but back in the day, I  
did implement this type of functionality. Basically, the app would  
redirect to the login action, with the destination what the user  
tried to access) as an encoded parameter in the URL. Something like "/ 
login.do?destination=http://...". The login action would look for the  
"destination" parameter, and send a redirect to that URL if present.

I don't have specific code for you (again, it's been a while since  
I've used Struts 1.x), but that gives you an outline of what you'd  
need to do.

On Oct 15, 2007, at 12:47 PM, Viplav Kallepu wrote:

> Hi all,
>
> I am using struts 1.3.8. I was trying bookmarking functionality out of
> curiosity.(User will bookmark a page then if he clicks that link he  
> should
> be informed to login which is the entry point into application and  
> then he
> should be forwarded to the page he bookmarked) . I wish to do it  
> even when
> session is expired. Any one who achieved this functionality before  
> please
> help me in knowing the solution. I did google but I wasn't able to  
> find any
> thing useful. If you can give me any tutorial kind of thing that  
> would be a
> great help.
>
> -- 
> Regards
> Viplav Kallepu


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org