public void doGet(HttpServletRequest request,HttpServletResponse response){
}
and
public void doPost(HttpServletRequest request,HttpServletResponse response){
}
public void doGet(HttpServletRequest request,HttpServletResponse response){
}
and
public void doPost(HttpServletRequest request,HttpServletResponse response){
}
In HTTP protocal GET and POST are type of request headers. So whenever a GET type of request is recieved by server, doGet() method is invoked at the backend. Same goes for POST, doPost() is invoked.
Example: This will invoke doGet when html form is submitted.
<form method="GET" action="servletname">
This will invoke doPost()
<form method="POST" action="servletname">
There are more request type headers like put, delete that are used for implementing REST api.