My `JSP` contains this `form` tag:

```
<form action="MyServlet" method="post">
    Fname:<input type="text" id="fname" placeholder="type first name"/>
    <input type="submit" value="ok"/>
</form>

```

My `servlet` is:

```
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.cad.database.DatabaseClass;
import com.cad.example.service.InputService;

public class Input extends HttpServlet {

    private static final long serialVersionUID = 1L;
    public Input() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String fname = request.getParameterById("fname");
        System.out.println("My name "+fname);
    }   
}

```