Writing HttpServlet for web is easy. It is a simple class but you have to extend it from HttpServlet. Also, you have to override doGet, doPost or Service method.

Java Code:
public class MyServlet extends HttpServlet {

 public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
...
  }