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

  • Home
  • SEARCH
  • 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 7535569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:20:12+00:00 2026-05-30T06:20:12+00:00

I use tomcat server, and try to call a java class from servlet, that

  • 0

I use tomcat server, and try to call a java class from servlet, that class has method which will return system current directory path. It’s result is difference with the one when I run form main method in that class.

  • from main method: “D:\Projects\Eclipse\Assignment” (which is where i place my project)
  • from servlet: “D:\IDE\eclipse helios” ( which is where i place my eclipse)

With this I have trouble to access my xml file in my project folder( file not found exception when I call a class from servlet). I want the same result when call from servlet as when run main method. How can I do that?

I would appreciate any advice you could give me to, or any articles that you could recommend.

Thank you.

  • 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-05-30T06:20:13+00:00Added an answer on May 30, 2026 at 6:20 am

    Why are you trying to access your resources from the filesystem? The expected method of accessing resources from any JAR, including webapps, is using getResourceAsStream:

    http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html#getResourceAsStream(java.lang.String)

    i.e. add the folder containing your resource to the build path, and use YourClassName.class.getResourceAsStream("/foo.xml") to access it.

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

Sidebar

Related Questions

I've developed a web application using servlet and tomcat. When I try to use
I try to move some services from my Tomcat Server to Jetty, just to
I'm about to use MySQL with Hibernate on a Tomcat 5.5.x server. Do I
How can i use Tomcat to serve image files from a public folder outside
We use Tomcat to host our WAR based applications. We are servlet container compliant
We use Tomcat for our java web application. There is a properties file under
I wish to use the Tomcat install/deploy tasks from catalina-ant.jar to deploy a webapp
Is there an open source filter that I can use on Tomcat to prevent
I would like to use NTLM authentication with Tomcat so that Iexplorer send automatically
I am trying to use Tomcat 6.0 as a web development server within SpringSource

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.