I have the following 3 folders:
My index.html
is located inside resources-->public
folder as shown below:
From this index.html
, I am trying to refer the jquery-3.3.1.js
, which is located inside webapp-->scripts
folder as shown below:
In index.html
, I tried the following but it didn’t work:
<script src="../webapp/scripts/jquery-3.3.1.min.js"></script>
What am I doing wrong?
PaulOB
March 27, 2019, 5:22pm
2
That’s two folders deep then you will need 2 steps back (i.e. ../../
)
e.g.
<script src="../../webapp/scripts/jquery-3.3.1.min.js"></script>
3 Likes
Thanks but for some reason, after making changes, it’s still not working :
Here is the screenshot of the changes I did :
However, when I uncomment this line and comment the HTML path line, it starts loading jQuery in the developer tools of Firefox :
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
When you go to “index.html” what is the full URL in the browsers address bar?
If “public” is the root you may need to pull in resources server-side or move resources under the root.
1 Like
The URL is : http://localhost:8080/MyProject/index.html
where, MyProject is the name of my project in the Eclipse.
Initially my index.html
was in webapp folder only and everything was working fine but for some reason we have to move index.html to the public folder.
You mean to say, I should move all things inside public
folder?
PaulOB
March 28, 2019, 3:01pm
6
Yes.
The public folder is usually the root folder for your online presence.
PaulOB:
Yes.
Ok. Which option would be good then:
Move whole webapp folder inside public folder without touching the index.html
, i.e. Keep index.html inside public folder and just move the webapp folder and then make file path adjustments ?
Move the index.html
also inside webapp folder and then keep this webapp folder inside public folder?
PaulOB
March 28, 2019, 3:16pm
8
Usually at the simplest level the index.html sits inside the root folder (which is usually the public folder) and is then accessible by default. Then you would have your other folders lined up below.
e.g.
Index.html
folder1
folder2
etc.
That’s how I usually do it for my own stuff but anything more complicated than that I leave to the experts
Thanks.The following directory structure worked for me:
However when I tested it by moving webapp
folder it didn’t work for some reason. I guess, I would stick with the working directory structure then.
PaulOB
March 28, 2019, 3:35pm
10
Yes that looks about right
1 Like
Great. Thanks for answering my questions !
1 Like
system
Closed
June 27, 2019, 10:49pm
12
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.