Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it good Idea to place css and js resources outside the WEB-INF folder?  RSS feed

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I am working on a web application where I have placed all my JSP file inside the WEB-INF folder

but I have placed my CSS and JS file outside the WEB-INF folder.

problem is that suppose my css is located in some directory like

"WebApplicationRoot/css/myHome.css"

and when I try to access it like this using tag library
<link rel="stylesheet" href="<c:url value="/css/main.css"/>" type="text/css"/>

and when I place those css file like this

"WebApplicationRoot/WEB-INF/css/myHome.css"

and when I try to access it like this using tag library
<link rel="stylesheet" href="<c:url value="/WEB-INF/css/main.css"/>" type="text/css"/>

then my css file is not loaded in my web browser

so what should I do?

Thanks
 
Marcus Biel
Ranch Hand
Posts: 51
IntelliJ IDE Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. A very good idea! :)

Resources inside WEB-INF are protected to be not accessible directly from the client -
therefore it would contains server resources like JSPs.
static content however will directly be downloaded from the client browser, so it must not be inside of WEB-INF.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resources such as images, stylesheets and scripts must never be placed inside WEB-INF as the browser must address those directly.

JSPs on the other hand should go into WEB-INF so that they cannot be directly addressed without going through their page controllers.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
Bear
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!