I have a web application which uses jQuery UI. The JavaScripts are not downloaded and applied when I browse to the context root directly and rely on the welcome file:
But the JavaScripts are downloaded and applied when I browse to the welcome file:
My project structure is as below:
projectName
`-- WebRoot
|-- myFiles
| `-- index.html
`-- WEB-INF
`-- web.xml
In web.xml, I have defined as welcome file the index.html which uses jQuery UI.
<welcome-file-list>
<welcome-file>myFiles/index.html</welcome-file>
</welcome-file-list>
This can happen if the path to the script source is relative to the current request URL, such as for example
When you open the page by
then it will attempt to download the script from
When you open the page by
then it will attempt to download the script from
You would like to use a domain-relative path instead. Assuming that the file is indeed located in
then you need to declare the script source as follows
or, with dynamic resolving of the context path as this is subject to changes outside control from inside your webapp’s code