Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8792303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:57:39+00:00 2026-06-13T22:57:39+00:00

I have a dynamic web project in eclipse. I have a file a.xml in

  • 0

I have a dynamic web project in eclipse. I have a file a.xml in my WEB-INF which is present on classpath. I have class named Test in my project.

I have following code in a JSP scriptlet –

<%@page import="com.kshitiz.Test"%>
<%
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"));
%>

The output is –

null
null
C:/Users/kshitiz/eclipse/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/test-project/WEB-INF/classes/a.xml

Apparently the system class loader and the JSP classloader are not able to find my file.

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?

I already know that I can use following to get to my file –

getServletContext().getResourceAsStream("/WEB-INF/a.xml");

I’m interested in understanding the above scenario not the various methods to load that file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:57:40+00:00Added an answer on June 13, 2026 at 10:57 pm

    Each deployed web application has its own class loader. That’s what makes it possible to deploy two different webapps on the same container and to undeploy them, even if they use conflicting versions of the same library.

    The webapp’s classloader is a child of the tomcat classloader, and its classpath contains the webapp’s WEB-INF/classes directory, as well as every jar file in WEB-INF/lib. I don’t know how you set your classpath, but you shouldn’t set any classpath in eclipse, and the WEB-INF directory itself should definiitely not be in the classpath.

    The first and second line are basically equivalent, since they both use getSstemResource, which uses the system classloader. It’s normal that they don’t find your file, since the webapp’s classpath is not in the system classpath.

    The third line should find the file if it’s in the webapp’s classpath, i.e. under WEB-INF/classes or in a jar under WEB-INF/lib.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created in Eclipse dynamic web project, I have index.html in WEB-INF folder. I
I have a Eclipse Dynamic Web Project which host a simple servlet and runs
I have a dynamic web project in eclipse, which uses annotations to map servlets
I have a Dynamic Web Project in Eclipse which has a dependency to another
I have a dynamic web project (JSP) on Eclipse that runs on a tomcat
I have created a dynamic web project in Eclipse, but when I set up
I have a war file which is a simple dynamic web application where I
I have created a Dynamic Web Project in my Eclipse workspace. It is also
I have a basic web application (dynamic web project in eclipse) with an associated
I have created simple Java Dynamic Web project in Eclipse. I host my project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.