After user logs in when he uses back browser button it takes him to the Login page. When he refreshes the page without entering any data the user is take back to his personal page. I am having problems in accomplishing this task. Give me some idea to solve this.
How to differentiate between the request coming via a refresh button and back browser button.
Author and all-around good cowpoke
Joined: Mar 22, 2000
Here is one of many possible ways to do this. Suppose that in the code that writes the "personal page" you do this: session.setAttribute("where","personalpage" );
In your doGet or doPost, after getting the session: String where = (String)session.getAttribute( "where" );
Now, if the request comes from the Login page, you can ignore the login form data and go straight to the personal page presentation.
Joined: Nov 15, 2004
I got a well-designed login jsp page with all the cache controlling mechanics enabled for the page(to reflect the state of the model). Once when the user enters loginName/Password control transfers to controller servlet. I had used a sendRedirect to tranfer the user to his personal page after setting the username in session attribute.
Now user is in his personal page. Without logging out when the user clicks Browser Back Button, a get request is made for the Login.jsp page. Since cache controlling is enabled both the userName/Password textboxes are empty. Here when the user clicks the refresh/reload button he should be taken back to his personal page since he hasn't logged out of his session.
It is here I am getting the problem.
Is there a way to find the difference between the request made by a Browser Back Button and Refresh/Reload button.
I had set a session attribute in personal page, evaluate that session attribute in login.jsp page and send him back to his personal page. This is fine when the user uses refresh/reload button. But the same logic happens even when the user clicks his Browser Back Button. Since both makes a get request.
How to solve this issue. [ November 17, 2005: Message edited by: Vishnu Prakash ]
If you read William Brogden's comment your answer is there.
Whether you do back or refresh, the browser generates only requests (get or post in this case) to the server. There is no way to distinguish between the request generated from a back button, refresh or submit. If you have an indication of where user is or status of user (logged in or logged out) in session, this is easy to do. Did you try what William told?
Could it be your browser caching the logging page?
Joined: Nov 15, 2004
Whether you do back or refresh, the browser generates only requests (get or post in this case) to the server. There is no way to distinguish between the request generated from a back button, refresh or submit.
Thanks for the information.
If you have an indication of where user is or status of user (logged in or logged out) in session, this is easy to do.
In my case user is logged in.
I had set the userName as session attribute in personal page, evaluated that session attribute in login.jsp page and if the user is still in the session transfer him to his personal page. This is fine when the user uses refresh/reload button. But the same logic executes even when the user clicks his Browser Back Button. Since both makes a get request.
Log in to your Yahoo account. You will be taken to your personal page. Now just click the Browser Back Button. You will be taken back to your log in page. (You are still a logged-in user which means user is in session). Now click the refresh/reload button. You will be taken back to your pesonal page without requiring to type in your username/password.