Thanks Marc.
I tried both the methods you suggested. But, I am still seeing some
wierd issues with IE caching. It works perfectly in Firefox. But, IE
seems to have an issue. I have to clear the IE cache manually to make
this work.
//method1
CacheControl c = new CacheControl();
c.setNoCache(true);
return Response.ok(rows, "application/xml").cacheControl(c).build();
--response from TCPMonitor--
HTTP/1.1 200 OK
Cache-Control: public, no-cache, no-transform
Content-Type: application/xml
Content-Length: 986
Server: Jetty(6.1.9)
//method2
Response.ResponseBuilder rb = Response.ok(rows, "application/xml");
rb.header("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
return rb.build();
--response from TCPMonitor--
HTTP/1.1 200 OK
Content-Type: application/xml
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Content-Length: 953
Server: Jetty(6.1.9)
Do you know what is happening here?
I observed another browser related issue when I delete a resource. It
works just fine in FireFox. But, in IE I see the following exception,
2008-05-16 16:36:34.732::WARN: /rest/rows/delete
java.lang.IllegalArgumentException: java.text.ParseException: Expected
separator
';' instead of ','
at
com.sun.ws.rest.impl.provider.header.MediaTypeProvider.fromString(Med
iaTypeProvider.java:78)
at
com.sun.ws.rest.impl.provider.header.MediaTypeProvider.fromString(Med
iaTypeProvider.java:37)
at javax.ws.rs.core.MediaType.parse(MediaType.java:108)
at
com.sun.ws.rest.impl.model.HttpHelper.getContentType(HttpHelper.java:
63)
at
com.sun.ws.rest.impl.model.HttpHelper.getContentType(HttpHelper.java:
52)
at
com.sun.ws.rest.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.j
ava:89)
at
com.sun.ws.rest.impl.uri.rules.RightHandPathRule.accept(RightHandPath
Rule.java:96)
at
com.sun.ws.rest.impl.uri.rules.ResourceClassRule.accept(ResourceClass
Rule.java:56)
at
com.sun.ws.rest.impl.uri.rules.RightHandPathRule.accept(RightHandPath
Rule.java:96)
at
com.sun.ws.rest.impl.uri.rules.RootResourceClassesRule.accept(RootRes
ourceClassesRule.java:49)
at
com.sun.ws.rest.impl.application.WebApplicationImpl.handleRequest(Web
ApplicationImpl.java:416)
at
com.sun.ws.rest.spi.container.servlet.ServletContainer.service(Servle
tContainer.java:151)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487
)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:3
62)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.jav
a:216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:1
81)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:7
26)
at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHand
lerCollection.java:206)
at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.
java:114)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:1
52)
at org.mortbay.jetty.Server.handle(Server.java:324)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:50
5)
at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnectio
n.java:842)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.ja
va:395)
at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool
.java:450)
Caused by: java.text.ParseException: Expected separator ';' instead of ','
at
com.sun.ws.rest.impl.http.header.reader.HttpHeaderReader.nextSeparato
r(HttpHeaderReader.java:85)
at
com.sun.ws.rest.impl.http.header.reader.HttpHeaderReader.readParamete
rs(HttpHeaderReader.java:213)
at
com.sun.ws.rest.impl.provider.header.MediaTypeProvider.fromString(Med
iaTypeProvider.java:74)
... 29 more
Thanks!
Arul
Marc Hadley wrote:
> On May 16, 2008, at 3:49 PM, Arul Dhesiaseelan wrote:
>>
>> I would like to disable IE caching in my HTTP response produced by
>> REST service.
>>
>> Is there a way to set the header params in the response? I would like
>> to do something like this.
>>
>> response.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); //
>> disable IE caching
>>
> Yes. You can use the methods of
> javax.ws.rs.core.Response/ResponseBuilder and
> javax.ws.rs.core.CacheControl. E.g.:
>
> CacheControl c = new CacheControl();
> c.setNoCache(true);
> Response r = Response.ok(someEntity,
> someMediaType).cacheControl(c).build();
>
> There is also a ResponseBuilder.header(name, value) method if you want
> to add a header manually.
>
> Marc.
>
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>
> ________________________________
> Scanned by MessageLabs for Flux
> ________________________________