I have a "web service" that writes the following out from a servlet.
         ObjectOutputStream outToCaller;
         response.setContentType("application/octet-stream");
         response.setHeader("Cache-Control","public");
         response.setHeader("Cache-Control","max-age=10");
         
         try
         {
             outToCaller = new                           
ObjectOutputStream(response.getOutputStream());
             outToCaller.writeObject(tcos);
             outToCaller.flush();

....

I read this from the following CONSOLE application.
            URL urlobj = new URL(servletURL);
            HttpURLConnection con = (HttpURLConnection) urlobj.openConnection();
    //        con.setDoInput(true);
    //        con.setDoOutput(true);
            con.setUseCaches(true);
            con.setDefaultUseCaches (true);
            con.setRequestProperty ("Content-Type", "application/octet-stream");
            con.setAllowUserInteraction(false);
            con.setRequestMethod("GET");
            InputStream is =(InputStream) con.getInputStream();
            
            ObjectInputStream ois = new ObjectInputStream(is);

            
            Serializable objs = (Serializable)ois.readObject();
            if (objs instanceof SecondTestComplexObjSer) {
                tcos = (SecondTestComplexObjSer)objs;
                System.out.println(tcos);
            }
So I have two questions:
How do I set up caching from my "Web Service" servlet?
And how do I properly test that it is working? 
(Note: tcos has a timestamp string, so I was expecting to see some old times 
since I set the age to 10 sec. I had a sleep set up of 4 sec in console app.)




      

Reply via email to