• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to understand output of these servlets

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Lasagna is spaghetti flvored cake. Just like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic