File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes How to attach/Detach cookies? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to attach/Detach cookies?" Watch "How to attach/Detach cookies?" New topic

How to attach/Detach cookies?

Shyam kumar
Ranch Hand

Joined: May 21, 2006
Posts: 146
I want to invoke a website(login/logout) and attach/detach cookies using java....I'll appreciate any help possible�..
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

you can add and get cookie using HttpServletResponse, HttpServletRequest


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).


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />
Shyam kumar
Ranch Hand

Joined: May 21, 2006
Posts: 146
Thans Prabhu
I agree. Here's the link:
subject: How to attach/Detach cookies?
It's not a secret anymore!