Hadraba Petr wrote:
>Hello,
>
>when you put your menu.xml into the WEB-INF/classes directory, it will
>be available under the "/WEB-INF/classes/menu.xml" resource path.
>
>The WEB-INF/ directory is simply accessible and the classes/ directory too.
>
>There are two points:
> - full resource path and
> - relative path.
>
>Example:
>
>You have the following java class
>
>local.sandbox.MySuperClass
>
>Inside the MySuperClass you want to load resource. When you use
>relative path -- "menu.xml", the ServletContext.getResource() will
>look for the menu.xml inside the "/WEB-INF/classes/local/sandbox/".
>
>
No, ServletContext.getResource() will resolve any relative
path as relative to the webapp's *context root*. So, if your
webapp has been deployed at "/abc", with a docroot filepath
of "/a/b/c/abc", ServletContext.getResource("/menu.xml") will
return a URL pointing to "/a/b/c/abc/menu.xml".
On the other hand, if you call:
getClass().getClassLoader().getResource("/menu.xml")
from your servlet or custom bean, "menu.xml" will be looked up inside
WEB-INF/classes/menu.xml.
Jan