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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:53:39+00:00 2026-05-16T06:53:39+00:00

Part of my webapp involves uploading image files. On the production server, the files

  • 0

Part of my webapp involves uploading image files. On the production server, the files will need to be written to /somepath_on_production_server/images. For local development, I want to write the files to /some_different_path/images.

What’s the best way to handle these configuration differences?

One important requirement is this: I don’t want to have to mess with the production server at all, I just want to be able to deploy a war file and have it work. So I don’t want to use any technique which will require me to mess with the environment variables/classpath/etc. on the production machine. I’m fine with setting those on my local machine though.

I’m imaginine two possible general approaches:

  1. loading a special “dev” configuration file at runtime if certain conditions are met (environment variable/classpath/etc)
  2. flipping a switch during the build process (maven profiles maybe?)
  • 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-16T06:53:40+00:00Added an answer on May 16, 2026 at 6:53 am

    Simple things like a String can be declared as environment entries in the web.xml and obtained via JNDI. Below, an example with an env-entry named “imagePath”.

    <env-entry> 
        <env-entry-name>imagePath</env-entry-name> 
        <env-entry-value>/somepath_on_production_server/images</env-entry-value> 
        <env-entry-type>java.lang.String</env-entry-type> 
    </env-entry>
    

    To access the properties from your Java code, do a JNDI lookup:

    // Get a handle to the JNDI environment naming context
    Context env = (Context)new InitialContext().lookup("java:comp/env");
    
    // Get a single value
    String imagePath = (String)env.lookup("imagePath");
    

    This is typically done in an old fashioned ServiceLocator where you would cache the value for a given key.

    Another option would be to use a properties files.


    And the maven way to deal with multiple environments typically involves profiles and filtering (either of a properties file or even the web.xml).

    Resources

    • Introduction to Build Profiles
    • 9.3. Resource Filtering
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Part of a new product I have been assigned to work on involves server-side
I have a webapp written with the Spring Framework, Velocity, and (in part) Spring
I have a server side code to process uploaded binary files: class UploadHandler(webapp.RequestHandler): def
Part of my latest webapp needs to write to file a fair amount as
Part of our java application needs to run javascript that is written by non-developers.
My WebApp is part CMS , and when I serve up an HTML page
As part of a webapp I'm building, there is an iframe that allows the
As part of a larger webapp, I want to build functionality that allows a
I am using google-app-engine webapp, part of the code is : class Post(db.Model): title
So I'm making a Google Maps based webapp in JavaScript and a part of

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.