Win a copy of Terraform in Action this week in the Cloud forum!
  • 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

Servlet can't send cookie for the first request by client

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to create a cookie wich keeps the number of visits on persistent storage on client side, my server is simple servlet wich runs on Apache Tomcat 8.0,
- when the client sends a cookie already initialized with counter (for example counter = 12), the server increments the counter and sends back new cookie with new counter (counter = 13) and it's saved correctly by the client on my hard drive. This works fine for me.
- but when the client sends a request for the first time, so no cookie is sent to server, and the server should create new cookie with counter = 0 and sends it back to client. This case doesn't work correctly and the client doesn't receive any cookie.
Here's my code example :

Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic