title: Why is my POST method not being called? Code included
body: <p>Fairly new to REST. Here are my two classes:</p>
  
  <p>values.java</p>
  
  <pre><code>@Path("/values")
  public class values {
  
  int value = 0;
  List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();
  
  @GET
  @Produces(MediaType.TEXT_PLAIN)
  public int getSum() {
      return sum.sum(list);
  }
  
  @POST
  public String addValue() {
      list.add(value);
      return "ok";  
  }  
  
  @DELETE
  @Produces(MediaType.TEXT_PLAIN)
  public String deleteList() {
      list.clear();
      return "ok";
  }
  
  }
  </code></pre>
  
  <p>sum.java</p>
  
  <pre><code>@Path("/values/sum")
  public class sum {
  
  public static int sum(List&lt;Integer&gt; numbers) {
        int sum = 0;
        numbers.add(10);
      for(int i : numbers) {
            sum += i;
            }
      return sum;
  }
  
  }
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;
    &lt;display-name&gt;PACKAGENAME&lt;/display-name&gt;
   &lt;servlet&gt;
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
       &lt;!-- Register resources and providers under com.vogella.jersey.first package. --&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;jersey.config.server.provider.packages&lt;/param-name&gt;
          &lt;param-value&gt;PACKAGENAME&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/api/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt; 
  </code></pre>
  
  <p>When I access my Tomcat Server it just sends me 10 as a response (which is correct if POST isn't working). Any tips for a newbie? I try to pass <a href="http://localhost:8080/PACKAGENAME/api/values?value=15" rel="nofollow">http://localhost:8080/PACKAGENAME/api/values?value=15</a> and it just sends me back 10 every time. I think it is only using the GET method. How do I make it POST?</p>
  
  <p>Thanks!</p>
  
  <p>Update 1:</p>
  
  <pre><code>@POST
  public String addValue(Integer value) {
      list.add(value);
      return "ok";  
  }  
  </code></pre>
  
  <p>Update 2: How would I go about passing value (?value=15) from POST to my list? </p>