Projeto_Aula03-16-08/src/java/servlets/GreetingServlet.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>Recurso requisitado</h3>");
            out.println("<p>"+request.getRequestURI()+"</p>");
            out.println("<h3>Saldação</h3>");            
            Calendar c = Calendar.getInstance();
            int h = c.get(Calendar.HOUR_OF_DAY);
            out.println("<p>São "+h+" horas</p>");
            if(h<6){
                out.println("<p>Vá dormir</p>");
            }else if(h<12){
                out.println("<p>Bom dia</p>");
            }if(h<18){
                out.println("<p>Boa tarde</p>");
            }else{
                 out.println("<p>Boa noite</p>");
            }
            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>Recurso requisitado</h3>" ) ; out . println ( "<p>" + request . getRequestURI ( ) + "</p>" ) ; out . println ( "<h3>Saldação</h3>"); Calendar c = Calendar . getInstance ( ) ; int h = c . get ( Calendar . HOUR_OF_DAY ) ; out . println ( "<p>São "+ h + "  horas</p>") ; if ( h < 6 ) { out . println ( "<p>Vá dormir</p>") ; } else if ( h < 12 ) { out . println ( "<p>Bom dia</p>" ) ; } if ( h < 18 ) { out . println ( "<p>Boa tarde</p>" ) ; } else { out . println ( "<p>Boa noite</p>" ) ; } 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 .