users@jersey.java.net

Re: java.io.File and conditional GETs

From: Rob Koberg <rob_at_koberg.com>
Date: Wed, 7 Apr 2010 14:47:20 -0700

(I am using Jersey 1.1.5.1)

Why does the following produce different dates for the Last-Modified
and ETag headers:

    Date lastMod = new Date(file.lastModified());
    return Response.ok(file)
      .tag(DateFormat.getDateInstance(DateFormat.FULL).format(lastMod))
      .lastModified(lastMod)
      .build();

Firebug is showing the following in the headers:

Etag "Wednesday, February 16, 2005"
Last-Modified Thu, 17 Feb 2005 04:25:14 GMT

-Rob


>
> On Wed, Apr 7, 2010 at 1:34 PM, Rob Koberg <rob_at_koberg.com> wrote:
>> Hi,
>>
>> What is the best way to handle conditional GETs when targeting files
>> that exist on the local file system that are being retrieved through a
>> jersey resource? Currently it looks like I am using
>> com.sun.jersey.core.impl.provider.entity.FileProvider (which doesn't
>> appear the javadoc, checking out the project now...). Perhaps that
>> could/should place an ETag and Last-Modified header by default?
>>
>> thanks,
>> -Rob
>>
>