views:

47

answers:

2

Hi, I am working in a struts application.Now suppose wants to access the page abc.do without active session right now I am asking the user to login to the app and he will login and go to the home page(index.jsp) I check whether he is logged in using an action class.

Now imagine there are three pages abc.do bca.do cba.do

All of these pages will call the action class validateAction.java before going to their corresponding jsp pages abc.jsp, bca.jsp cba.jsp

There are other pages also apart from the above jsp pages mentioned.So my user wants to store these as bookmark and he is ready to login only by selecting abc.do and immediately after logging instead of coming to index.jsp he wants to land in abc.do(abc.jsp)

How to keep track of which .do was called?

I can provide more information if needed

+2  A: 

In the code that checks if the user has an active session, you can get the request URI address from the HttpServletRequest and then store it as a session attribute.

HttpServletRequest hreq = (HttpServletRequest) request;
String currentURI = hreq.getRequestURI();
hreq.setAttribute("firstURI", currentURI);

After the user is authenticated you get the attribute from the session and issue a forward command.

hreq.getRequestDispatcher(firstURI).forward(hreq, hres);

Prof
A: 

Please refer http://java.sun.com/blueprints/patterns/InterceptingFilter.html Implement it the same way Prof describe..

Shashi Bhushan

related questions