开发者

How to maintain track of a url

开发者 https://www.devze.com 2022-12-20 19:25 出处:网络
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 t

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


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);


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

0

精彩评论

暂无评论...
验证码 换一张
取 消