Configuration settings for an application should never be hardcoded; instead, they should be configured through a separate properties file.
A properties file looks like this:
#This is a comment
The # symbol denotes a comment, while keys are separated from values with an = sign.
You can read this file into a Java application by using the following code. It reads in a properties file named app.properties located within the /WEB-INF/ folder (putting your properties files in /WEB-INF/ also keeps them private):
InputStream app_properties_stream = this.getServletContext().getResourceAsStream("/WEB-INF/app.properties");
Properties app_properties = new Properties();
//This will throw a NullPointerException if the properties file cannot be found,
//and an IOException if an error occurs while reading.
From here you can retrieve values by calling:
String value = app_properties.getProperty("key");