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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:01:59+00:00 2026-05-16T02:01:59+00:00

My JSP-application requires some configuration; so I created the Settings class which is a

  • 0

My JSP-application requires some configuration; so I created the Settings class which is a wrapper to an apache commons Configuration object which should be initialized in the static constructor of Settings and I wish to do that using path to the property file. But how can I get the application path (not web path) outside the JSP page? I know that there is config auto variable in JSPs, but I need the path outside from JSP code.

This problem seems to be quite common but I’m a newbie in the java world and can’t get the solution.

  • 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-16T02:02:00+00:00Added an answer on May 16, 2026 at 2:02 am

    This is indeed a bad idea and recipe for portability trouble. The common JSP/Servlet practice is to just put the file in the classpath or add its path to the classpath and obtain it as follows:

    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    URL resource = classLoader.getResource("config.properties");
    File file = new File(resource.getPath());
    // ...
    

    or

    InputStream input = classLoader.getResourceAsStream("config.properties");
    // ...
    

    Note that you’d like to do this in a real Java class, not in a JSP file. I can suggest the ServletContextListener for this. Use contextInitialized() method to hook on webapp’s startup.

    See also:

    • Config files for a webapplication
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an application which requires the reloading of an image several times
I have created a JSP / servlets application running in Tomcat 7. It runs
Hi I have a page in my java/jsp based web application which shows list
I am working on a preexisting web application built with JSP, which uses an
I am writing a Java application that requires access to a database, which is
I'm working on an intranet-only web application (J2EE) that requires some basic security features.
i'm programing a java web application where some fields in jsp require specific characters
My Java JSP application requires to store permanent files on the Tomcat web server.
I have developed a JSP web application which, on every request, spawns a new
I am trying to migrate a java application which consist of some graph charts

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.