/** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub if (request.getSession(false) != null) { request.getRequestDispatcher("/acesso.do").forward(request, response); } Professor professor = (Professor) Fachada.getInstance().criarProfessor(); professor.setLogin(request.getParameter("login")); professor.setNome(request.getParameter("nome")); professor.setSobrenome(request.getParameter("sobrenome")); professor.setEmail(request.getParameter("email")); professor.setSenha(request.getParameter("senha")); professor = Fachada.getInstance().cadastrarProfessor(professor); String[] materias = request.getParameterValues("disciplinas"); if (materias != null) { for (int x = 0; x < materias.length; x++) { Disciplina disciplina = (Disciplina) Fachada.getInstance().criarDisciplina(); Disciplina disciplinaRetornada = null; disciplina.setDescricao(materias[x]); disciplinaRetornada = comparaDisciplinas(disciplina); disciplinaRetornada.setProfessor(professor); Fachada.getInstance().atualizarDisciplina(disciplinaRetornada); } } request.getRequestDispatcher("/acesso.do").forward(request, response); }
/** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub if (request.getSession(false) != null) { request.getRequestDispatcher("/acesso.do").forward(request, response); } listaDisciplinas = Fachada.getInstance().listarDisciplinasSemProfessor(); request.setAttribute(LISTA_DISCIPLINAS, listaDisciplinas); request.getRequestDispatcher("/WEB-INF/jsp/CadastroProfessor.jsp").forward(request, response); }