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

What is the difference between context parameter and context attribute?

698


What is called Scriptlet?

799


What is Request Dispatcher?

1039


What is servlet configuration?

732


Differentiate between get and post?

862






How to get the path of servlet in the server?

698


What’s the difference between forward() and sendredirect() methods?

747


Can we use the constructor, instead of init(), to initialize servlet?

794


Why do we have servlet wrapper classes?

762


Write a hello world program using servlets.

770


Why is http protocol called as a stateless protocol?

703


What is servlet attributes and their scope?

754


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

803


What is difference between PrintWriter and ServletOutputStream?

964


How the typical servlet code look like ?

837