• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Closing original window when logging out

 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to close the window in a piece of Javascript.
Send back a URL to a page:


remove the _
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't closing the browser on the user strike you as a tad bit rude?
 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34863
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternatively, you could redirect to a full page version of the login screen.
 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, does anyone know the answer to this one? My last message's question: Can the original window be closed? Thanks!
 
Junilu Lacar
Bartender
Posts: 7605
54
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65124
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic