title: Porting a servlet to a web service - accessing the context?
body: <p>Consider a simply servlet:</p>
  
  <pre><code>// MyServlet.java
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
  {
      UtilClass.doSomething(getServletContext().getRealPath(SOME_FILE));
  }
  </code></pre>
  
  <p>And the utility class does something with the file:</p>
  
  <pre><code>// UtilClass.java
  public String doSomething(String filePath)
  {
      File f = new File(filePath);
      String s = readWhateverFrom(f);
      return s;
  }
  </code></pre>
  
  <p>I am now porting the <code>doSomething()</code> function to a web service running under Tomcat and <strong>Axis2</strong>. How would I port it so that I can still access the context and get access to a file under the servlet?</p>