X
xarora
Hi !
Just started learning Java Servlets and so I have a newbie question:
What's the difference between:
HttpSession session = req.getSession(true);
and
res.addCookie(Cookie) ?
It seems both are used to track session. So, are they both doing the
same thing ?
I read an article "Servlet Essentials" from
http://www.novocode.com/doc/servlet-essentials/chapter2c.html .
"It says Cookie is a string (in this case that string is the session
ID) which is sent to a client to start a session. If the client wants
to continue the session it sends back the Cookie with subsequent
requests."
And then it describes HttpSession session = req.getSession(true);
So, does this mean this line of code is creating a cookie (if it
already doesn't exist). And we could replace that line with
res.addCookie(Cookie) ?
I am just learning Java Servlets etc. so I have all the newbie
questions ! Your help would be greatly appreciated.
Thanks a lot!
xarora
Just started learning Java Servlets and so I have a newbie question:
What's the difference between:
HttpSession session = req.getSession(true);
and
res.addCookie(Cookie) ?
It seems both are used to track session. So, are they both doing the
same thing ?
I read an article "Servlet Essentials" from
http://www.novocode.com/doc/servlet-essentials/chapter2c.html .
"It says Cookie is a string (in this case that string is the session
ID) which is sent to a client to start a session. If the client wants
to continue the session it sends back the Cookie with subsequent
requests."
And then it describes HttpSession session = req.getSession(true);
So, does this mean this line of code is creating a cookie (if it
already doesn't exist). And we could replace that line with
res.addCookie(Cookie) ?
I am just learning Java Servlets etc. so I have all the newbie
questions ! Your help would be greatly appreciated.
Thanks a lot!
xarora