Hi PID:

Say the object from  the servlet contains the string "Hi the date is : Jun 18, 
2009 12:30:19 PM"

When I call the first time
             URL urlobj = new URL(servletURL);
             HttpURLConnection con = (HttpURLConnection) 
urlobj.openConnection();

The object returned from the request  contains the string:
"Hi the date is : Jun 18, 2009 12:30:19 PM"

When I call it again, say 4 seconds later, I prefer:
"Hi the date is : Jun 18, 2009 12:30:19 PM"
not
"Hi the date is : Jun 18, 2009 12:30:23 PM"
I do not want to have the 2nd request call the servlet, but instead use local 
cache/browser cache since it is still fresh...


--- On Thu, 6/18/09, Pid <p...@pidster.com> wrote:

From: Pid <p...@pidster.com>
Subject: Re: object serializable and caching???
To: "Tomcat Users List" <users@tomcat.apache.org>
Date: Thursday, June 18, 2009, 8:53 AM

Paul M wrote:
> 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?

Caching what?

p


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



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




      

Reply via email to