Q : In session created by server with client(browser) How
can server find that request coming is belong to new
session OR belong to session that is timeout.

Answer Posted / subhash

getSession() returns a session regardless of there's apre-
existing session.Since we always get back an HttpSession
instance back from the method,the only way to know if the
session is new is to ask the session itself:

HttpSession session=request.getsession();

if(Session.isNew())
{
out.println("A NEW SESSION");
}
else
{
out.println("WelCOme Back");
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of?

610


What is the purpose of ?

591


Why are jsp pages preferred for creating web-based client program?

620


How do I save a jsp file?

596


What do you know about jsp tags?

599






How to pass information from jsp to included jsp?

608


How is scripting disabled?

610


What is expression language injection?

585


What is session tracking in jsp?

618


How can we retrieve warnings?

603


How to run java program in jsp page?

591


What is the use of requestdispatcher?

600


What is jsp language?

575


How are the jsp requests handled?

589


Where is jsp used?

574