• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session from HF S&J

 
sylvia greene
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pg 233 HF S&J


Passing "false" to request.getSession(false) means the method returns a preexisitng session, or null if there is no session associated with the client.


So i made a JSP page and put the following line in it



I was expecting "null" but it gave me

org.apache.catalina.session.StandardSessionFacade@144b18f


Does that mean a session was already existing?
 
Mikalai Zaikin
Ranch Hand
Posts: 3371
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you are right, the session was already existing.

By default, every JSP participate in session.

Even there is a best practice rule to disable explicitly session in JSP if you don't need it - this saves server's resources.

If you wish to get "null" value when output session object, try to add the following code snippet in your JSP:



More details you can read on this page of SCWCD 1.4 Study Guide.

best regards,
MZ
 
sylvia greene
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot
 
Mikalai Zaikin
Ranch Hand
Posts: 3371
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the JSP now print "null" to the client ?

regards,
MZ
 
sylvia greene
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mikalai Zaikin:
Does the JSP now print "null" to the client ?

regards,
MZ


yes it does
thanks again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic