3. For getSession(true), it will check whether there is a session already existing for the user. If a session is existing, it will return that session object, otherwise it will create a new one and returns it.
And for getSession(false), this will check whether a session exists or not. If yes, then it returns that session object, or else it will return null.
Author and all-around good cowpoke
Joined: Mar 22, 2000
1. If we set setMaxInactiveInterval(int interval) to high value,does it mean the user's information will be maintained , after a user exits a browser and reopens the browser again.
A session is only good for a single browser session just like the name implies. Note that the only user information in a session is what the programmer puts there, nothing is put there automatically.
Just to clear my doubt, How many ways we can create a session in Servlet ? Is there any other way except request.getSession() call ?
Joined: Mar 22, 2005
As to #2, yes, you can write a servlet that way. But you'd have to duplicate everything GenericServlet and HttpServlet do, and in particular you'd need to implement the "service" method and its handling of the various HTTP methods.