i learning session in servlets , doing code stuff. saw this:
i invoked servlet using url mapping. is:
http://localhost:8080/servletsessionproject/sessionlearningpath
the servlet code simple:
httpsession session = request.getsession();
now, simple code (i used doget()
), opened cookies in chrome, this:
chrome://settings/cookies
there was able see cookie set.
i confused. in code called request.getsession()
. why simple statement setting cookie in browser? sure cookie not there before.
how possible?
yes. session set in cookie. jsessionid
web application trace user session using cookie not method. when user not have session web application , request.getsessin();
called, servlet api create new session , session id. session id used uniquely represent , trace user session. session id sent in response set cookie request. why seeing cookie after 1 request cycle.