title: Calling Java function inside doPost of servlet?
body: <p>I wanted to process a HTTP request and do some processing on it. Can I do the following?</p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      response.setContentType("application/soap+xml;charset=utf-8");
      char[] cbuf = new char[10000];
  
      PrintWriter out = response.getWriter();
  
      InputStreamReader in = new InputStreamReader(request.getInputStream());
  
      in.read(cbuf,0,10000);
  
      int req_len = request.getContentLength(); 
  
      String inputLine = new String(cbuf);
  
      Spoof sp = new Spoof();
  
      String xml_response = sp.spoof_second(inputLine.substring(0, req_len), request.getParameter("mode"));    
  
      out.println(xml_response);
  }
  </code></pre>
  
  <p>I am getting a null response so I wanted to know if there is a way to call the function spoof_second(). </p>
  
  <p>My web.xml looks like:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;web-app
   xmlns="http://java.sun.com/xml/ns/j2ee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
      http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
   version="2.4"&gt;
   &lt;servlet&gt;
      &lt;servlet-name&gt;home&lt;/servlet-name&gt;
      &lt;servlet-class&gt;website.web.HomeServlet&lt;/servlet-class&gt;
   &lt;/servlet&gt;
   &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;home&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/home&lt;/url-pattern&gt;
   &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p></p>
  
  <p>I am sending the request to [http://localhost:4321/website/home?mode=record] so the mode is correct and the inputLine is also correct as I checked by printing them out. The thing I am unsure is on how to build the whole project in Eclipse as I think the function call is not being made. I am not getting any exception and I am getting an HTTP 200 OK response with null content.</p>