0

I got this error on the Google Chrome's console when navigating on my WebApp:

GET http://localhost:8080/Bichos/slider/js/jquery.js 404 (Not Found)
GET http://localhost:8080/Bichos/slider/js/slider.js
GET http://localhost:8080/Bichos/slider/images/arrow-left.png
GET http://localhost:8080/Bichos/slider/images/arrow-right.png

This is the folder structure:

---Bichos
   |
   `---- Web Pages
         |
         |---- WEB_INF
         |
         |---- css
         |     |---- fonts.css
         |     `---- default.css
         |
         |---- images
         |     |---- a.png
         |     `---- b.png
         |
         |---- pages
         |     |---- admin.xhtml
         |     `---- index.xhtml
         |
         |---- resources
         |     `---- css
         |           `---- pstyle.css
         |
         |---- slider
         |     |---- images
         |     |     |---- arrow-left.png
         |     |     `---- arrow-right.png
         |     |---- js
         |     |      |---- jquery.js
         |     |      `---- slider.js
         |     `---- index.html
         |
         `---- principal.xhtml

The application is JSF 2.1, i heard that the Faces Servlet config at the web.xml file could be a factor, so this is the actual config:

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

The pages located at /pages/admin.xhtml and /pages/index.xhtml work properly referencing to each other and the principal.xhtml too.

When visiting the /slider/index.html file (With URL http://localhost:8080/Bichos/slider/index.html), seems to be loading the style sheet referenced by:

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

But these references are not loaded:

<script src="js/jquery.js"></script>
<script src="js/slider.js"></script>

I try to access to these file through the URL http://localhost:8080/Bichos/slider/js/jquery.js, but get the 404 status.

I'm a little stuck, and almost sure that the solution lies on the servlet-mapping but I don't know for sure.

The environment used is Glassfish 4.0, JSF 2.1 (Facelets), PrimeFaces 5.0.

Please help, and thanks in advance.

Sebastian Motavita
  • 355
  • 1
  • 3
  • 9
  • Related: http://stackoverflow.com/questions/8367421/how-to-reference-css-js-image-resource-in-facelets-template – BalusC Nov 06 '15 at 07:25

1 Answers1

1

Well after some trial and error I realized that the referencing of the sources

<script src="js/jquery.js"></script>
<script src="js/slider.js"></script>

Are not referenced as type="text/JavaScript". I made some research and find out that HTML 4.0 and XHTML is necessary to declare the type attribute, but in HTML 5 its optional.

Regards!

Sebastian Motavita
  • 355
  • 1
  • 3
  • 9