title: Unable to call rest web service from html form action attribute
body: <p>I am trying to call rest web service written in java from html form</p>
  
  <p>My web service code is</p>
  
  <pre><code>import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.PathParam;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  @Path("/hello")
  public class Hello {
  
        @POST
        @Path("/hello")
        @Consumes(MediaType.TEXT_HTML)
        @Produces(MediaType.TEXT_HTML)
        public String hello( @FormParam("username") String name1) {
    return "&lt;html&gt; " + "&lt;title&gt;" + "Hello Jersey" + "&lt;/title&gt;"
              + "&lt;body&gt;&lt;h1&gt;" + "Hello from helpdesk" + "&lt;/body&gt;&lt;/h1&gt;" + "&lt;/html&gt; ";
        }
  
  }
  </code></pre>
  
  <p>And my html page is </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form action= "http://localhost:8080/helpdesk/rest/hello" method="POST"&gt;
          Username: &lt;input type="text" name="username"&gt;
          &lt;p&gt;
          &lt;input type="submit" value="Submit"&gt;
      &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here in the html form, i have called the web service ../rest/hello.
  I have referred example from <a href="http://www.vogella.com/articles/REST/" rel="nofollow">http://www.vogella.com/articles/REST/</a></p>
  
  <p>Can anybody please tell me how to do it?</p>
  
  <p>Thank you</p>