package commands;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import spring.Context;
import business.Professor;
import dao.ProfessorDAO;

public class ProfessorPreencheLista extends AbstractCommand {

	private ProfessorDAO professorDao = null;

	public void processarComando(HttpServletRequest request,
			HttpServletResponse response, Context context) {
		
		professorDao = (ProfessorDAO) context.getBean("professorDao");

		List<Professor> professores = professorDao.listarProfessores();

		request.setAttribute("professores", professores);

		RequestDispatcher rd = request
				.getRequestDispatcher("professorRemover.jsp");

		try {
			rd.forward(request, response);
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
