• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

redirecting a logged in user to the previous page

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I noticed that if I try to respond to a post without logging in, Javaranch redirects me to the login page, and once I login, takes me back to the original page I was on, before logging in.
One approach I can think of to do this, is to examine the session for the user's credentials, and if the user has not logged in, redirect him/her to the login page, with a query string that gives the value of the page the user should be sent to, once he/she logs in. But, there has to be a better way of doing this. How does Javaranch do this?
 
Bala Krishna
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No Responses! . I was curious about how Javaranch handles this and hoped that the moderators would know the answer to my question and respond.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know how JavaRanch does it. But if I wanted to do that, here's how I would do it:

1. Store the URL of the requested page somewhere. E.g. in a session variable or as a parameter of the URL being redirected to.

2. Have the login page retrieve that URL and redirect to it after successful login.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've used hidden elments quite successfully for this purpose.
reply
    Bookmark Topic Watch Topic
  • New Topic