File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes What is wrong with my cookie? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "What is wrong with my cookie?" Watch "What is wrong with my cookie?" New topic
Author

What is wrong with my cookie?

Joe Wang
Greenhorn

Joined: Sep 19, 2003
Posts: 3
Hi people,
I used following code to test Cookie:
........
public void doGet(... req, ... res)throws ...,..{
HttpCookie cookie = new Cookie("userName","someOne");
res.addCookie(cookie);
res.setContentType("text/html");
//Next, get PrintWriter to send response to client
}
.....
The code was successfully compiled and run without any exception.
But, when I checked the temporary directory of IE, where the cookies should be stored, I could not find any cookie file.Why?
Does anybody can tell the reason?
I run it at TomCat on my PC. URL is http://localhost:8080/test/Coo
???
[ October 11, 2003: Message edited by: Joe Wang ]
Sathya Sankar
Ranch Hand

Joined: Sep 16, 2000
Posts: 67
Hi Joe,
Cookies will be stored on a per session basis if their expirati0on time is not set. This means that the cookie will be stored only in the RAM and not onto the hardisk. Hence when the last browser window of that session closes, the cookie will be lost forever.
You can set the cookie age using the setMaxAge method of the Cookie class. Exammple code,
Ciao,
GSS


SCJP, SCJD, SCWCD 1.3, SCWCD 1.4, SCBCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is wrong with my cookie?