tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Miller <bruce.mil...@nist.gov>
Subject Re: Resource vs. RealPath
Date Sat, 06 May 2006 17:24:50 GMT
Tim Funk wrote:
> You'll need to clean the following up but you can use this:
> 
> Date lastModified =
>   new Date(servletContext
>              .getResource()
>              .openConnection()
>              .getLastModified());

Ah! I did miss that...  However...
Openning a connection seems potentially
more expensive than "merely" getting the timestamp on a file.
(I was planning on checking this at the beginning of every request,
and by the time this application is finished, there could
end up several levels of resources that might occasionally
get updated).
Is this likely to be an issue?

Thanks, in any case, though.

> -Tim
> 
> Bruce Miller wrote:
> 
>> Hi Tomcatters;
>>  A seemingly naive question:
>> I've got various configuration data, tucked away
>> under /WEB-INF/.
>>
>> If I use context.getRealPath(datapath), I can check the
>> timestamp, so that I know if it needs to be re-read.
>> However, this fails if we're serving from a .war file
>> (in which case, presumably it won't need re-reading?)
>>
>> OTOH, context.getResourceAsStream(datapath) gives no
>> means to check the timestamp, but will work from .war.
>>
>> An obvious solution is to use getRealPath to check the
>> timestamp and getResourceAsStream to read it.
>> But this seems to mix modes of thinking (A Resource being
>> something more abstract?).  Experience tells me this
>> can often lead to problems down the line...
>>
>> So the question is: Am I missing something?
>> Is there some other Best Practices approach to this
>> rather simple situation?
>>
>> Thanks in advance;
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


-- 
bruce.miller@nist.gov
http://math.nist.gov/~BMiller/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message