• Post Reply Bookmark Topic Watch Topic
  • New Topic

Auto Redirect to login page and back

 
Poornima Sharma
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,

In a no. of web sites we have seen that when we try to open a page we are redirected to the login page and after login we return back to the required page.
How can we perform this operation in jsp. I think it could be done through filters but how I dont know.

Please guide.

Poornima Sharma
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simple. In the filter you check to see of you need to redirect to the login page. If you do, before redirecting, record the original URL and any request parameters (in session, or in hidden parameters on the login page). Once a successful login occurs, redirect to the recorded URL, passing the recorded parameters.
 
Poornima Sharma
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks sir,

Even I was thinking the same way. Can I get the selected url dynamically.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's all there on the request.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


getServletPath() would give you the requested Servlet , which can be used to redirect.
 
Poornima Sharma
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I searched a lot but could not find it.
Please tell me the command.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look harder.
 
Poornima Sharma
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Sir,

I got it its request.getRequestURI()/URL()
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!