title: What is the class loading process for a JSP?
body: <p>I have a dynamic web project in eclipse. I have a file <code>a.xml</code> in my WEB-INF which is present on classpath. I have class named <code>Test</code> in my project.</p>
  
  <p>I have following code in a JSP scriptlet - </p>
  
  <pre><code>&lt;%@page import="com.kshitiz.Test"%&gt;
  &lt;%
  System.out.println(ClassLoader.getSystemClassLoader().getSystemResource("a.xml"));
  System.out.println(this.getClass().getClassLoader().getSystemResource("a.xml"));
  System.out.println(Test.class.getClassLoader().getResource("a.xml"));
  %&gt;
  </code></pre>
  
  <p>The output is - </p>
  
  <pre><code>null
  null
  C:/Users/kshitiz/eclipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/test-project/WEB-INF/classes/a.xml
  </code></pre>
  
  <p>Apparently the system class loader and the JSP classloader are not able to find my file.</p>
  
  <p>Could you explain the output? Is tomcat using a different classloader to load JSP? Why so? Why isn't system classloader able to find my file?</p>
  
  <p><em>I already know that I can use following to get to my file</em> - </p>
  
  <pre><code>getServletContext().getResourceAsStream("/WEB-INF/a.xml");
  </code></pre>
  
  <p><em>I'm interested in understanding the above scenario not the various methods to load that file.</em></p>