Projeto_Aula03-16-08/src/java/servlets/RandomServlet.java
/**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
Processes requests for both HTTP GET and POST
methods.

@param request servlet request
@param response servlet response
@throws ServletException if a servlet-specific error occurs
@throws IOException if an I/O error occurs
Processes requests for both HTTP GET and POST methods . @param request servlet request @param response servlet response @throws ServletException if a servlet - specific error occurs @throws IOException if an I / O error occurs
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>JavaEE - Servlets</title>");            
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>JavaEE</h1>");
            out.println("<h2>Servlets</h2>");
            out.println("<h3>Números aleatórios</h3>");
            out.println("<table border='1'>");
            out.println("<tr><th>Indice</th><th>Número</th></tr>");
            for(int i=1;i<=10;i++){
                int na = ((int)(Math.random() * 100));
                out.println("<tr><th>"+i+"</th><td>"+na+"</td></tr>");
            }            
            out.println("</table>");
            out.println("<h3><a href='index.html'>Voltar</a></h3>");
            out.println("</body>");
            out.println("</html>");
        }
    }
protected void processRequest ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { response . setContentType ( "text/html;charset=UTF-8" ) ; try ( PrintWriter out = response . getWriter ( ) ) { /* TODO output your page here. You may use following sample code. */ out . println ( "<!DOCTYPE html>" ) ; out . println ( "<html>" ) ; out . println ( "<head>" ) ; out . println ( "<title>JavaEE - Servlets</title>" ) ; out . println ( "</head>" ) ; out . println ( "<body>" ) ; out . println ( "<h1>JavaEE</h1>" ) ; out . println ( "<h2>Servlets</h2>" ) ; out . println ( "<h3>Números aleatórios</h3>"); out . println ( "<table border='1'>" ) ; out . println ( "<tr><th>Indice</th><th>Número</th></tr>") ; for ( int i = 1 ; i <= 10 ; i ++ ) { int na = ( ( int ) ( Math . random ( ) * 100 ) ) ; out . println ( "<tr><th>" + i + "</th><td>" + na + "</td></tr>" ) ; } out . println ( "</table>" ) ; out . println ( "<h3><a href='index.html'>Voltar</a></h3>" ) ; out . println ( "</body>" ) ; out . println ( "</html>" ) ; } }
Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 methods.
Processes requests for both HTTP <code > GET< / code > and <code > POST< / code > methods .