my dog learned polymorphism
The moose likes Servlets and the fly likes getSession Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "getSession" Watch "getSession" New topic


ahamed irshad
Ranch Hand

Joined: Feb 26, 2010
Posts: 31

can anyone explain me request.getSession() with a simple example?thanks in advance

You can do anything, but not everything
David Newton

Joined: Sep 29, 2008
Posts: 12617

What specifically don't you understand? And what would an example look like other than setting a reference to it?
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Lets go:

you get a new session if doesnt exists.

If you do

if the session doesn't exist it wont creat one.

You can use session to store objects to navigate beetwen the requests. Like an user attribute.

C ya

[] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
I agree. Here's the link:
subject: getSession
It's not a secret anymore!