Search code examples
javaframesethttpsession

How to reload the frame and session value is not getting removed


i am using the loginpage which does not come in frame but once i logged in all the pages are in framset and when i try to log out (the logout link is there in the frame) only that specific frame is reloaded and the login page comes to that frame. but i want the login page to be displayed where no pages should be displayed.

i remove session values like this, but when i refresh the page all the valuse are there in pages which are there in the frame.

public void sessionRemove(HttpServletRequest request,HttpServletResponse response){
        request.getSession(true).removeAttribute("userDetails");

        /**
         * Remove the Session Object.
         */
        Enumeration enumSessionObj = request.getSession(false).getAttributeNames();
        while(enumSessionObj.hasMoreElements()){
            String enumObj = enumSessionObj.nextElement().toString();
            request.getSession(false).removeAttribute(enumObj);
        }

        /**
         * Remove the Cookies.
         */
        Cookie[] cookies = request.getCookies();
        for (int i = 0; i < cookies.length; i++) {
            Cookie delCookie = cookies[i];
            delCookie.setMaxAge(0);
        }
    }

How to do this ,

Please help


Solution

  • Could you try?:

        request.getSession().invalidate();
    

    Could you print the time in one of those frames. I think your problem could be cache related.

    If you session is invalidated you can do a number of things. Ex. fowarding the user to another page. Or refreshing your frames with javascript just like this.

                window.parent.MY_FRAME_NAME.location.reload();
    

    Good luck;