No need to reply-to-all. I'm on the mailing list, I don't need to get the mail twice.
If you're sending the data like this you're responsible for setting all of the various headers. If the client can handle cached content it will send headers indicating that it can. Try adding some code to check what http headers the client is sending. If you've not modified the content since the last request, and the client sends some headers that indicate what it knows about the URL and they match appropriately, you send a different status: // set headers if (variousCriteria) { httpResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED); // don't send body } else { httpResponse.setStatus(HttpServletResponse.SC_OK); // send body } Reading this is a good idea. http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html p Paul M wrote: > 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 > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org