package controleur;
import Metier.FileService;
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Init extends HttpServlet {
public static final String VUE_ACCUEIL = "/Accueil.jsp";
public static final String INIT_CONNECTION_PROPERTIES = "connectionProperties";
public static final String INIT_PAGINATION = "pagination";
@Override
public void init() throws ServletException {
ServletContext context = getServletConfig().getServletContext();
int pagination = Integer.parseInt(getInitParameter(this.INIT_PAGINATION));
String connectionProperties = getInitParameter(this.INIT_CONNECTION_PROPERTIES);
FileService fileService = Metier.MetierFactory.getFileService();
fileService.lireFichierPropriete(connectionProperties);
context.setAttribute("pagination", pagination);
context.setAttribute("nbLivres", Metier.MetierFactory.getPrincipale().getNbLivreTotalBDD());
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.getServletContext().getRequestDispatcher(this.VUE_ACCUEIL).forward( request, response );
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}