aspose file tools*
The moose likes JSP and the fly likes Closing original window when logging out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Closing original window when logging out" Watch "Closing original window when logging out" New topic
Author

Closing original window when logging out

Barbara Norway
Ranch Hand

Joined: Sep 30, 2003
Posts: 150
Hello,

I am new to JSP so I apologize if this is a trivial question. I have looked for an answer to this a fair bit and have experimented to try to see if I could get it to work but am still unable to. What I want to do is close the main application (brower) window for my JSP system when the user selects logout form the navigation menu. What it does now is to inactivate the session (good) but it doesn't close the window. If the user clicks on another menu item, a "min-version" of the original login window pops up in the main frame (bad). The code for my logout is:

<%@page language="java" %>
<html>
<head>
</head>
<body onUnload="invalidate.jsp"; mainframe.close();>
<%
%>
</html>

invalidate.jsp looks like this:

<%@page language="java" %>
<html>
<head></head>
<%
session.invalidate();
window.close();
%>
</body>
</html>

I know these are kludgey, especially because I've been hacking them for awhile so leftover stuff may still be in them. I borrowed the invalidate.jsp as a separate program idea from a former poster to this forum. I originally had it in my logout.jsp

Thanks very much in advance for any help.
farmkitty


farmkitty
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
you need to close the window in a piece of Javascript.
Send back a URL to a page:


remove the _


42
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

Doesn't closing the browser on the user strike you as a tad bit rude?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Barbara Norway
Ranch Hand

Joined: Sep 30, 2003
Posts: 150
Thanks but I'm still not "gettin' it". I didn't have an underscore in my Onload but I decided to take everything out of the logout except Onload window.close() and still nothing (window stays open). I am running a JSP applcation on Tomcat. I also tried changing language from "java" to "javascript". Then it was really unhappy. Maybe it's impossible to close the window entirely in this case?


Would the browser type matter? I'm trying on MacOS X using Safari browser. My JSP backend is running on Solaris (Oracle database backend).

Thanks!
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30957
    
158

Alternatively, you could redirect to a full page version of the login screen.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Barbara Norway
Ranch Hand

Joined: Sep 30, 2003
Posts: 150
Thanks for the help. Let me think about that one because actually it just opens the initial window in the center frame of the application. This happens even if I just call the index.jsp from the tree.js menu item "logout". *sigh*

I just wish the session would invalidate AND the window would close. Otherqise, if the person logs on from the frame the application comes up with the main frame including a new small version of the side navigation menu. It's not usable. If they log out again and log back in, it makes a third version inside the outer two.
Barbara Norway
Ranch Hand

Joined: Sep 30, 2003
Posts: 150
Oh, I just saw Bear's comment about clowsing the browser on the user. What I want to do is totally
close the application if the user clicks on "logout" on the navigation menu (xtree.js). It would be ideal if they chose "logout" and it invalidated the session and then gave then the entire screen as a login as they see if they type the URL to log on in the first place but that's optional. The users are all the members of our lab ( about 20). I just want to be sure that they aren't still active in the application after they've logged out and also that they don't get a kludge of screen real estate with the old navigation menu on the left and successively smaller versions within the original.

Thanks again.
Barbara Norway
Ranch Hand

Joined: Sep 30, 2003
Posts: 150
Hi,

In case I wasn't clear:

What I have at this point is a new window opening that allows users to login again and the page is fine (without frames). What I want to do is have the original window close (the one where they had logged out).
The code I have is:

<%@ page language="java" %>
<html>
<head></head>
<body on_Load="window.open('index.jsp?reason=nologin');mainframe.close();topframe.close();leftframe.close()">
<%
%>
</body>
</html>
(I had to add the underscore to the "onload" to be able to post this)

I even read something that made it sound like you couldn't close the original window

I hope that's not true.

Thanks very much for your help so far and your anticipated help.

farmkitty
Barbara Norway
Ranch Hand

Joined: Sep 30, 2003
Posts: 150
Hi, does anyone know the answer to this one? My last message's question: Can the original window be closed? Thanks!
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5018
    
    8

Perhaps you are banging your head against the wrong wall, so to speak. Correct me if I'm wrong but it seems to me that what you want is not so much to close the window but rather to avoid bringing up content in a frame: "If the user clicks on another menu item, a "min-version" of the original login window pops up in the main frame (bad)". An alternative approach would be to get rid of the frameset altogether. I'm not a JavaScript expert but you could try setting the main document.location to an appropriate url.


Junilu - [How to Ask Questions] [How to Answer Questions]
Barbara Norway
Ranch Hand

Joined: Sep 30, 2003
Posts: 150
Hi. Have I asked this question in the wrong forum? I'm a beginner and I don't understand the latest response. Should I ask this in the beginner Java forum? If this is the right spot, would somebody be able to give me a code sample to help me close the original window (the new one displays the original non-frame login window), or, as the latest response suggests (sounds good but I don't know how to do it) - redisplay the contents of the first window without frames, just the original login window.

Thanks!
P.S. This isn't for a class. I'm at work and am trying to debug a humungous JSP application (i'm an Oracle DBA/Unix sys admin but they asked me to help out with an app that has never worked). I'm managing to tease out all the problems with the transactions (insert, modify, delete, edit, etc.) but this issue has me stumped (I need JavaScript here I guess).

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

Yes, this is the right place. But to tell you the truth, I really have no idea what it is you are really trying to accomplish, and I don't have the time to go back and try to piece it all together from the previous reponses. Perhaps you can start out again and carefully describe your window and page hierarchies, and what it is you are trying to do with it. From previous discussions, I can't tell which windows and pages you are referring to in your questions.
[ July 13, 2004: Message edited by: Bear Bibeault ]
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Originally posted by Junilu Lacar:
try setting the main document.location to an appropriate url.


When the user logs out, send back a page with something like this in the body onload event
window.top.location='myloginpage.jsp'

maybe
<body on_load="window.top.location='myloginpage.jsp'">

Incidently there is a JavaScript forum on this site too.


The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
Barbara Norway
Ranch Hand

Joined: Sep 30, 2003
Posts: 150
Thanks Sonny that worked like a charm! I was just getting ready to repost my question with all the necessarily detail and clarity when I saw your message. Also thanks very much to Jeroen, Bear, Jeanne, and Junilu for all their help. It's obvious I don't know much at all about Javascript but I'll learn!

Thanks again.
Barbara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Closing original window when logging out