You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Paul M <pj...@yahoo.com> on 2009/06/18 17:19:27 UTC
object serializable and caching???
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.)
Re: object serializable and caching???
Posted by Pid <p...@pidster.com>.
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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org