I have a html file where I submit a form to register a user. The form will be received by the back end `servlet`. However before that, the **registration** will happen via `Firebase` and once it is done, the form data need to be transferred to the `servlet`.

Below is my Form.

```
<form id="register-form" class="form" action="" method="post">
   <div class="form-group row">
      <input type="text" id="name" name="name" class="form-control" placeholder="Name">
   </div>
   <div class="form-group row">
      <input type="text" id="address" name="address" class="form-control" placeholder="Address">
   </div>
   <div class="form-group row">
      <input type="number" id="phone" name="phone" class="form-control" placeholder="Phone">
   </div>
   <div class="form-group row">
      <input type="email" id="email" name="email" class="form-control" placeholder="Email">
   </div>
   <div class="form-group row">
      <input type="password" id="password" name="password" class="form-control" placeholder="Password">
   </div>
   <div class="form-group row">
      <input type="text" id="language" name="language" class="form-control" placeholder="Language">
   </div>
   <div class="form-group row">
      <button type="button" class="btn btn-primary green max round" onClick="registerUser()">Create Account</button>
   </div>
</form>

```

Below is the javascript code

```
<script >

    function registerUser() {
        alert("hi");
        var email = "someone1@example.com";
        var password = "password";
        //Create User with Email and Password
        firebase.auth().createUserWithEmailAndPassword(email, password).then(function(user) {
            var user = firebase.auth().currentUser;
            alert(user.email); // Optional

            var email = firebase.auth().currentUser.email;
            var name = document.getElementById("name").value;
                //alert(email);
                // console.log(email) contains email
                const options = {
                    method: 'POST',
                    url: 'Register',
                    headers: {
                        // set appropriate headers, assuming json here
                        //"Content-Type": "application/json",
                        "Content-Type": "application/x-www-form-urlencoded"
                    },
                    // form body, assuming json
                    //body: JSON.stringify(email)
                    body: `email=${email};name=${name}`
                }
                //alert(email);
                url = 'Register';
                fetch(url, options)
                    .then(response => window.location.href = 'LoadCategoryList')
                    .then(data => console.log(data))
                    .catch(e => console.error(e))

        }, function(error) {
            // Handle Errors here.
            var errorCode = error.code;
            var errorMessage = error.message;
        });

    }
</script>

```

In my javascript code, I tried sending form data first by sending **email** and **name**.

Below is my `Servlet`

```
package register;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Register extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");

        response.setContentType("application/json");

        String email = request.getParameter("email");
        String name = request.getParameter("name");

        System.out.println("Name: "+name +" Email: "+email);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    public String getServletInfo() {
        return "Short description";
    }

}

```

In my servlet, I am using `request parameters` to grab the data. However, my output is as below when I printed what I received.

```
Name: null Email: someone6@example.com;name= Peakgen

```

It seems I am not getting the data in request params as I expected. How can I fix this?