HttpServlet class provides generic methods to accomplish this:
doGet for GET requests
doPost for POST requests
doPut for PUT requests
doDelete for DELETE requests
And that's all.
If you want to support other HTTP methods, like TRACE or CONNECT, then you should extend from GenericServlet and do all this work manually by overriding GenericServlet#service method. Take into account that this may involve several work. You could also forget about extending from one of these classes and do it all yourself by implementing Servlet interface. Examples of these:
DispatchServlet from Spring MVC framework, which extends from HttpServlet.
FacesServlet from JavaServer Faces framework, which directly implements Servlet interface and do all the work by itself. It provides support for OPTIONS, HEAD, TRACE and CONNECT methods apart from the 4 methods described above.
If you're specifically looking about how to implement a RESTful API, then it would be better to use a framework that implements JAX-RS like Jersey or RestEasy or Restlet