How can I save a file (pdf) in the cache of a browser (IE 6) in a user's computer? I am using
Servlet and
Tomcat 4.1.24. PDF file is sitting in server (remote computer) under a URL space.
The idea is to NOT to download the pdf file on user's computer (from the remote server) if the user has a cached copy of the pdf file and pdf file in the server is the same as the pdf file in the browser. If cached pdf is different from pdf in browser, or, if the user does not have that pdf file in cache, then download pdf file from the server.
Can I come up with a way to use Cookie class? Cookie class does not have an API which will let me save a File/Object in it. I could have saved the pdf file in the Cookie with 999999999 setMaxAge. Is storing that pdf file in session the only choice? I do not see session serving my purpose - session should not be valid for a longgg duration e.g. week or month.
Also, how would I create a file given a URL to that file.
URL fileInServer = new URL("http://www.myDomain.com/myWebApp/PDF/my.pdf");
URLConnection conn = fileInServer.openConnection();
Does getContent() help and what are the steps after that?
Any help with the source code will be appreciated.
Thanks,
Sam
sgho@aol.com