how to delete cookie and temporary internet files using java
posted 9 years ago
Hi, I wrote a JSP page after sucessfully logging into the application. In that JSP page i have a logoff option. When user clicks on logoff button all the cookis and temporary internet files for that particluar browser, i want to delete it. So can any one please help in writing that peace of java code??
The JSP is run on the server and outputs a HTTP response, probably made up of HTML but possibly binary content instead. Whatever this content is, only it gets sent to the client and only it could possibly effect the broowser cache (or the HTTP header, but we'll get to that).
So on the client, you want something which runs on the client side to clear the cache for the current site. I'm pretty sure it can't be done and the security measures would block you. However if all communication was in HTTPS and the user had the option selected to prevent caching secure content set then the cache wouldn't exist, but again you can't enforce this setting. If you had already specified that each piece of content should not be cached as you sent it to the client it would not be cached, but this requires setting HTTP headers to instruct the browser not to cache the content.
With respect to cookies, if it is a session cookie it should be memory only and not resident. You can get all of the cookies from the request and set them to expire immediately and they'll disappear. It's all in the API and can be done on the server.