Package controleur

Source Code of controleur.DetailEpreuve

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package controleur;

import dao.DetailEpreuveDAO;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import model.Epreuve;
import model.Sportif;

/**
*
* @author Linda
*/
public class DetailEpreuve extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> 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 {

            int IdEp = Integer.parseInt(request.getParameter("idEpreuve"));
            Context init = new InitialContext();
            DataSource dataSource = (DataSource) init.lookup("java:comp/env/jdbc/iphitosbd");
            DetailEpreuveDAO detailEpDao = new DetailEpreuveDAO(dataSource);


            /**
             * boucle qui permet de selectionner la liste des sportifs
             * soit sportifs inscrits dans une epreuve individuelle ou par equipe
             */
            int[] tabIdEp = detailEpDao.getTableauIdEpEq(IdEp);
            boolean trouve = false;
            for (int i = 0; i < tabIdEp.length; i++) {
                trouve = trouve || (IdEp == tabIdEp[i]);
            }
            if (trouve) {
                getServletContext().setAttribute("sportifs", detailEpDao.getSportifsEpreuveEq(IdEp));
                getServletContext().setAttribute("nomCatEpreuve", detailEpDao.getNomCatEpreuveEq(IdEp));
            } else {
                getServletContext().setAttribute("sportifs", detailEpDao.getSportifsEpreuveInd(IdEp));
                getServletContext().setAttribute("nomCatEpreuve", detailEpDao.getNomCatEpreuveInd(IdEp));
            }
            getServletContext().getRequestDispatcher("/WEB-INF/afficherDetailEpreuve.jsp").forward(request, response);
        } catch (Exception ex) {
         
            Logger.getLogger(DetailEpreuve.class.getName()).log(Level.SEVERE, null, ex);
            throw new ServletException("problème lors de l'initialisation de la source de données ",
                    ex);
        }




        /**---------------------------------------------------------------------
        Construction du modèle
        ----------------------------------------------------------------------*/
        //construire un model Detail Epreuv
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> 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);
    }

    /**
     * Handles the HTTP <code>POST</code> 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);
    }

    /**
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
TOP

Related Classes of controleur.DetailEpreuve

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.