Neeldz
Neeldz

Reputation: 131

error loading images and JS files in a web app

After creating some sub folders under WEB-INF like js or images,i found problems loading their files i can not obtain any js or image files...what it could be the problem?. I got this error on the browser :

GET http://localhost:8080/images/blueAqua.gif 404 (Not Found)

Upvotes: 0

Views: 1086

Answers (3)

DaniiiB
DaniiiB

Reputation: 1

Try this:

<servlet-name>default</servlet-name>
<url-pattern>*.gif</url-pattern>
</servlet-mapping>

Upvotes: 0

Neeldz
Neeldz

Reputation: 131

It work fines now i did realise what was the problem and how to fix it, it needed just some configuration in the web.xml as below:

<servlet-name>default</servlet-name> <url-pattern>/static/*</url-pattern> </servlet-mapping> and in the JSP file it was the call like this :

<body background="static/images/example.jpg"> thx for your help anyway.

Upvotes: 0

sp00m
sp00m

Reputation: 48817

WEB-INF is not accessible client-side.

I usually create a static folder next to the WEB-INF one, to store images, JS, CSS, etc.

webapp
|__static
|  |__css
|  |__js
|  |__img
|__WEB-INF
   |__web.xml 

Then, access the resources using:

http://localhost:8080/static/images/blueAqua.gif

Upvotes: 1

Related Questions