How we can check in particular page the session will be
alive or not

Answer Posted / ruchi

when we create session , we write
HttpSession session= res.getSessionn(true);
this checks whether there is a session bind on associated
request.if yes then it returns reference to session
object,otherwise create a session for associated request.

but if we want check that session is alive or not then we
write
HttpSession session= res.getSessionn(false);
this checks whether there is a session bind on associated
request.if yes then it returns reference to session
object,otherwise it returns null reference.

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why are servlets used?

532


Why is a constructor needed in a servlet even if we use the init method?

603


List some life cycle methods of a servlet.

589


What are the steps that are involved in using the httpservlet class?

572


What are the steps involved in placing a servlet within a package?

589






What is a servlet engine?

544


Why the container loads server at the application startup and how?

579


What is servlet looping or chaining?

658


What is the major difference between context parameter and context attribute?

595


How to rectify errors in java servlet while compilation?

517


How can you create a session in servlet?

595


How is an application exception handling is done using a servlet?

539


What do you mean by httpservlet and how it is different from the genericservlet?

536


What are the new features added to servlet 2.5?

592


What is the use of java servlet api?

599