Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
med medin
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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 :
Server

Client
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!