Why this example of w3s jquery does not work inside web-inf?

1

Well, I have a project in maven, and in my folder I have this structure.

  

src > main > webapp > WEB-INF > jsp > index > index.jsp, demo_test.txt

This code is inside my web-inf inside of my index.jsp the two files are inside the index folder.

When I shoot from WEB-INF and I put it in webapp it works.

    
asked by anonymous 07.08.2014 / 04:15

2 answers

1

Probably the problem is regarding the address of the demo_test.txt file, as it is inside a folder, you have to pass the full address of it, something like:

$("#div1").load("./jsp/index/demo_test.txt");
    
18.08.2014 / 22:41
0

The WEB-INF folder is protected by containing the settings, classes, and libraries of a Java application. It is not allowed to access any resources of this directory via URL for security reasons.

However, it is possible to do an include within the server itself, ie a JSP accessed outside the WEB-INF folder can include a JSP from that folder.

You can also forward a response to a JSP within that folder from a servlet or controller .

And finally, you can read files from this folder using the ServletContext.getResourceAsStream() method. Example:

servletContext.getResourceAsStream("/WEB-INF/jsp/index/index.jsp");

But usually this is done for configuration files or other static files and not for JSPs.

    
19.08.2014 / 15:43