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

/**
 * This servlet receives an http POST request, informs and prints which
 * parameter does not have a value.
 
 @author Sofoklis Stouraitis
 */
public class ErrorHandlerServlet 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 parameters from the request.
       */
      String name = request.getParameter("nameField");
      String surname = request.getParameter("surnameField");
      String username = request.getParameter("usernameField");
      String password = request.getParameter("passwordField");
      String preferences = request.getParameter("preferencesField");
      String gender = request.getParameter("genderField");
      String age = request.getParameter("ageField");
      /*
       * An integer to count errors (optional).
       */
      int countErrors = 0;

      out.println("<html>");
      out.println("<head>");
      out.println("<Meta Http-Equiv='Content-Type' Content='text/html; Charset=windows-1253'>");
      out.println("<title>ErrorHandlerServlet</title>");
      out.println("</head>");
      out.println("<body>");
      out.println("<h1>ErrorHandlerServlet is running...</h1><br>");
      out.println("<h3>Έχετε κάνει τα παρακάτω λάθη:</h3>");
      out.println("<font color='#FF0000'>");

      /*
       * if user did not type anything in field name
       */
      if (!(name.length() 0))
        out.println("<font color='#FF0000'><b>" + ++countErrors
            ") Δεν έχετε συμπληρώσει Όνομα!</b><br>");
      /*
       * if user did not type anything in field surname
       */
      if (!(surname.length() 0))
        out.println("<b>" + ++countErrors
            ") Δεν έχετε συμπληρώσει Επώνυμο!</b> <br>");
      /*
       * if user did not type anything in field username
       */
      if (!(username.length() 0))
        out.println("<b>" + ++countErrors
            ") Δεν έχετε συμπληρώσει username!</b> <br>");
      /*
       * if user did not type anything in field password
       */
      if (!(password.length() 0))
        out.println("<b>" + ++countErrors
            ") Δεν έχετε συμπληρώσει password!</b> <br>");
      /*
       * if user did not choose anything in field preferences
       */
      if (preferences.equals("0"))
        out.println("<b>" + ++countErrors
            ") Δεν έχετε επιλέξει Ενδιαφέροντα!</b> <br>");
      /*
       * if user did not choose anything in field gender
       */
      if (gender == null)
        out.println("<b>" + ++countErrors
            ") Δεν έχετε επιλέξει Φύλο!</b> <br>");
      /*
       * if user did not check the field age
       */
      if (age == null)
        out.println("<b>" + ++countErrors
            ") Δεν είστε άνω των 18!</b> <br>");

      out.println("</font>");
      out.println("</body></html>");

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

}//End of class