File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes getSession(false); Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "getSession(false);" Watch "getSession(false);" New topic


Vipul Gulhane

Joined: Mar 28, 2011
Posts: 20
What happen if I did Like this

HttpSession ses=resquest.getSession(false);
Santhosh ayiappan
Ranch Hand

Joined: Jan 30, 2007
Posts: 80

returns the session obj if the session is valid, else you will get null
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33124

What do you mean? You get a reference to the session if it exists. But that's in the JavaDoc so I'm guessing you are asking something more specific.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
bagaria kushal

Joined: Mar 29, 2011
Posts: 19
This will check whether Session already existed for the request or not. If it existed then it will return the already existed Session. If Session is not already existed for this request then this method will return NULL, that means this method says that the request does not have a Session previously
I agree. Here's the link:
subject: getSession(false);
It's not a secret anymore!