ErrorDisplayerServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 * The servlet ErrorDisplayerServlet is used to display all the web site errors.
 *
 @author Sofoklis Stouraitis
 */
public class ErrorDisplayerServlet extends HttpServlet {

  /**
   * Handles HTTP Post requests.
   *
   @param request
   *            the request object
   @param response
   *            the response object
   *
   @throws IOException
   *             if an input or output error is detected when the servlet
   *             handles the Post request
   @throws ServletException
   *             if the request for the Post could not be handled
   */
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {

    response.setContentType("text/html; charset=ISO-8859-7");
    PrintWriter out = new PrintWriter(response.getWriter()true);

    try {
      /*
       * gets the error message from request object.
       */
      String theError = request.getAttribute("error").toString();

      out.println("<html>");
      out.println("<head>");
      out.println("<Meta Http-Equiv='Content-Type' Content='text/html; Charset=windows-1253'>");
      out.println("<title>ErrorDisplayerServlet</title>");
      out.println("</head>");
      out.println("<body bgcolor='#CCFFaa'>");
      out.println("<hr><h3>ErrorDisplayerServlet is running...</h3><hr><br>");
      out.println("<font color='#FF0000'>");
      out.println("<h1>Error description:</h1>");
      out.println("<b>" + theError + "</b>");
      out.println("</font>");
      out.println("</body></html>");

    catch (Exception ex) {
      out.println("Exception: " + ex.getMessage());
      out.println("</body>");
      out.println("</html>");
    }
  }

  /**
   * Handles HTTP GET requests.
   *
   @param request
   *            the request object
   @param response
   *            the response object
   *
   @throws IOException
   *             if an input or output error is detected when the servlet
   *             handles the GET request
   @throws ServletException
   *             if the request for the GET could not be handled
   */
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {

    doPost(request, response);
  }
}//End of class