package controleur; import Metier.StructureBibliotheque; import Metier.StructureBibliothequeService; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class AddStructure extends HttpServlet { public static final String VUE_ACCUEIL = "/Accueil.jsp"; public static final String CHAMP_NOM = "nomStructure"; public static final String ATT_RESULTAT = "resultat"; protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { StructureBibliotheque structureBibliotheque = new StructureBibliotheque(request.getParameter(this.CHAMP_NOM)); StructureBibliothequeService structureBibliothequeService = Metier.MetierFactory.getStructureService(); structureBibliothequeService.add(structureBibliotheque); String resultat = "<div class=\"alert alert-success alert-dismissable\">\n" + " <button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button>\n" + " La structure \"<strong>" + structureBibliotheque.getNom() + "</strong>\" à été ajoutée\n" + "</div>"; request.setAttribute(this.ATT_RESULTAT, resultat); this.getServletContext().getRequestDispatcher(this.VUE_ACCUEIL).forward( request, response ); } @Override public String getServletInfo() { return "Short description"; }// </editor-fold> }