Reputation: 1021
I'm trying to load a JavaScript file to my jsp file
Here is what I've tried:
<script type="text/javascript" src="static/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="/static/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="/WebContent/WEB-INF/static/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="WebContent/WEB-INF/static/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="/WEB-INF/static/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="WEB-INF/static/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="/USI-WEB/WEB-INF/static/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="/USI-WEB/WebContent/WEB-INF/static/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="USI-WEB/WEB-INF/static/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="USI-WEB/WebContent/WEB-INF/static/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() + "/static/js/jquery-ui-1.10.3.custom.js"%>"></script>
<script type="text/javascript" src="<%=request.getContextPath() + "/static/js/jquery-ui-1.10.3.custom.js"%>"></script>
<script type="text/javascript" src="<%=request.getContextPath() + "/WebContent/WEB-INF/static/js/jquery-ui-1.10.3.custom.js"%>"></script>
<script type="text/javascript" src="<%=request.getContextPath() + "WebContent/WEB-INF/static/js/jquery-ui-1.10.3.custom.js"%>"></script>
<script type="text/javascript" src="<%=request.getContextPath() + "/WEB-INF/static/js/jquery-ui-1.10.3.custom.js"%>"></script>
<script type="text/javascript" src="<%=request.getContextPath() + "WEB-INF/static/js/jquery-ui-1.10.3.custom.js"%>"></script>
And this is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>USI WEB</display-name>
<!-- Filter to set character encoding on each request -->
<servlet>
<servlet-name>Servlet</servlet-name>
<servlet-class>usi.servlet.Servlet</servlet-class>
</servlet>
<welcome-file-list>
<welcome-file>Servlet</welcome-file>
</welcome-file-list>
</web-app>
On all of this I get : The requested resource () is not available.
Upvotes: 0
Views: 470
Reputation: 1021
Found the solution, the problem was that I've had JS,CSS and other stuff under the WEB-INF folder, which is inaccessible from outside, when I moved the JS folder a level higher it started working
The new Location of static folder
Upvotes: 1
Reputation: 9639
you can try this:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript" src="<c:url value="/static/js/js/jquery-ui-1.10.3.custom.js"/>"></script>
Upvotes: 0