• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Logout problem

 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1637
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is there any mistake in my action class,struts configuration file and jsp file
 
Swastik Dey
Rancher
Posts: 1637
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1637
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1637
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Thanks swastik, I tried it. but there is no change. I don't know whats the wrong with the application. Thanks.
 
Swastik Dey
Rancher
Posts: 1637
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1637
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we have a look on the frameset page?
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1637
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1637
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Thanks i got it..
 
Swastik Dey
Rancher
Posts: 1637
6
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome.
 
Luis Mesa
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic