package zall.page;

import zall.ZalleryServlet;
import zall.bean.User;
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(UserListServlet.URI)
public class UserListServlet extends ZalleryServlet {
    private static Logger logger = LogUtil.getLogger();

    public static final String URI = "/users";
    private static final String JSP_FILE = "page_users.jsp";


    public void doGet(HttpServletRequest request, HttpServletResponse response, DBConnection db) throws ServletException, SQLException, IOException {
        List<User> users = User.load(db);
        request.setAttribute("users", users);

        include(JSP_FILE, request, response);
    }
}
