Reputation: 7333
I working with servlet application my folder structure is :
WEB-INF ->
-> Test
-> index.html
-> index.js
-> index.css
Inside .java file I am loading index.html file as follow:
RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/Test/index.html");
dispatcher.include(request, response);
dispatcher.forward(request, response);
This is loading index.html file successfully on browser. But problem is with css , js files. This files are not loading in the resource ,I have loaded those as follow inside index.html :
<link rel="stylesheet" type="text/css" href="index.css" />
<script src="index.js"></script>
The error I am getting is 404 resource not found error.
So am I missing anything ? or should I take some other approach ?
Upvotes: 1
Views: 863
Reputation: 1626
Don't put those files in /WEB-INF. Move them up one level.
The /WEB-INF folder is meant to hold configuration files, the compiled application (/WEB-INF/classes) and the application dependencies (/WEB-INF/lib).
Upvotes: 2