src/java/br/org/catolicasc/fcgf/projprog4/web/controllers/AjaxSamplesFindAllProject.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("application/json; charset=UTF-8");
        response.setCharacterEncoding("utf-8");
        try (PrintWriter out = response.getWriter()) {
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException ex) {
                Logger.getLogger(AjaxSamplesFindAllProject.class.getName()).log(Level.SEVERE, null, ex);
            }
            List<Project> projetos = buildProjectList();
                Gson gson = new Gson();
                JsonElement element = gson.toJsonTree(projetos , new TypeToken<List<Project>>() {}.getType());
                JsonArray jsonArray = element.getAsJsonArray();
                out.println(jsonArray.toString());
                out.flush();
        }
    }
protected void processRequest ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { response . setContentType ( "application/json; charset=UTF-8" ) ; response . setCharacterEncoding ( "utf-8" ) ; try ( PrintWriter out = response . getWriter ( ) ) { try { TimeUnit . SECONDS . sleep ( 2 ) ; } catch ( InterruptedException ex ) { Logger . getLogger ( AjaxSamplesFindAllProject . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } List < Project > projetos = buildProjectList ( ) ; Gson gson = new Gson ( ) ; JsonElement element = gson . toJsonTree ( projetos , new TypeToken < List < Project > > ( ) { } . getType ( ) ) ; JsonArray jsonArray = element . getAsJsonArray ( ) ; out . println ( jsonArray . toString ( ) ) ; out . flush ( ) ; } }
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 .