Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to understand output of these servlets

 
bhanwala Anish
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Below are the two Servlet's codes:

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64980
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check to see what the two cookies were? This could give you a clue as to where they came from.
 
bhanwala Anish
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
bhanwala Anish
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic