J2EE: Useful methods of HttpSession
1. How to get the session id from HttpSession? you can retrieve session id by calling getId() on the HttpSession object. HttpSession session = request.getSession(); sessoin.getId(); // returns session id. 2. How to know whether the session is new or old? To know whether the session is new or old, you can use isNew() on HttpSession object. It returns true, if the session is created during the current request, which means the user's browser has not yet received the session id. HttpSession session = request.getSession(); boolean isSessionNew = session.isNew(); 3. How to change the maximum inactive interval time for a session? setMaxInactiveInterval() enables you to change the inactivity window. This overrides the value you set in in web.xml for that specific session. you can make it shorter or longer based on your requirement. Why do u want to change inactive interval? Lets consider some scenario, where you want to increase the inactivity interval for some ...