users@jersey.java.net

Re: [Jersey] disabling IE cache on the HTTP response

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 19 May 2008 10:36:55 +0200

Arul Dhesiaseelan wrote:
> --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?
>

According to my calendar the 26th of July 1997 is not a Monday, it is a
Saturday. Perhaps IE is rejecting this as an invalid header whereas
Firefox is more forgiving?


> 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,
>

Can you log and email the request headers that are being sent by IE?

Thanks,
Paul.

> 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
>> ________________________________
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109