tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <funk...@joedog.org>
Subject Re: Resource vs. RealPath
Date Sat, 06 May 2006 17:09:55 GMT
You'll need to clean the following up but you can use this:

Date lastModified =
   new Date(servletContext
              .getResource()
              .openConnection()
              .getLastModified());

-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


Mime
View raw message