File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes logout from page with frames Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "logout from page with frames" Watch "logout from page with frames" New topic

logout from page with frames

michael yue
Ranch Hand

Joined: Nov 20, 2003
Posts: 204
I have a page with 2 frames. Each of them check for session whether there is a user login or not. There is also 1 page that when called will display the page in frames(its a frameset page). I also check for session in this page. Now the problem is how do i logout/invalidate session from all this 3 pages at once when user click logout. The logout button is on the left frame of my page. Currently when I logout, the other frame is still in session.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

No, it's not. Once you invalidate the session, it's invalid regardless of window/frame.

Nothing, on the other hand, will automatically remove the "stale" page from other frames/windows.

[Asking smart questions] [About Bear] [Books by Bear]
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
By the way its not a good idea to use Frames. See <div> tag of HTML. It can help you. It will also help you to make your HTML pages more attractive.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Ditto on the recommendation to stop usng frames, but you can try adding a target="_top" to the logout button. The response will then replace all your frames. (Unless I've forgotten how to use frames. It's possible)
Srinivas Gogineni

Joined: May 06, 2004
Posts: 6
we can use some java scripting to achieve the same.On click of Logout ,cll the java script function to load into the whole frame

in that javascript write top.location.href="Login.jsp"

i have used this technique earlier.shd work for u also.
Thx and regards
michael yue
Ranch Hand

Joined: Nov 20, 2003
Posts: 204
Actually just now I figured out my problem. Its when I log in, if successful the login servlet perform a forward request to the welcome page. This cause the url to become the login servlet's url and it remains like that wherever any other links i clicked. Then I change to use redirect and the url does not stuck on the servlet's url again and i can logout completely.
If use forward, after logout pressing back button and hitting refresh will make the user being logged in again. It seems that using forward has some disadvantage like what I discovered. So when is the best times to use forward instead of redirect?
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Use redirect when the request object is not needed. I mean in redirect a new request object is created.

In case of forward the new request object is not created. the request object is forwarded to the next page as it is.
I agree. Here's the link:
subject: logout from page with frames
It's not a secret anymore!