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.




Answers were Sorted based on User's Feedback



Q : In session created by server with client(browser) How can server find that request coming is b..

Answer / vanita

when client request for the first time, container generates
a session id for that perticular user. server process the
request and sends the response and also sends that sessionID.

for next request from the same user, that session id must be
sent back to the server so that server can fetch the
sessionID from request and match with previously generated
IDs , if match then it associates this next request with
the previous session.

This transfer of sessionId b/w server and user can be done
via 2 ways -

1. By cookies
2. By URL rewritting

In case if browser doesnt support cookies, then only the
second method is used.

Is This Answer Correct ?    4 Yes 0 No

Q : In session created by server with client(browser) How can server find that request coming is b..

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

Q : In session created by server with client(browser) How can server find that request coming is b..

Answer / raj

While client is requesting to server, in requested body
session id will go to server. then the server will treated
as old client is connecting/.

Is This Answer Correct ?    2 Yes 1 No




Q : In session created by server with client(browser) How can server find that request coming is b..

Answer / rajib

import javax.servelet.*;
public MyServelet extends HttpServelet{
public void doGet(HttpServeletRequest
req,HttpServeletResponse res)throws ServletException,IO
Exception{
res.setContentType("text/html");
PrintWriter out=res.getPrintWriter();
out.println("for trac session0");
HttpSession sess=req.getSession();
if(sess==null){
out.println(Old session not exist );
}else{
HttpSession session=request.getSession(true);
out.println("new Session Created.");
}}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer



More JSP Interview Questions

how to u se in jsp

0 Answers   Google,


what are the alternate way to use the scriplet in jsp.

1 Answers  


What are the implicit objects?

2 Answers   IBM, Sigma IT,


How do I set password expire time period?

4 Answers  


which is the place to learn java in chennai..

3 Answers  






what will happen if we disable cookies in the web page?

7 Answers  


What is JSP?

3 Answers  


What is the difference between <jsp:forward> and sendRedirect?

6 Answers   HCL,


How to find the hidden answers present in an online exam?

3 Answers  


hpcl information systems officer 2008 Question Papers or any last previous questions papers thanks in advance shyamprasad71@gmail.com shyamprasad71@gmail.com

0 Answers   HPCL,


what type of question will be asked in the interview in this software field?????///

2 Answers   wbsedcl,


How do I set password expire time period?

1 Answers  






Categories