title: Accessing ServletContext outside of a servlet
body: <p>I wonder if anyone can advise on a Java webapp question?</p>
  
  <p>I have a set standard Java class which has methods to set and get values of a property file. These methods are used system wide and are called by servlets and non-servlet class methods alike. </p>
  
  <p>But what I would like to do is to use a ServletContextListener to set the paths to the property file globally rather than hard code them or store them in the database. </p>
  
  <p>A ServletContextListener can be used to set 'global variables' for the servlets with context.setAttribute("PROP_FILE_PATH", "C:\..."). But is there a way to access these variables outside the servlets or can ServletContext be accessed outside servlets?</p>
  
  <p>I don't think passing the ServletContext as a parameter to the class methods I have to get and set property file values will be a viable option because of the number of calls.</p>
  
  <p>Thanks</p>
  
  <p>Martin</p>