aspose file tools*
The moose likes JSP and the fly likes session handling problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "session handling problem" Watch "session handling problem" New topic
Author

session handling problem

shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
Hi everyone,
I need help from you people and I am sure that you'll help me.
I am using jsp as front end,ms-access at the backend .I have done the validation part and the user is validated but when the user logs out from the main screen which is the jsp page ,he goes back to the login.html page ,over there the user shouldn't be able to go back once logged out.But over here it is showing me the previous page from where i logged out and also when the user logs in he can go back to the login.html page and without logging in he is directed to main page using forward.I have done the neccessary session handling but cant get the perfect result.Am i making any mistake or missing out something.
please help me .thanks in advance I am placing the code over here.


This is my main page. welcome.jsp


this is my logout.jsp



the loginpage is the login.html and the database connectivity is done by login1.jsp which forwards to welcome.jsp .
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

use javascript.history.forward(1); in your jsp... when he comes out from the jsp..he can not go to that again

Hope this helps
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

I dont know how can one disable the back button or show error message once the user logged out ! But you can surely check a valid session on each JSP page and then allow user to perform operation or show results ! If in case the user logged out and go back on previous page using 'Back' button , he will not able to perform any operation , as you are checking its user id in session , which is no longer valid, user need to re-login !


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
I did not properly understand.You mean to say that i have to place this code in jsp, javascript.history.forward(1); but in which jsp i have to place this code and how so that it is implemented for every user also if you are saying that to maintain user id session in each jsp page i have to use <%=session.getid()%> right.but how should i maintain it to not to go back.
please help me with suggestions.
thanks in advance.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575




put this into your login page(which is contain username/password textbox) at header section...and try...
let me know,if any issue
shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
hi,
I placed that code in my login.html in the <head>-- </head> tag. But there is no changes to the scenario.And i did not understand forward(1),what is that 1 for.
please help me.I am still facing the same problem.
thanks in advance
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by shiju nair:

forward(1),what is that 1 for.


hi, suppose you are putting that code in a.jsp then you went b.jsp(href link from a.jsp) now if you click back button of browser it will go a.jsp right?...that time browser will see that forward(1)..then it will go 1 step forward it mean you willbe in the same page (b.jsp)

i think you not using that code the particular page(which page you have to put)..

try and let me know


Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi,
you put below one also in your jsp to avoid the browser caching



Hope This Helps
shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
hi,
I am putting this code in my login.html which is my first page containing the username and password textbox,through which i will be directed to login1.jsp which is my database connectiviy and validation page.From there if the user is valid it is forwarded to welcome.jsp,now when i log out from welcome.jsp it takes me to login.html, but when i click the back in the standard bar it takes me back to welcome.jsp though i have not logged in that means my session is still running.I tried to place this code as i stated above but no difference it is giving me the same result.
please solve this problem for me.
thanks in advance.
shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
hi,
Let me try out the second one .
thanks
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by shiju nair:
hi,
I am putting this code in my login.html which is my first page containing the username and password textbox,through which i will be directed to login1.jsp which is my database connectiviy and validation page.From there if the user is valid it is forwarded to welcome.jsp,now when i log out from welcome.jsp it takes me to login.html, but when i click the back in the standard bar it takes me back to welcome.jsp though i have not logged in that means my session is still running.I tried to place this code as i stated above but no difference it is giving me the same result.
please solve this problem for me.
thanks in advance.


Then you put in welcome.jsp (you have to put that javascript in welcome.jsp)...i think your not geeting me
shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
hi,
Now the scene is that when i added your code in jsp,the back button in the welcome page is not functioning that means, the person has to logout that is nice.but once the user logs out and comes to the login.html from there he is able to press the back button and can go back to previous welcome page without logging in.
should i do one thing i should make that html page into jsp page and add the same code over there also. will that make any difference or else any other solution.
please suggest .thanks in advance.
shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
hi,
I have added this code in welcome.jsp as you suggested but it does not make any difference it is the same as i mentioned just now.
one more thing you want me to place that javascript code also in the login.html .
please suggest.
shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
hi,
sorry i was a bit mistaken in my previous statement .i will add the javascript in the welcome.jsp .hope it works.
thanks
shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
hi,
the code what you told really worked.
thanks a lot.
one more thing has happened now due to the changes that i made now when i am logging in as wrong user and password it is not giving me the invalid page else it is showing me a blank page where in i cant even go back.
please suggest.
shiju nair
Ranch Hand

Joined: Jul 18, 2008
Posts: 45
hi,
thanks a lot, now all the things are working fine as i want.I am going ahead with my project and if i find any problem,hope you are always there to help .
thanks again.
take care
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

you are welcome
 
 
subject: session handling problem