Marco Dinatsoli
Marco Dinatsoli

Reputation: 10580

tomcat can't load the css file though it exists

enter image description here

the page popup.JSP contains:

<link rel="stylesheet" type="text/css" href="./css/bootstrap.css'">

as you see the folder css is there and it contains the bootstraps.css file, but i am getting error that :

http://localhost:8080/PhorestIntegrationPopup/css/bootstrap.css'

can't be found

Upvotes: 2

Views: 3302

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48087

In order for the css folder to be served to browsers, it needs to be outside of the WEB-INF folder. The servlet spec prohibits serving any content that is within this folder. (Even if it would allow it - WEB-INF is missing in the URL that you state, so there are two reasons for the file not being found)

The same goes for your JS files, which seem to be within the same folder. Move both up one directory, so that they're in the same folder as WEB-INF, but not within that folder.

JSPs can be in WEB-INF, because they just mimic code that is executed server side - however, if they are you can't reach them through any URL, only through a servlet's internal redirection. Decide for yourself if that's what you want - it secures you from unwanted information disclosure (should there be an issue within JSPs), but you'll have more work. It all depends on the framework that you're using on top of the Servlet/JSP API.

Upvotes: 3

Related Questions