wood burning stoves 2.0*
The moose likes Struts and the fly likes Logout problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Logout problem" Watch "Logout problem" New topic
Author

Logout problem

Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98
Hi,

I am developing an application in struts with logout functionality. But logout functionality is not working.

My application page contains 3 frames. Below am showing my frames. The frame2 contains logout link. when i click on the logout link it is displaying the message like "Successfully logged out of site" in other frame i.e with in the application only, but it is not closing the application. Please give me some solution. Please help me.

----------------------------
(frame1) site name
----------------------------
(frame 2) |
contact us | output of contact us
logout |
----------------------------
copy right information (frame3)
----------------------------

Thanks in Advance
Lalitha

Here is my Action class

LogoutActionClass.java
----------------


struts-config.xml
-------------


logout.jsp
-----------

Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1474
    
    6

Lalitha Kotha wrote:but it is not closing the application


What exactly do you mean by not closing the application? Do you wish to close the browser window?


Swastik
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98

I mean that, when ever we click on logout link, it must come out of the particular page and display the success message. But in my case it is showing the message in the application only. Even after clicking logout also am able to click on other links in the page.
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98


Is there any mistake in my action class,struts configuration file and jsp file
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1474
    
    6

Once you click logout does it show the output of logout.jsp (you have been successfully logged out. Thank you. and link to login again) in frame2 where you had the logout option?
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98

Ya it is showing the output of the logout.jsp page.
I think you saw my example application page i given above. It is displaying the output just beside the logout link.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1474
    
    6

You problem seems to be with frames. The forward action is opening logout.jsp in the frame from where the request came, and this is obvious, on the other hand I don't think struts has any option where you can specify the target frame. So it seems that you may have to look for some java script code.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1474
    
    6

Could you please try this once?

Create a file called logout1.jsp and map the action to logout1.jsp.

logout1.jsp
-----------


This is my suggestion. There might be better solutions too.
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98


Thanks swastik, I tried it. but there is no change. I don't know whats the wrong with the application. Thanks.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1474
    
    6

By frames do you mean, <Frameset> or you something else. If frameset it should have worked, and after making changes did you restart server? If not restart it and also clear cookies, history etc.
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98

ya swastik, i used <frameset> tag only to create the frames in application. And i restarted the server and redeployed the application.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1474
    
    6

Can we have a look on the frameset page?
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98
homepage.jsp
-----------


In the above, toppage.jsp contains just title
contentpage.jsp contains some links and also logout link
bottompage.jsp contains copyright information
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1474
    
    6

Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98

Thank you very much swastik. It worked. But when i click on back button in browser, it is again showing the same application.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1474
    
    6

Probably apart from invalidating the session. You need to remove the user info from session. When the back button button is pressed, the page once again gets loaded, here you can check if you don't valid information about the user retrieved from session, redirect him back to the login page.
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98


Thanks i got it..
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1474
    
    6

You are welcome.
Luis Mesa
Greenhorn

Joined: May 12, 2014
Posts: 1
This may be an old post but for someone reading and having the same or a similar problem, the solution might be to ALSO call request.logout() to remove the userPrincipal from the request. If your forward page (after the logout action) is also secured by the authorization mechanism but the userPrincipal is not removed from the request then no login prompt will be presented and it seems as if nothing happened. Also a good idea is to use redirect="true" in the forward to make sure you "leave the past behind".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logout problem