Servlet throws Exceptions : Error Exceptions « Servlets « Java






Servlet throws Exceptions


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Thrower extends HttpServlet {

  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {

    throw new java.io.IOException("IO thrown");
    //response.sendError(403);
  }

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

    doPost(request, response);
  }
}

           
       








Related examples in the same category

1.Generate errors
2.Error code