package commands;

import java.io.IOException;
import java.util.*;

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

import spring.Context;

import business.*;

import dao.*;

public class TurmaListar extends AbstractCommand {

	TurmaDAO turmaDAO = DAOFactory.getInstance().getTurmaDAO();

	public void processarComando(HttpServletRequest request,
			HttpServletResponse response, Context context) {

		List<Turma> turmas = turmaDAO.listarTurmas();

		request.setAttribute("turmas", turmas);

		RequestDispatcher rd = request
				.getRequestDispatcher("turmaListar.jsp");
		try {
			rd.forward(request, response);
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
