Re: [jetty-user] Best way to serve resources from arbitrary location?
Jesse McConnell <[email protected]> Mon, 18 Apr 2011 16:45:49 -0500
| Newsgroups | gmane.comp.java.jetty.support |
|---|---|
| Message-ID | <[email protected]> |
Don't subclass it, just look at the javadoc.xml example in the contexts directory of the distribution. set a context for it and point the resourceBase at the directory you want to serve out cheers, jesse -- jesse mcconnell [email protected] On Mon, Apr 18, 2011 at 15:22, Chris <[email protected]> wrote: > 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 > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email