Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
I am unable to understand the difference between 2. getSession() create a session if there is no session exist and getSession(boolean create) also creates a session if there is no session (if we pass TRUE). If the later function can perform the same functionalities then why the prior function is needed? or i am mis-interpreting the meanings and purpose of both function. Please explain out!
The difference between <b>failure</b> and <b>success</b> is often being <b>right</b> and being <b>exactly right</b>.
getSession(false) will not return a new Session if one does not already exist.
If your application needs to explicitly create and initialise a session, or you decide to use the existence of a session as detection of a logged in user, then you don't want to create sessions by accident. It is also useful as it can tell you where a user entered your application, ie if session==null then they didn't request another page before this one.
The implementation is up to the container builders but it seems like a pretty safe bet that that's how they do it. If you really want to know, you can always grab the source to Tomcat, Jetty, Resin, or any other open source container and see for yourself. [ July 24, 2007: Message edited by: Ben Souther ]