System.getProperties returning null for some values

3.9k views Asked by At

I am having some issues with my tomcat servlet hosted by amazon aws on elasticbeanstalk.

In an attempt to secure sensitive data, I am saving it in the web.xml file so that it can be referenced from System.getProperties().

Some of this data, when called through System.getProperties() in code, returns null - while other data also called through System.getProperties() returns correct values.

My web.xml file is as follows:

    <env-entry>
    <env-entry-name>RDS_PASSWORD</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>blah</env-entry-value>
</env-entry>
<env-entry>
    <env-entry-name>RDS_HOSTNAME</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>blah</env-entry-value>
</env-entry>
<env-entry>
    <env-entry-name>DUMBDATA</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>blah</env-entry-value>
</env-entry>

My code is as follows:

        w.println(System.getProperty("DUMBDATA"));
    w.println(System.getProperty("RDS_HOSTNAME"));

Although I try to access the data from the same methods and they are set up in the same way, RDS_HOSTNAME returns its correct value, whereas DUMBDATA returns null.

I appreciate any insight into this issue,

Thanks.

1

There are 1 answers

0
PKeidel On BEST ANSWER

Try something like

Properties p = System.getProperties();
Enumeration keys = p.keys();
while (keys.hasMoreElements()) {
  String key = (String)keys.nextElement();
  String value = (String)p.get(key);
  w.println(key + ": " + value);
}

to find out which ones are supported.