eng_mazzy
eng_mazzy

Reputation: 1049

Where to put resources (css, js) when working with multi folders environment

I have a problem.

This is my folders tree

WEB-INF
---adminarea
   ---some jsp files
---jspf
---view
   ---error
   ---userarea
      some jsp files
Resources
---css
---js 
---img

When I work with servlet and for example I call servlet mapped /admin everythings works but when I ask for a servlet mapped /admin/admin_page that forward the request and response to an jsp file inside adminarea folder I get an error. In particulary all the resources css, js and img are not found. The system try to find the resources in ...My_project/admin/resources/ but the resources aren't there. How can I fix the problem in the way that all the file in my project wherever they are could reach correctly the resources?

This is the way I call the resources the header

    <link rel="stylesheet" href="resources/css/style.css">

Upvotes: 0

Views: 37

Answers (1)

Nirav Prajapati
Nirav Prajapati

Reputation: 3005

by giving full path to your CSS or JS or any static resources like Image folder as below

 <link rel="stylesheet" href="${pageContext.servletContext.contextPath}/resources/css/style.css">

try this one it may help you

Upvotes: 1

Related Questions