<script src="./WebContent/WEB-INF/JSP/Scripts/Modernizr-2.5.3.js" asynch defer></script>
When the servlet runs the .jsp page is displayed but I get 404 errors like "The requested resource (/MyServer/WebContent/WEB-INF/JSP/Scripts/Modernizr-2.5.3.js) is not available." on all of the .js and .css files that are included in the .jsp page.
The relevant file locations are:
./WEB-INF/JSP the .jsp file
./WEB-INF/JSP/Scripts the .js file
./WEB-INF/JSP/CSS the .css files
In particular, Modernizr-2.5.3.js is located (as managed by Eclipse) at .\Projects\MyServer\WebContent\WEB-INF\JSP\Scripts\Modernizr-2.5.3.js. I understand that the path to "included" content such as .js, .css, images and such is relative to the location of the submitted URL, not relative to the displayed .jsp and it is my understanding that the best way to handle this is to use a fully qualified path in the src= URL, which I believe I am doing. However, I get 404 errors. I have tried placing Modernizr-2.5.3.js (as a test case) "all over the place" and I have never been able to eliminate the 404 errors. (I realize I can pull this particular script from the web but that doesn't solve the problem that I have.)
Do I have a mistake in the src= URL? If not, what else would cause these 404 errors?
Al Koch wrote:Do I have a mistake in the src= URL?
Yes, you do. It's quite possible that you haven't specified that relative URL correctly in terms of what it's relative to, but even if you had, the server won't serve any resources which are under the application's WEB-INF directory.
So don't put resources there if the browser needs to ask for them. That clearly applies to JS and CSS, and there might be other resources you have which it applies to as well.
And one more thing -- the URLs shouldn't include anything related to Eclipse specifically, such as the WebContent directory. They should represent paths relative (see Bear's link) to your web application. Eclipse should have nothing to do with your configuration.
I'd sure like to know why a folder that can't be accessed "from the WEB" was named "WEB-INF". I interpreted that to mean "WEB-INFORMATION" and that actually suggested to me that this was exactly where I was supposed to the resources!