This discussion is archived
6 Replies Latest reply: Apr 24, 2013 11:33 PM by gimbal2 RSS

Session not Killed in jsp

Subramanian Meyyappan Expert
Currently Being Moderated
hi folks,

i h'd a index.jsp in that page logout is available. while hitting the button . i want to invalidate all the session variable which i used. but it is not happening.
<html:image src="/x/images/logout1.png" onclick="logout()"> </html:image>
<script type="text/javascript">     
               function logout()
               {
               document.forms[0].action =  "/x/x.do?method=dologout";
            document.forms[0].submit();
               }
               </script>
public ActionForward dologout(ActionMapping mapping, ActionForm form,
               HttpServletRequest request, HttpServletResponse response) {
               try {
               DynaActionForm logoutform = (DynaActionForm) form;
               HttpSession hs = request.getSession();
               hs.invalidate();
               return mapping.findForward("login");
               } catch (Exception e) {
                    System.out.println(e);
               }
          }
even when i logout. then i start from new session means., session values continues from previous session. not killed.
  • 1. Re: Session not Killed in jsp
    Subramanian Meyyappan Expert
    Currently Being Moderated
    when i searched over the google i get this.
    http://www.coderanch.com/t/531984/Struts/session-struts

    in the above one of the person suggest this http://www.roseindia.net/struts/struts2/struts2-login.shtml

    remove the session variable is not right way? i hope so..
  • 2. Re: Session not Killed in jsp
    gimbal2 Guru
    Currently Being Moderated
    session.invalidate() works. So if you are "seeing" old values, perhaps it is simply a browser caching issue?

    Assuming you are 100% positive that the code is actually executed of course. It seems like you are doing some javascript hackery that may screw up whatever tech you're using (Struts, perhaps?).
  • 3. Re: Session not Killed in jsp
    Subramanian Meyyappan Expert
    Currently Being Moderated
    It seems like you are doing some javascript hackery that may screw up whatever tech you're using (Struts, perhaps?).
    am using javascript is this a problem? well, yes you 're right stack tech am using - struts1.3
  • 4. Re: Session not Killed in jsp
    gimbal2 Guru
    Currently Being Moderated
    user707 wrote:
    It seems like you are doing some javascript hackery that may screw up whatever tech you're using (Struts, perhaps?).
    am using javascript is this a problem? well, yes you 're right stack tech am using - struts1.3
    Well is the Java code executed? Put a System.out in there or use the debugger of your IDE to see it. I'm guessing that the answer is in fact no and that yes, you manually meddling with javascript is causing the problem. Struts is a framework, do it the struts way. Which means you need to find out what the struts way is.

    And you should ask struts questions in a struts forum, especially legacy struts stuff.
  • 5. Re: Session not Killed in jsp
    Subramanian Meyyappan Expert
    Currently Being Moderated
    Well is the Java code executed? Put a System.out in there or use the debugger of your IDE to see it. I'm guessing that the answer is in fact no and that yes, you >manually meddling with javascript is causing the problem. Struts is a framework, do it the struts way. Which means you need to find out what the struts way is.
    By the way java code is executed, S.O.P is Printing it does the job. but it doesnt in validate the session.. most of the time am using javascript to do client side it doesnt works perfectly. i understood this in earlier. " finally i conclude that javascript is the problem"... thanks man.
    And you should ask struts questions in a struts forum, especially legacy struts stuff.
    i searched out a lot about struts forum before am here. i cant find the appropriate area to post my question. if you dont mine can you do me a favour.
    if i had oracle doubt i can come to otn, otn people will assist me. if i have struts doubts means where do i ask? is there any professional site/forum to ask.
  • 6. Re: Session not Killed in jsp
    gimbal2 Guru
    Currently Being Moderated
    Whatever information you need is on the struts website. OTN is not your personal information service, as a developer and a professional (even a beginning professional) it is a big part of your job description to be able to figure out stuff. In the 15 odd years I've been doing this programming trick there is -nothing- I couldn't ask a colleague, find in a book or through google or whatever search engine was available at the time. Nothing. I have never needed to ask in a forum where to look for information, its all readily available. All you need to do is make the effort to go look for it.

    Really, its that simply.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points