aspose file tools*
The moose likes JSP and the fly likes Need some help regarding sessions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Need some help regarding sessions" Watch "Need some help regarding sessions" New topic
Author

Need some help regarding sessions

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Hi everybody, I have a problem with my application. In my application I have a login page, if the user is already logged in and requests for login page, he will be automatically redirected to home.jsp. If he is not logged in he will must get authenticated.

Now after the user logins from the browser, if he opens another window and tries to login from that one the, login page is recognizing the user as already logged in, the problem is arising if the user closes the browser and again wants to login. If the user closes the browser and opens a new browser then if he request for the login page he is not redirected to home page, he is asked to get authenticated. Why is this happening? Anybody please help me.

This is the code:

login.jsp


web.xml


Login.java


main.jsp


error.jsp


Please help me. Thank you all in advance.


Love all, trust a few, do wrong to none.
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 453

it is happening because the default lifetime of the JSESSIONID cookie is until a user closes the browser. if you don't want this to happen create a custom cookie and based on that you can create the session and condition for redirection.

avi sinha


SCJP 5.0 SCWCD 5.0
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Thank you Avi, but what if the cookies are disabled. I can go with url encoding, but I don't know how to do that. Can you give me a sample example.

Thank you in advance.
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 453

anusha chaitanya wrote:Thank you Avi, but what if the cookies are disabled. I can go with url encoding, but I don't know how to do that. Can you give me a sample example.

Thank you in advance.


well if cookies are disabled then you can implement url-rewriting easily by encoding all the urls or using <c:url value ../> (in encodes the url provided in the value) .
but in this case i can't suggest another option. wait for sometime some senior member will help you out with this.

avi sinha
 
jQuery in Action, 2nd edition
 
subject: Need some help regarding sessions