package locadora.servlets;

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

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import locadora.hibernate.HibernateUtil;
import locadora.modelo.filmes.Filme;
import locadora.persistencia.dao.FilmeDAO;

import org.hibernate.Session;


public class ListaVideos extends HttpServlet {
	
	
	 private HttpServletRequest request;
	 private HttpSession session = request.getSession(true);
	    
	public String execute() throws Exception {
	
	//Verifica login
	if(session.getAttribute("cliente") == null) {
		return "naologado";
	} 
	else{	
	 try {
		Session sessionB = new HibernateUtil().getSession();
		List<Filme> listaFilme = new FilmeDAO(Filme.class, sessionB).listAll();
		session.setAttribute("listaFilmes", listaFilme);   
		    
	 } catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace(); 
	  }
	 return "logado";
	} 
	 
	  
   }
}

