Tomcat directly serve static (css, js) files shared by multiple applications
Posted
by
Josvic Zammit
on Server Fault
See other posts from Server Fault
or by Josvic Zammit
Published on 2012-06-26T15:43:33Z
Indexed on
2012/06/27
21:19 UTC
Read the original article
Hit count: 182
I'm using the ExtJS framework which has a bulk of js
and css
files that are used for all apps. I intend to share these between a number of web applications (different war
files).
For this reason I would like to serve ExtJS js
and css
directly from the web server, in my case Tomcat6
, which can be used to serve static files, as in this helpful link.
Therefore I put my files under /var/lib/tomcat6/webapps/ROOT/extjs/
. The static files that are directly under that directory are served correctly, e.g. /extjs/ext.js
correctly serves the file at /var/lib/tomcat6/webapps/ROOT/extjs/ext.js
.
However files in lower-level directories, for example /extjs/welcome/css/welcome.css
, which should serve the file at /var/lib/tomcat6/webapps/ROOT/extjs/welcome/css/welcome.css
, return a 404
.
TL/DR
Tomcat serves static files only at top-level directory. A 404
is returned for files deeper in the hierarchy.
Config file contents:
- server.xml
- application's web.xml
© Server Fault or respective owner