aspose file tools*
The moose likes Servlets and the fly likes Unable to understand output of these servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unable to understand output of these servlets" Watch "Unable to understand output of these servlets" New topic
Author

Unable to understand output of these servlets

bhanwala Anish
Greenhorn

Joined: Mar 20, 2011
Posts: 5
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

Joined: Jan 10, 2002
Posts: 61437
    
  67

Did you check to see what the two cookies were? This could give you a clue as to where they came from.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
bhanwala Anish
Greenhorn

Joined: Mar 20, 2011
Posts: 5
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

Joined: Mar 20, 2011
Posts: 5
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Unable to understand output of these servlets