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

The Archive Base Latest Questions

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

I have a servlet filter that adds a random amount of latency to each

  • 0

I have a servlet filter that adds a random amount of latency to each request. Right now I toggle it on when I am developing, and switch it off before I deploy to the production server, but I have to do it manually.

Is there something I can do to automatically detect the development environment and only apply the filter there?

  • 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-20T12:30:28+00:00Added an answer on May 20, 2026 at 12:30 pm

    We use system properties to set a property on each application server that allows the application to determine whether it is running on live or dev. This works best if you have control of these environments which means you can standardise naming conventions etc.

    We use Tomcat, and the startup and shutdown scripts have been modified to add some extra properties to the JVM. For example:

    JVM_OPTS="-Dfuturemedium.javalogs=/usr/share/tomcat_a/logs/ \
    -Dfuturemedium.server.development=false \
    -Dfuturemedium.smtp.server=localhost"
    

    This means that environment-specific properties are taken out of the hands of each individual developer and pushed into the environment itself where they can be controlled by the sys admin and not duplicated throughout build files etc.

    We can then access these properties in code via:

    boolean dev = Boolean.parseBoolean(System.getProperty("futuremedium.server.development", "false"));
    

    in order to conditionally perform some action based on whether it is live or dev.
    Or in log4j.properties we can use:

    log4j.appender.myapplication_file.File=${futuremedium.javalogs}myapplication.log
    

    It is easy enough to specify these same properties on the command line for any CLI apps as well so it is fairly transparent inside or outside the container.

    Not sure what IDE you use, but if you are running an app server within it then it should be possible to control those extra properties via the IDE too.
    For Tomcat inside Netbeans go to Tools –> Servers –> Tomcat –> Platform –> VM Options

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

Sidebar

Related Questions

I have a Filter Servlet that filters request from a Servlet. I do not
For many internal problems that doesn't count now, We have a Servlet filter that
I have a javax.servlet.Filter class that I would like to redirect urls. The problem
I have a servlet.Filter implementation that does a lookup of a client's user ID
I have a servlet filter that handles errors for both vanilla servlets and JSF
On Java side, we have a servlet filter that handles authentication. We don't have
I have a filter that takes an incoming request, and then wraps it with
I have a servlet Filter that acts as the basis of my web stack.
I have a servlet filter in my Java app to ensure that users are
I have a servlet that does some business login and then redirects to 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.