This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

URLConnection and outputobjects caching  RSS feed

p paul
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following code in a servlet:
ObjectOutputStream outToCaller;
response.setHeader("Pragma", "cache");
response.setHeader("Expires", "Fri, 11 Nov 2011 12:19:00 GMT");

outToCaller = new ObjectOutputStream(response.getOutputStream());

I call the above from a console application:

URL urlobj = new URL(servletURL);
HttpURLConnection con = (HttpURLConnection) urlobj.openConnection();
// con.setDoInput(true);
// con.setDoOutput(true);
con.setDefaultUseCaches (true);
con.setRequestProperty ("Content-Type", "application/octet-stream");

tcos is object that has say a timestamp string as follow "The time is 1:00:00"

When I initially make request from servlet, the string "The time is 1:00:00" is returned.
I was attempting to create some type of local/browser cache ability when the page is served. So that a request, say 5 seconds
later, still returns "The time is 1:00:00", not "The time is 1:00:05" . Since I sent expires to be in the future, I thought a local cache/browser cache
of the page and object would be created...But it does not seem to be working...

Any ideas
tomcat server
live http headers:
HTTP/1.x 200 OK
Server: Apache-Coyote/1.1
Pragma: cache
Cache-Control: public
Expires: Fri, 11 Nov 2011 12:19:00 GMT
Content-Type: application/octet-stream
Transfer-Encoding: chunked
Date: Thu, 18 Jun 2009 17:33:20 GMT
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!