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 8447275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:08:39+00:00 2026-06-10T10:08:39+00:00

I am trying to access a conf file (located in the WEB-INF folder) from

  • 0

I am trying to access a conf file (located in the WEB-INF folder) from a Tomcat web app. At the moment, I have the location of the file hard coded as a String. However, this does not work when the tomcat/webapps folder is in a different location than my hard coded String indicates. I’ve looked online and it seems like using the getResourceAsStream () method is what I’m looking for, but I’m having a hard time getting it to work. My application is not liking it when I call the getServletContext () method. Can anyone help me?

EDIT: The relevant block of code

BufferedReader myReader = new BufferedReader (new InputStreamReader (getServletContext ().getResourceAsStream ("/WEB-INF/conf.txt")));
  • 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-10T10:08:40+00:00Added an answer on June 10, 2026 at 10:08 am

    To solve this problem I created two folders under WEB-INF (path/to/app/WEB-INF/classes/mypackage/) and then put my files in this folder. Then, from my POJO I called this.getClass.getResourceAsStream ("<filename>") to open up a stream. To just get a String that was the complete absolute path name of a file I did this.getClass.getResource ("<filename>").toString ().substring (5).

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

Sidebar

Related Questions

I wanted to put my log4j.xml file in WEB-INF/conf directory where I have many
I am trying to access all the data from database listOfFolder table folder and
I have a RoR web app that I'm trying to serve up with Passenger
I'm trying to access an existing Subversion server over HTTP. My dav_svn.conf file looks
Trying to access a Servlet from a button on HTML page //Html Page FORM
I am trying to access a file for xml parsing with this: InputStream inputStream
I'm trying to access the resources of a derived abstract class (from PhoneApplicationPage) in
In the apache server installation I have a .conf file which forwards all requests
I have an .htaccess file that I'm trying to convert so it can be
I'm trying to enable a php file to access another file residing in a

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.