• 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

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..!!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic