0 Replies Latest reply on Jun 19, 2015 4:43 AM by Jonathan MERCIER

    How to config a war app to allow access to resources directory from GET method?

    Jonathan MERCIER Newbie

      I am trying wildfly and I do not know how to allow to access to some resources.

       

      My index.jsp need to get some js files. But when loading the corresponding web page. I observe this error:

       

      GET http://localhost:8080/resources/jquery-ui/external/jquery/jquery-2.1.4.min.js [HTTP/1.1 405 Method Not Allowed 4ms]

      GET http://localhost:8080/resources/jquery-ui/jquery-ui.min.js [HTTP/1.1 405 Method Not Allowed 1ms]

       

      index.jsp

       

      <%@ page language="text/html; charset=UTF-8"  pageEncoding="utf-8"%>

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
        <head>
        <title>FOO</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script async="defer" src="${pageContext.request.contextPath}/resources/jquery-ui/external/jquery/jquery-2.1.4.min.js"> </script>
        <script async="defer" src="${pageContext.request.contextPath}/resources/jquery-ui/jquery-ui.min.js"> </script>
         </head>
        <body>

        <div class="speciesSearch">
        <label for="species">Species: </label>
        <input id="species">
        </div>

        </body>
      </html>

       

       

      web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
        <security-constraint>
        <web-resource-collection>
        <web-resource-name>allowed</web-resource-name>
        <url-pattern>/resources/*</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
        <http-method>HEAD</http-method>
        </web-resource-collection>
        <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>
        </security-constraint>
      </web-app>

       

      jboss-web.xml

       

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="
        http://www.jboss.com/xml/ns/javaee
        http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
        <context-root>/</context-root>
      </jboss-web>

       

      structure

      $ tree -d src/
      src/
      └── main
        ├── java
        │   └── fr
        │   └── foo
        │   └── bar
        │   └── wildfly
        │   └── service
        ├── resources
        │   └── META-INF
        └── webapp
        ├── resources
        │   └── jquery-ui
        │   ├── external
        │   │   └── jquery
        │   └── images
        └── WEB-INF

       

       

       

      Regards