aspose file tools*
The moose likes Servlets and the fly likes j_security_logout issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "j_security_logout issue" Watch "j_security_logout issue" New topic
Author

j_security_logout issue

Ven Red
Greenhorn

Joined: Nov 10, 2007
Posts: 6
Hi All

I am trying to logout the application using j_security_logout and with in the javascript i am looking for confirmation from the user and if the user cliecks confirm the application will logout, if not application should stay where it is now. But the application is being submitted and going to application context root. Is there any way that i can stop this action? Please help.

Belos is my code

Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 273

So, you want the browser window to close after the form is submitted, but it's not doing that? I think what happens is when you submit the form, the browser loads the form's POST response, ignoring the rest of the Javascript. I think you need to send the POST request via Ajax, and then when you get the response, close the browser window.
Ven Red
Greenhorn

Joined: Nov 10, 2007
Posts: 6
Let me explain little more clarity.

I am trying to logout the application and as soon i click on logout link, java script promtps for confirmation. If user confirms, the application will be logged out and prompts for closing the window, and if clicked yes the window will be closed. This is happy scenario.

When the user clicks logout and in the prompt if the user chooses 'No' (no logout scenario), the application still submits to the context root and goes to the index.jsp page.(Java script doesn't stop submitting).But i want the applicaion should stop submiting to any action adn let the user stays in the same page.

Hope i am clear this time.
Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 273

So...if they click "No", the browser navigates to a page you don't want it to go to? You just want nothing to happen when "No" is clicked?

Can you post the code that calls goLogOut()? If it's being called in a link, you have to add "return false;" to the onclick event, or else the browser will navigate to the URL specified in the "href" attribute:
Ven Red
Greenhorn

Joined: Nov 10, 2007
Posts: 6
Thanks for the quick reply.

return false; did not work for some reason.

Since i am using struts, tiles, request.getRequestURl() returns some jsp page rather than some action(abcd.do etc), so end up in WEB-INF/layouts/abcd.jsp
is there any way i can get the current action or current url some thing like https://localhost:9444/ABCD/XYZ/abcd.do

Thanks for your help.
Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 273

Ven Red wrote:Since i am using struts, tiles, request.getRequestURl() returns some jsp page rather than some action(abcd.do etc), so end up in WEB-INF/layouts/abcd.jsp
is there any way i can get the current action or current url some thing like https://localhost:9444/ABCD/XYZ/abcd.do


I don't know what this has to do with the original problem.. Again, can you post the code that's calling goLogOut()?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: j_security_logout issue