Re: [jetty-user] Best way to serve resources from arbitrary location?

Chris <[email protected]> Mon, 18 Apr 2011 15:22:37 -0500
Newsgroups gmane.comp.java.jetty.support
Message-ID <[email protected]>
On 4/18/2011 2:51 PM, Steve Sobol wrote:
> This should be an FAQ...
>
> Chris wrote:
>> I've been struggling with how best to do this. I could just implement
>> all the rules in a servlet or servlet filter, and write each file
>> directly to the response object, but then I lose the benefit of all the
>> things that the default Jetty handlers do, like deal with compressed
>> files, caching, setting content length, deal with HEAD requests, etc..
>>
>> I don't want to reinvent the wheel. What, in general, is the best way to
>> get Jetty's default resource serving mechanism to load resources from
>> arbitrary locations?
>
>
> Create a ResourceHandler, maybe?
>
> http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/handler/ResourceHandler.html
>
> http://tinyurl.com/jetty7resourcehandler

Ok. I presume that I subclass it and override appropriate methods, like 
getResource(). I can do that.

It looks like all the other functionality I'd like to preserve, though, 
is in DefaultServlet. How do I get DefaultServlet to use my new 
ResourceHandler? I do not see an init param for it.

Or maybe there's another mechanism in web.xml to get Jetty to use it?





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email