title: How to get Context when servlet/jsp is not used? Only plain class files
body: <p>My existing web application gets database pooling parameters from context.
  Now, I'm developing a new web service to be deployed as a separate application, but using the previous database.</p>
  
  <p>In this new web service application, I am not using any servlet, as well as JSPs. They'll just be a collection of service classes. In such a case, how do I get the context parameters? </p>
  
  <p>In the earlier case when I'm using a servlet, my context is as below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Context antiResourceLocking="false" privileged="true" &gt;
   &lt;Resource 
      name="jdbc/NetmarketDB"
      auth="Container"
      type="javax.sql.DataSource"
      removeAbandoned="true"
      removeAbandonedTimeout="30"
      maxActive="100"
      maxIdle="30"
      maxWait="1000"
      username="root"
      password="xxxxxxxx"
      driverClassName="com.mysql.jdbc.Driver"
      url="jdbc:mysql://localhost:3306/netmarket"/&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <p>... and I get the context from a servlet or JSP as below:</p>
  
  <pre><code>Connection conn = MySqlDB.getDBConnection(getServletContext());
  </code></pre>
  
  <p>But now that I'm not using any servlet/JSP, I'm confused. Please help me out.</p>