Can Tomcat docBase span multiple folders?

I apologize if this is a bad question, but I'm using Windows and see if there is a way to run webapp via Tomcat, where docBase are multiple folders.

A little more than that, we have an Eclipse project configured so that web content is divided into separate folders. One folder is what our SDK provides, one is the folder with the SDK patches, and the third is project-specific components. Any of the last two folders may have subfolders / files that β€œerase” items from the first two.

I would like to try returning my context file to my dev environment so that I don't need to create / deploy to see the changes I make. Is it possible?

A few other notes:

  • We thought about using symbolic links via mklink , but did not want to create complexity if it were simplicity.
  • This is easy to run locally, so simple hacks are allowed. When we create a WAR that deploys in a real environment, the ANT script creates one web root.
+4
source share
2 answers

I use it as follows:

  <Context docBase="jquery" path="/js/jquery" /> <Context docBase="foobar/www/javascript" path="/js" /> <Context docBase="foobar/www/css" path="/css" /> <Context docBase="foobar" path="/" /> 

The context attribute is the path attribute. The request is processed from top to bottom.

Thus, the request for /css/default.css processed only from the 3rd context.

A different order may take a different context.

This is not true :

  <Context docBase="foobar" path="/" /> <Context docBase="jquery" path="/js/jquery" /> <Context docBase="foobar/www/javascript" path="/js" /> <Context docBase="foobar/www/css" path="/css" /> 

Because /css/default.css will be caught in the first context, not the fourth.

Edit 2013-08-10: (Not the author of the answer) It is important to note that although the above method will work, most of it is actually incorrect. See comments for more details.

+2
source

Tomcat can do this for you, you just need a little extra configuration.

You are looking for a VirtualDirContext that allows you to specify a list of extraResourcePaths that will search (in order) for additional files. You can use this to combine static resources, JSPs, JAR file directories, etc.

Just remember that each path you add makes the search for files potentially longer - especially if the file cannot be found at all.

+3
source

Source: https://habr.com/ru/post/1492216/


All Articles