protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, NamingException {
        
        response.setContentType("text/html;charset=UTF-8");
        if (request.getParameter("opcao") != null) {
            if ("sala.listar".equalsIgnoreCase(request.getParameter("opcao"))) {            
                Context context = JNDIUtil.getCORBAInitialContext();
                Chat chat = (Chat)context.lookup("ChatBean");          
                request.setAttribute("salas", chat.listarSalas());
                RequestDispatcher view = request.getRequestDispatcher("/jsp/sala/listar.jsp");
                view.forward(request, response);               
            } 
            
            if ("sala.inserir".equalsIgnoreCase(request.getParameter("opcao"))) {                
                Context context = JNDIUtil.getCORBAInitialContext();
                Chat chat = (Chat)context.lookup("ChatBean");        
                chat.criaSala(new Sala(request.getParameter("nome")));                
                RequestDispatcher view = request.getRequestDispatcher("./ChatServlet?opcao=sala.listar");                
                view.forward(request, response);
                
            }
            
             if ("sala.excluir.form".equalsIgnoreCase(request.getParameter("opcao"))) {               
                Context context = JNDIUtil.getCORBAInitialContext();
                Chat chat = (Chat)context.lookup("ChatBean");   
                request.setAttribute("salas", chat.listarSalas());
                RequestDispatcher view = request.getRequestDispatcher("./jsp/sala/excluir.jsp");                
                view.forward(request, response);              
            }
             
            if ("sala.excluir".equalsIgnoreCase(request.getParameter("opcao"))) {                
                Context context = JNDIUtil.getCORBAInitialContext();
                Chat chat = (Chat)context.lookup("ChatBean");
                chat.removeSala(new Sala(request.getParameter("sala")));      
                RequestDispatcher view = request.getRequestDispatcher("./ChatServlet?opcao=sala.listar");                
                view.forward(request, response);               
            }
            
            if ("sala.entrar.form".equalsIgnoreCase(request.getParameter("opcao"))) {
                Context context = JNDIUtil.getCORBAInitialContext();
                Chat chat = (Chat)context.lookup("ChatBean");   
                request.setAttribute("salas", chat.listarSalas());                
                RequestDispatcher view = request.getRequestDispatcher("./jsp/sala/entrar.jsp");
                view.forward(request, response);  
            }
            
            if ("sala.conversar".equalsIgnoreCase(request.getParameter("opcao"))) {
                Context context = JNDIUtil.getCORBAInitialContext();
                Chat chat = (Chat)context.lookup("ChatBean");                
                Sala sala = new Sala(request.getParameter("sala"));                
                chat.escreveNaSala(sala, request.getParameter("mensagem"));
                RequestDispatcher view = request.getRequestDispatcher("./jsp/sala/conversar.jsp");
                view.forward(request, response);          
            }
            
        }        
    }