Wrap the default servlet but override the default webapp path?

You can either write your own servlet to serve static content (which is not that hard) or try to extend rather than wrap the DefaultServlet. Either way, your resulting servlet will have be configured in place of default in your web. Xml (using "default" as servlet-name).

You can either write your own servlet to serve static content (which is not that hard) or try to extend rather than wrap the DefaultServlet. Either way, your resulting servlet will have be configured in place of default in your web. Xml (using "default" as servlet-name).

That said, DefaultServlet will only serve static content from under your webapp context; in order to change that you'll have to create / bind to JNDI your own ProxyDirContext instance pointing to the outside folder and I'm not sure whether that will work; its configuration process is rather involved. Trying to override servlet path will not get you anywhere.

We have a similar problem that we need to share some files generated by CMS among several applications. Symlink is the easiest way to do this if you are not using Windows. We setup 2 accounts for CMS and Tomcat.

The files are read-only to Tomcat so it can't delete them. You can also write a small Tomcat extension so it can look for files in multiple places. See this web site, blog.bazoud.com/post/2009/05/12/Multiple... Your current approach won't work.

Tomcat needs to load up all the resources in a cache on deploy for it to be available. It's too late to change that in request processing. This extension allows Tomcat load resources from multiple directories.

The drawback of this approach is that you have to put a small JAR in server/lib.

I ended up deciding to just create my own serlvet that is mapped to a specific path. I have been using symlinks since the files are shared between multiple app nodes but must be writeable. This of course is not the ideal solution but the best given the requirements.

– Ruggs Sep 26 '09 at 2:22.

You can override DefaultServlet with your own implementation. You can perfectly subclass it, it's a public class. Here are the functional specifications of the DefaultServlet, you need to adhere it.

On the other hand you can ignore DefaultServlet and go for your own solution, an example can be found here.

That's not a good idea. Web containers or application servers can be deployed behind Web servers or you can simply use a Web server in conjunction with your container. Just put your static files under that and refer to them by absolute path.

There's really no need for this kind of hack (sorry but that's what it is). Either that or simply deploy them with the Web app.

Unfortunately the content needs to be protected behind a security filter. We are already running apache httpd for most static content, but his folder is special. I agree it's a hack.

– Ruggs Sep 25 '09 at 16:57.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions