I have a Servlet/JSP webapp. So now I am having troubles in pointing NetBeans to my style.css file. If stylesheet is being placed in WEB-INF or META-INF or outside them in Web Pages dir - everything works fine. But I need to store this file in a css folder under src/main/resources/css/style.css The problem is that I can't refer to style.css is it is outside Web Pages dir.
Asked
Active
Viewed 9,227 times
2 Answers
3
You cannot place a css file outside the pages folder simply because everything exept that folder is not accessible by the Client. Dont forget that a css file is included like this:
<link rel="stylesheet" type="text/css" href="css/notification.css" />
You dont want someone to change it to <link rel="stylesheet" type="text/css" href="../src/MyPreciousJavaFile.java" />
and simply get the coding of any other file.

MaVRoSCy
- 17,747
- 15
- 82
- 125
-
Now THAT makes sense. Thanks a lot :) I was fighting this problem for a few hours because my mentor told me that it's my "smart NetBeans" problem and he wanted the webapp to be structured exactly this way: css file under resources. Hope, he will change his mind after I have sent him your answer. Thank you a lot. :) – Nazar Sobchuk Jun 21 '13 at 08:14
1
src/main/resources- is the directory of properties file or xml file that used by Java classes. For css you should place your file in webapp directory like src/main/webapp/resources. Client can't get any access outside of webapp directory.

Masudul
- 21,823
- 5
- 43
- 58