On 8/23/06, Will Hartung <[EMAIL PROTECTED]> wrote:
...
I have my filter intercepting on /static, it checks the local web app
dir and notices that the file, xyz.jpg, does not exist and proceed to
copy it in to the web app directory. Then it simply does a Filter chain
to let the request proceed.

The problem is that when a resource is freshly copied, Tomcat replies
with a 404, even though it fired my filter, and my filter has copied the
resource. It's "pre-determined", even before firing my filter, that the
resource does not exist, and fails anyway, even though I put the
resource where it belongs before I continue on the request chain.

When I make a new request, Tomcat sees the new file and serves it up
normally.

Anyone have any thoughts on how to get around this? If not, can someone
point me to the handle static resource code in the tomcat source base so
I can yank it out and put it in my own application? It's seems like a
silly thing to do, cutting and pasting that handler logic, but doing it
AGAIN, is an even sillier thing to do.

I think that it's pretty logical behaviour since tomcat will probably
look for path resolution before any filter is called. Therefor it
already decided that the resource doesn't exist before your filter
copies it.
I think the quick and dirty solution would be to send a redirect to
the same url with a dummy param after you copied the file  from the
filter and abort execution. The second request should get the file
then.

For the future development I would consider streaming the content of
the file through a servlet instead of copying it. Depending on the
number and size of the resources you could cache everything and be
faster.

regards
leon




Regards,

Will Hartung
([EMAIL PROTECTED])



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to