src/java/br/org/catolicasc/fcgf/projprog4/web/controllers/CmdControllerServlet.java
/**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param req servlet request
     * @param res 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 req servlet request
@param res 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 req servlet request @param res servlet response @throws ServletException if a servlet - specific error occurs @throws IOException if an I / O error occurs
protected void processRequest(HttpServletRequest req, HttpServletResponse res)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        res.setCharacterEncoding("UTF-8");
        try {
            final String cmd = this.readParameter(req, "cmd", getInitParameter("notFoundCmdCmd"));
            final String mtd = req.getParameter("mtd");
            final String cmdPackage = getInitParameter("cmdAddressPackage");
            final Class theClass = Class.forName(cmdPackage + "." + cmd);
            final IWebCmd theCmd = (IWebCmd) theClass.newInstance();
            String nextCmd;
            if (mtd == null || mtd.trim().isEmpty()) {
                nextCmd = theCmd.execute(req, res);
            } else {
                final Method method;
                try {
                    method = theClass.getDeclaredMethod(mtd, new Class[]{HttpServletRequest.class, HttpServletResponse.class});
                    nextCmd = (String) method.invoke(theCmd, req, res);
                } catch (NoSuchMethodException | SecurityException | InvocationTargetException ex) {
                    nextCmd = theCmd.execute(req, res);
                    Logger.getLogger(CmdControllerServlet.class.getName()).log(Level.SEVERE, "Method " + mtd + " not found!", ex);
                }
            }
            req.getRequestDispatcher(nextCmd).forward(req, res);
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            final String cmd = this.readParameter(req, "cmd", "Não submetido ao controlador!");
            req.setAttribute("cmd", cmd);
            req.setAttribute("go", this.readParameter(req, "go", "Não submetido ao controlador!"));
            req.setAttribute("msg", String.format("%s %s", "ERROR NÍVEL-1 MVC: Não encontrei a Classe: ", cmd));
            req.getRequestDispatcher("WEB-INF/views/notfoundcmd.jsp").forward(req, res);
        }
    }
protected void processRequest ( HttpServletRequest req , HttpServletResponse res ) throws ServletException , IOException { req . setCharacterEncoding ( "UTF-8" ) ; res . setCharacterEncoding ( "UTF-8" ) ; try { final String cmd = this . readParameter ( req , "cmd" , getInitParameter ( "notFoundCmdCmd" ) ) ; final String mtd = req . getParameter ( "mtd" ) ; final String cmdPackage = getInitParameter ( "cmdAddressPackage" ) ; final Class theClass = Class . forName ( cmdPackage + "." + cmd ) ; final IWebCmd theCmd = ( IWebCmd ) theClass . newInstance ( ) ; String nextCmd ; if ( mtd == null || mtd . trim ( ) . isEmpty ( ) ) { nextCmd = theCmd . execute ( req , res ) ; } else { final Method method ; try { method = theClass . getDeclaredMethod ( mtd , new Class [ ] { HttpServletRequest . class , HttpServletResponse . class } ) ; nextCmd = ( String ) method . invoke ( theCmd , req , res ) ; } catch ( NoSuchMethodException | SecurityException | InvocationTargetException ex ) { nextCmd = theCmd . execute ( req , res ) ; Logger . getLogger ( CmdControllerServlet . class . getName ( ) ) . log ( Level . SEVERE , "Method " + mtd + " not found!" , ex ) ; } } req . getRequestDispatcher ( nextCmd ) . forward ( req , res ) ; } catch ( ClassNotFoundException | InstantiationException | IllegalAccessException e ) { final String cmd = this . readParameter ( req , "cmd" , "Não submetido ao controlador!") ; req . setAttribute ( "cmd" , cmd ) ; req . setAttribute ( "go" , this . readParameter ( req , "go" , "Não submetido ao controlador!") ) ; req . setAttribute ( "msg" , String . format ( "%s %s" , "ERROR NÍVEL-1 MVC: Não encontrei a Classe: ",  c d)) ; req . getRequestDispatcher ( "WEB-INF/views/notfoundcmd.jsp" ) . forward ( req , res ) ; } }
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 .