I am new to JSP & servlets. I am unable to understand the output of the 'CheckSession' (code given below) servlet. If i access CheckSession directly it gives Cookie Array length as 1. But if i first go to TestSession which forwards request to jsp(the jsp does nothing but has a href link to CheckSession Servlet), and from jsp to CheckSession, the cookie length is 2. I dont understand why its 2. Please help.
The output when i view CheckSession through TestSession servlet is:
Here is the output: check 2 Bhanwala
The output when i view CheckSession directly is:
Here is the output: check 1 Bhanwala
I printed all the cookies in output in CheckSession servlet. For the first output the JsessionID and its value is in the output along with the value 'bhanwala' which i set myself. Can you tell me why jsessionID is there for first output and not for 2nd.
Joined: Mar 20, 2011
I think my question can be answered if it is clear when the JsessinID is added in the cookie. From my above two output it looks like Jsession ID is added in the cookie when the 2nd request comes from the same client for the same session. But not sure if this is correct
subject: Unable to understand output of these servlets