• 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Cookie in Servlet

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to learn the use of Cookie in Java .
What is the use of Cookie..?
Can someone give me a simple example of how to write to a cookie nd read from the same cookie..??

Thanks.
Regards,
Rahul.
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

Rahul Chandran wrote:
What is the use of Cookie..?


Cookie is used to store some temporary information on the Client side.

Rahul Chandran wrote:
Can someone give me a simple example of how to write to a cookie nd read from the same cookie..??


Have a look on HttpServletResponse and HttpServletRequest APIs for the details~!
 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rahul Chandran wrote:Hi,
I want to learn the use of Cookie in Java .
What is the use of Cookie..?
Can someone give me a simple example of how to write to a cookie nd read from the same cookie..??

Thanks.
Regards,
Rahul.



Cookie is one of the popular ways of session management. Though other mechanisms do exist.

When the client (any browser for instance) sends the request for the first time , a cookie is created, loaded with session identifier and sends back along with the response (all done behind the scenes). On subsequent requests, client would send the cookie along with the request, so that servlet can identify if the request belongs to the same old session or not.

You as a developer can also create a cookie object and stuff them with values. Ideally it is like a map having key/value pair..
 
Rahul Chandran
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks..
But an Example would be more understandable..!!
Any way Thank You All..!!
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic