Servlets Java

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ErrorGen extends HttpServlet {
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
    //check the servlet exception
    Throwable throwable = (Throwable) request
        .getAttribute("javax.servlet.error.exception");
    String servletName = (String) request
        .getAttribute("javax.servlet.error.servlet_name");
    if (servletName == null)
      servletName = "Unknown";
    String requestUri = (String) request
        .getAttribute("javax.servlet.error.request_uri");
    if (requestUri == null)
      requestUri = "Unknown";
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    out.println("");
    out.println("");
    out.println("Error page");
    out.println("");
    out.println("");
    if (throwable == null) {
      out.println("

The error information is not available

");
      out.println("Please return to the           + response.encodeURL("http://www.rntsoft.com")
          + "\">home page");
    } else {
      out.println("

Here is the error information

");
      out
          .println("The servlet name associated with throwing the exception: "
              + servletName + "

");
      out.println("The type of exception: "
          + throwable.getClass().getName() + "

");
      out.println("The request URI: " + requestUri + "

");
      out.println("The exception message: " + throwable.getMessage());
    }
    out.println("");
    out.println("");
    out.close();
  }
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {
    doPost(request, response);
  }
}