/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template
*/
package servlet;
import bean.Pompier;
import com.mysql.cj.util.StringUtils;
import form.PompierForm;
import jakarta.servlet.ServletContext;
import java.io.IOException;
import java.io.PrintWriter;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author domin
*/
public class PompierServlet extends HttpServlet {
/**
* Processes requests for both HTTP GET
and POST
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("");
out.println("");
out.println("
GET
method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//processRequest(request, response);
//Méthode accédée uniquement depuis la barre du menu
int pageDemandee = 0;
int page = 2;
String jsp = "pompierJSP.jsp";
boolean erreur = false;
if (request.getParameter("pageDemandee") != null) {
String pageEnString = request.getParameter("pageDemandee");
boolean isNumeric = StringUtils.isStrictlyNumeric(pageEnString);
if (isNumeric) {
pageDemandee = Integer.parseInt(pageEnString);
if (pageDemandee != 2 && pageDemandee != 3) { // erreur
erreur = true;
}
} else {
erreur = true;
}
} else {
erreur = true;
}
HttpSession maSession = request.getSession();
Pompier lePompier = null;
if (erreur == false) {
lePompier = (Pompier) maSession.getAttribute("lePompierConnecte");
if (pageDemandee == 3 && lePompier.getLeStatut().getCode() != 2) { // erreur
erreur = true;
}
}
if (erreur == false && pageDemandee == 3) { // Chef de centre
ArrayListPOST
method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//processRequest(request, response);
/* Méthode accédée
depuis la validation du formulaire de choix du pompier à afficher (btAfficherPompier = "Afficher")
depuis le bouton Ajouter du formulaire du choix du pompier (btAfficherPompier = "Ajouter")
depuis le bouton de validation de mise à jour d'un pompier (btAfficherPompier = "ValiderMaj")
*/
int erreur = 0;
String btValue = null;
ArrayList