1

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.

Thanks

Umar

Jonik
  • 80,077
  • 70
  • 264
  • 372
craftsman
  • 15,133
  • 17
  • 70
  • 86

4 Answers4

6

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.

Jason Fritcher
  • 1,471
  • 9
  • 12
2

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

serg
  • 109,619
  • 77
  • 317
  • 330
0

To access 'WEB-INF' use

getServletContext().getRealPath("/WEB-INF/...");
kamal
  • 1,093
  • 6
  • 19
  • 34
0

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">
palAlaa
  • 9,500
  • 33
  • 107
  • 166