This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
The above code is working fine. but my problem is when user has opened one JSP by logging, he is able to open the same page in the different window which is required session. my intension is he should not open same page in different window. i.e. with same user id two pages should not be opened simultaneously. Anybody have the solution?
If I understand you correctly, yo don't want two or more windows opened by the same user to share the same session. It depends on the browser and how the new window was opened. With IE, if it's opened via file->New (cntrl-N), the new window will share the same session.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
I am not clear whether you can restrict the user from sharing the same session with different instance of the browser,but for your login concern you can create (or use a existing one) a session attibute that indicates user is currently loged in.You can crosscheck this attribute before allowing him to login again through different browser instance.
... but my problem is when user has opened one JSP by logging, he is able to open the same page in the different window which is required session. my intension is he should not open same page in different window. i.e. with same user id two pages should not be opened simultaneously.
There isn't much you can do about this. Depending on how the user opens the new browser instance, the browser may or may not use the same session cookie for both windows.
For example: With MSIE, if you use CTRL+N to open a new instance both windows will have the same page and will both share the same session ID. This happens without a call to the server.
If the user opens a new instance of MSIE by clicking on Start -> Programs-> MSIE then the new one will have it's own cookie space and can maintain a separate session within your app.