This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to attach/Detach cookies?

 
Shyam kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to invoke a website(login/logout) and attach/detach cookies using java....I'll appreciate any help possible´┐Ż..
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can add and get cookie using HttpServletResponse, HttpServletRequest

In JSP,

1. you can add cookie using response implicit object.



2. you detach cookie by setting maxAge(maximum time).


3. you can get the added cookie using request implicit objects.

Cookie[] cookie = request.getKookies();

4. you can replace cookie with using key with different value (which will replace cookie with new value).

hth,
 
Shyam kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thans Prabhu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic