Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Loading resources from multiple locations

I'm using plain-vanilla Jetty 8 in our application. When a request comes in, I need to check the headers, and then serve resources out of a particular subdirectory depending on header contents. I also need to check an external location to look for updated files.

These requirements suggest I should override DefaultServlet's getResource() method and return a custom Resource object. This is fine, but getResource(String path) only passes in a path as an argument, and not the entire Request object, so I can't get the headers within the getResource() method.

getResource() is called in only one location, in the DefaultServlet.doGet() method. I tried to override that, but it refers to a lot of private variables, so I get compile errors.

I considered putting the Request into a ThreadLocal variable, but the potential problems with classloading leaks describe here spooked me (second answer, Phil M): http://stackoverflow.com/questions/817856/when-and-how-should-i-use-a-threadlocal-variable

I've also considered using RequestDispatcher, but can't quite get that to work.

Any suggestions on how to attack this problem welcome. My best alternative right now is to make a complete copy of DefaultServlet and modify as needed.




Back to the top