Take the 2-minute tour ×

I am facing a problem when I move my JSP files along with CSS and JS files under WEB-INF/web/ directory. The problem is that, when a JSP page loads, it does not load CSS and JS files. Please help if you have any idea about it.



share|improve this question

5 Answers 5

up vote 5 down vote accepted

Unless you want to write controllers to serve the css/js files in the WEB-INF folder, you will need to move those files out of WEB-INF so that they can be served as static files by the app server.

share|improve this answer

WEB-INF is not web accessible, you need to put css/js into public_html(www) as browser loads them through http.

share|improve this answer

You can use the contextPath to retrieve any file from the foot folder,this way can work with files inside and outside WEB-INF folder.

You can make like this

<link rel="stylesheet" href="${pageContext.request.contextPath}/css/fromStyle.css" type="text/css">
share|improve this answer

To access 'WEB-INF' use

share|improve this answer

The WEB-INF-dierctory is a protected one to hold internal configuration data like the web.xml. Nothing inside schould be delivered by HTTP access (don't know why your server delivers the JSP at all). No URL schould contain WEB-INF at all. Please move your JSPs, style sheets, images and all ather files to be accessible by a browser outside WEB-INF.

share|improve this answer
I'm not sure about struts, but with Spring, it is accepted practice to put JSPs in WEB-INF and then your view code accesses the protected JSP. This also prevents direct HTTP access to your JSPs so you get better access controls. –  Jason Fritcher Sep 2 '09 at 5:30
Same goes for Struts as well. It is considered a good practice to put JSPs in WEB-INF folder. Anyways, I have got my answer. –  craftsman Sep 2 '09 at 7:14
No application server can serve anything out of WEB-INF in response to a direct GET request from the user. Application code on the server written to access WEB-INF can however do so. So you are kind of missing the point. –  Vineet Reynolds Sep 2 '09 at 10:16

Your Answer


