package zall.page;

import zall.ZalleryServlet;
import zall.bean.Image;
import zutil.db.DBConnection;
import zutil.log.LogUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Logger;

@WebServlet(SlideshowServlet.URI)
public class SlideshowServlet extends ZalleryServlet {
    private static Logger logger = LogUtil.getLogger();

    public static final String URI = "/slideshow";
    private static final String JSP_FILE = "page_slideshow.jsp";


    public void doGet(HttpServletRequest request, HttpServletResponse response, DBConnection db) throws ServletException, SQLException, IOException {
        Image image = Image.load(db, Integer.parseInt(request.getParameter("id")));
        request.setAttribute("image", image);
        List<Image> list = Image.loadFolder(db, image.getFolder());

        request.setAttribute("image", image);
        request.setAttribute("images", list);

        include(JSP_FILE, request, response);
    }

}
