title: How to get an HTML data form to my web service?
body: <p>I'm working on a project and I'm trying to get an HTML form data into my REST web service, so I can insert it into my database, I don't know where to get the HTML form data from.</p>
  <p>This is my web service:</p>
  <pre><code>package hananepkg;
  
  import javax.ws.rs.core.Context;
  import javax.ws.rs.core.UriInfo;
  import javax.ws.rs.Produces;
  import javax.ws.rs.Consumes;
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.PUT;
  import javax.ws.rs.PathParam;
  import javax.ws.rs.QueryParam;
  import javax.ws.rs.core.MediaType;
  
  /**
   * REST Web Service
   *
   * @author mon pc
   */
  @Path(&quot;generic&quot;)
  public class GenericResource {
      DBConnector db = new DBConnector();
      @Context
      private UriInfo context;
  
      /**
       * Creates a new instance of GenericResource
       */
      public GenericResource() {
      }
  
      /**
       * Retrieves representation of an instance of pkg.GenericResource
       * @return an instance of java.lang.String
       */
      @GET
      @Produces(MediaType.TEXT_HTML)
      
      public String insert(@QueryParam (&quot;name&quot;)String name,@QueryParam (&quot;email&quot;)String email,@QueryParam (&quot;password&quot;)String password,@QueryParam (&quot;confirmpassword&quot;)String confirmpassword) {
          //TODO return proper representation object
          
          return &quot;&lt;html&gt;&lt;body&gt;&lt;h1&gt;&quot;+db.insertData(name,email,password,confirmpassord)+&quot;&lt;/body&gt;&lt;/h1&gt;&lt;/html&gt;&quot;;
      }
  
      /**
       * PUT method for updating or creating an instance of GenericResource
       * @param content representation for the resource
       */
      
      @PUT
      @Consumes(MediaType.TEXT_HTML)
      public void putHtml(String content) {
      }
  }
  </code></pre>
  <p>This is my html page:</p>
  <pre><code>&lt;section id=&quot;contact&quot; class=&quot;contact3&quot;&gt;
          &lt;div class=&quot;container&quot; data-aos=&quot;fade-up&quot;&gt;
    
            &lt;div class=&quot;section-title&quot;&gt;
              &lt;h2&gt;Sign In&lt;/h2&gt;
            &lt;/div&gt;
  
    
              &lt;div class=&quot;col-lg-6 mt-5 mt-lg-0&quot; data-aos=&quot;fade-left&quot; data-aos-delay=&quot;100&quot;&gt;
    
                &lt;form action=&quot;forms/contact.php&quot; method=&quot;post&quot; role=&quot;form&quot; class=&quot;php-email-form&quot;&gt;
                  &lt;div class=&quot;form-row&quot;&gt;
                      &lt;div class=&quot;col-md-6 form-group&quot;&gt;
                        &lt;input type=&quot;text&quot; name=&quot;name&quot; class=&quot;form-control&quot; id=&quot;name&quot; placeholder=&quot;Username&quot; data-rule=&quot;minlen:4&quot; data-msg=&quot;Please enter at least 4 chars&quot; /&gt;
                        &lt;div class=&quot;validate&quot;&gt;&lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class=&quot;col-md-6 form-group&quot;&gt;
                        &lt;input type=&quot;email&quot; class=&quot;form-control&quot; name=&quot;email&quot; id=&quot;email&quot; placeholder=&quot;Email&quot; data-rule=&quot;email&quot; data-msg=&quot;Please enter a valid email&quot; /&gt;
                        &lt;div class=&quot;validate&quot;&gt;&lt;/div&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  &lt;div class=&quot;form-group&quot;&gt;
                    &lt;input type=&quot;password&quot; class=&quot;form-control&quot; name=&quot;subject&quot; id=&quot;password&quot; placeholder=&quot;Password&quot; data-rule=&quot;minlen:4&quot; data-msg=&quot;Please enter at least 8 chars of subject&quot; /&gt;
                    &lt;div class=&quot;validate&quot;&gt;&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form-group&quot;&gt;
                      &lt;input type=&quot;password&quot; class=&quot;form-control&quot; name=&quot;subject&quot; id=&quot;confirmpassword&quot; placeholder=&quot;Confirm Password&quot; data-rule=&quot;minlen:4&quot; data-msg=&quot;Please enter at least 8 chars of subject&quot; /&gt;
                      &lt;div class=&quot;validate&quot;&gt;&lt;/div&gt;
                    &lt;/div&gt;
                  &lt;div class=&quot;text-center&quot;&gt;&lt;button id=&quot;submit&quot; type=&quot;submit&quot;&gt;Sign In&lt;/button&gt;&lt;/div&gt;
                &lt;/form&gt;
    
              &lt;/div&gt;
    
            &lt;/div&gt;
    
          &lt;/div&gt;
        &lt;/section&gt;
  
  &lt;script type=&quot;text/javascript&quot;&gt;
              $(document).ready(function() {
                  $(&quot;#submit&quot;).click(function(event) {
                      event.preventDefault();
  
          $.ajax({
              type: &quot;POST&quot;,
              url:  &quot;http://localhost:8080/HananeTest/&quot;,
              data: formToJSON(),
              contentType: &quot;application/json; charset=utf-8&quot;,
              dataType: &quot;json&quot;,
              success: function(data) 
              {
                  alert('Success');
              },
              error: function(jqXHR, textStatus, errorThrown) 
              {
                  alert('Error: ' + textStatus);
              }
          });
      });
  });
  
      function formToJSON() 
      {
          return JSON.stringify
          ({
              &quot;username&quot;: $('#name').val(),
              &quot;email&quot;: $('#email').val(),
              &quot;password&quot;: $('#password').val()
              &quot;password&quot;: $('#confirmpassword').val()   });
      };
       
      &lt;/script&gt;
  </code></pre>
  <p>Any suggestions how to get the input data into my web service so I can insert it to my database?</p>