First of all, the absolute path should work. This is not a Netbeans or Glassfih question, or JSF is a browser. And if your browser had an error preventing it from receiving Javascript from valid URLs, you would notice. Therefore, if your Javascript does not load, the probability of 99% is a simple typo, a silly mistake (forgetting the directory name, adding an extra slash or such things) and nothing to do with any of the mentioned technologies.
Another theory (just a theory - I donβt have enough data to prove it) is that you have a standard mapping showing all the face files in the "virtual" faces directory (/ faces / *). Thus, when you put your index.xhtml in the main directory of the Foo project, you see it under: localhost: 8080 / Foo / faces / index.xhtml. The "front" part of the path does not represent any real directory, it is just a display. Therefore, if you have a js file sitting on index.xhtml, you would refer to it like this: '../yourjavascript.js';../- this is a compensation for part of the virtual directory.
In any case, I highly recommend that you give up the downloadable dillemas script and use the official and good way to load resources like javascript to put them in a directory called "resources" (make it under "web pages") node in Netbeans. it will go to the top directory of your .war); to get the path to any file stored in resources, you use EL as: # {resource ['filename.css']}. You load your script with:
<script src='#{resource['script.js']}' ></script>
If you use a resource directory, you can do many more things, read some details somewhere
source share