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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:28:42+00:00 2026-05-17T16:28:42+00:00

My JSP pages need to display different information depending on which environment they’re in

  • 0

My JSP pages need to display different information depending on which environment they’re in (dev, production, sandbox, etc). I want to have a properties file for each of these environments that contain all the parameters they might need. How can I reference the properties from this file in a JSP page?

My thoughts are:

  • Have a servlet feed the properties in the form of a model object to all JSP pages so I can reference them like ${properties.propertyName}
  • Somehow reference this property file in the web.xml, then maybe I call something like ${context.properties.propertyName}?
  • Instead of a properties file, list parameters in web.xml and reference those in the JSP pages. Not sure how to do this, but I’d very much prefer a simpler properties file.

UPDATE – I should’ve mentioned I’m using Spring 3.0 and Spring webmvc. So if there’s some best practices way to do this using Spring, that’s ideal!

  • 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-17T16:28:42+00:00Added an answer on May 17, 2026 at 4:28 pm
    • You can load the properties using java.util.Properties (or commons-configuration) in a ServletContextListener‘s contextInitialized(..) method.

    • register the listener with <listener> in web.xml

    • You then store the Properties into the ServletContext (you can get it from the event) (ctx.setAttribute("properties", properties)

    • then access the properties using ${applicationScope.properties.propName} (as BalusC noted, applicationScope is optional)

    Update:

    Initially I thought spring had some ready-to-use facility for that, but it turns out it’s not exactly the case. You have two options:

    • this article explains something similar to my suggestion above, but using spring’s PropertyPlaceholderConfigurer

    • this answer and this answer allow you to expose all your beans, including a PropertyPlaceholderConfigurer to the servlet context.

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

Sidebar

Related Questions

I'm running tomcat and have some jsp pages that display a subset of a
I need to display build number in my index.jsp page <!DOCTYPE HTML> <html> <head>
i am using display tag for showing table in my jsp page. I need
I have a webapp on which I need to display unicode characters. It's all
I have a large number of JSP pages that need a small bit of
For a variety of reasons I need a JSP to act and display differently
I need to get a visitor's locale in my JSP pages so that I
I need to upload .dat file from jsp page. I am using struts. I
On a JSTL/JSP page, I have a java.util.Date object from my application. I need
Can I set timeouts for JSP pages in tomcat either on a per page

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.