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

/**
 * This Servlet prints the result of a random cast of a pair of dice.
 
 @author Sofoklis Stouraitis
 
 */
public class DiceServlet extends HttpServlet {

  /**
   * 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 {

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

    try {

      int dice1 = (int) (Math.random() 1);
      int dice2 = (int) (Math.random() 1);

      out.println("<html>");
      out.println("<head>");
      out.println("  <title>DiceServlet</title>");
      out.println("    <meta http-equiv='Content-Type' content='text/html; charset=windows-1253'>");
      out.println("</head>");
      out.println("  <body>");
      out.println("  <h1>DiceServlet is running..</h1><br>");
      out.println("    <strong>Πρώτο ζάρι: " + dice1);
      out.println("    <br>");
      out.println("    Δεύτερο ζάρι: " + dice2 + "</strong>");
      out.println("  </body>");
      out.println("</html>");

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