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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / aseet padhi

U can use request.getSession(false); method in
HttpServletRequest interface.It returns the HttpSession
associated with this request or null if the request has no
valid session.

Is This Answer Correct ?    10 Yes 3 No

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

Answer / pratyusha

is alive()

Is This Answer Correct ?    4 Yes 8 No

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

Answer / venkata rao g

Hi ,
I think is alive() is the method of the thread.
iam assuming it is correct "if the page will be there for a
specified amount of time or until the browser will be
closed or until the user log's out" the session is there.


if u have the better solution plz send to my mail id

Is This Answer Correct ?    3 Yes 9 No

Post New Answer

More Servlets Interview Questions

explain the advantages of servlet life cycle?

0 Answers  


What is the difference between RequestDispatcher and sendRedirect?-

5 Answers   CTS,


Explain url encoding in servlet?

0 Answers  


How to get the IP address of client in servlet?

0 Answers  


Which HTTP method is non-idempotent?

0 Answers  






What is the effective way to make sure all the servlets are accessible only when user has a valid session?

0 Answers  


What is the role of the webserver?

4 Answers  


Hi friends am newbie to servlet. How code reusability easy in servlet. why not in jsp . here reusabillity means only javabeans or any thing else.

1 Answers  


Explain the architechure of a servlet?

0 Answers  


What are the mechanisms used by a servlet container for maintaining session information?

0 Answers  


When we don't write any constructor for the servlet, how does container create an instance of servlet?

2 Answers   Godrej, TATA,


Why do we use sendredirect() method?

0 Answers  


Categories