hey guys, me again !! I have created a session using HttpSession session = request.getSession(true). So far, so good, is working smoothly. 1o.) I'm using a servlet and I need to retrieve some values from the session. I'm doing it this way: HttpSession session = request.getSession(true) String someString = session.getAttribute("att") Am I creating a new session if I do this?? or Am I retrieving the current session (what I actually want to achieve)?? 2o.) How do I ask if the session is already created? using isNew()? or extracting some value from the session and asking if it is null? thankssss
I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
posted 13 years ago
1) request.getSession(true) retreives the current session if it was already created before otherwise it creates a new one (first time in). 2)There are a number of ways to determine if a session is new. isNew() will work, so will extracting some value from the session and asking if it is null provided you put it into the session before. A third option is checking for request.getSession(false) == null. . .