/**
  * Permet de repondre a une requete web En affichant la liste des Spectacles et representations :
  * Utiliste JQuery javascript pour la mise en forme
  *
  * @param HttpServletRequest request requete
  * @param HttpServletResponse response reponse
  * @throw IOException, ServletException
  * @return void
  */
 public void doGet(HttpServletRequest req, HttpServletResponse res)
     throws ServletException, IOException {
   // Get the session object
   HttpSession session = req.getSession(true);
   // Get the output stream
   ServletOutputStream out = res.getOutputStream();
   res.setContentType("text/html");
   out.println("<HEAD><TITLE>Reservation de tickets </TITLE></HEAD><BODY>");
   out.println("<h1> Reservations de tickets </h1>");
   out.println("<BODY bgproperties=\"fixed\" background=\"/images/rideau.JPG\">");
   out.println("<p align=\"Right\"><font face=\"Monotype Corsiva\"style=\"font-size: 16pt\">");
   try {
     // Open the file that is the first
     // command line parameter
     String relativeWebPath = "/WEB-INF/files/JAVASCRIPTPROG.txt";
     String absoluteDiskPath = this.getServletContext().getRealPath(relativeWebPath);
     File file = new File(absoluteDiskPath);
     FileInputStream fstream = new FileInputStream(file);
     // Get the object of DataInputStream
     DataInputStream in = new DataInputStream(fstream);
     BufferedReader br = new BufferedReader(new InputStreamReader(in));
     String strLine;
     // Read File Line By Line
     while ((strLine = br.readLine()) != null) {
       // Print the content on the console
       out.println(strLine);
     }
     // Close the input stream
     in.close();
   } catch (Exception e) { // Catch exception if any
     out.println("Error: " + e.getMessage());
   }
   if (session.isNew() || session.getAttribute("session.PanierListe") == null)
     out.println("<a href=\"admin/admin.html\">Caddie (vide)</a></font><br></p>");
   else if (session.getAttribute("session.PanierListe") != null)
     if (((PanierListe) session.getAttribute("session.PanierListe")).getSize() > 0)
       out.println(
           "<a href=\"admin/admin.html\">afficher caddie("
               + ((PanierListe) session.getAttribute("session.PanierListe")).Liste.size()
               + "Representations dans le panier)"
               + "</a></font><br></p>");
   try {
     Utilisateur user = Utilitaires.Identification(this);
     out.println(Utilitaires.AffichageAchat(user));
   } catch (Exception e) {
     out.println(e.getMessage());
   }
   out.println("</BODY>");
   out.close();
 }
Esempio n. 2
0
  /**
   * Permet de repondre a une requete web affiche le contenu du panier ansi que les differentes
   * Places disponible pour la Representation passee via la methode POST HTML Creation du panier ,
   * des différent Item mis dedans et le rajoute dans les cookie Du client si necessaire.
   *
   * @param HttpServletRequest request requete
   * @param HttpServletResponse response réponse
   * @throw IOException, ServletException
   * @return void
   */
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    HttpSession session = req.getSession(true);

    ServletOutputStream out = res.getOutputStream();
    res.setContentType("text/html");

    try {
      out.println("<HEAD><TITLE>Panier</TITLE></HEAD><BODY>");
      out.println("<h1>Contenu du panier:</h1>");
      out.println("<BODY bgproperties=\"fixed\" background=\"/images/rideau.JPG\">");

      String nom = req.getParameter("nom");
      String num = req.getParameter("num");
      String date = req.getParameter("date");
      String place = req.getParameter("place");
      String rang = req.getParameter("rang");
      SimpleDateFormat s = new SimpleDateFormat("dd/MM/yyyy HH");
      // ajout d'une place au panier

      if (place != null && rang != null && num != null && date != null) {
        if (session.getAttribute("session.PanierListe") != null) {
          ((PanierListe) session.getAttribute("session.PanierListe"))
              .addPlace(num, date, place, rang);
          if ((String) session.getAttribute("session.log") != null) {
            // utilisateur loggé
            out.println("votre panier est enregistre");
            Utilisateur user = Utilitaires.Identification(this);
            out.println(
                Utilitaires.enregistrerPlacePanier(
                    user, (String) session.getAttribute("session.log"), num, date, place, rang));
          }
        }
      }
      if (nom != null && num != null && date != null) {
        if (session.getAttribute("session.PanierListe") != null) {
          if (!((PanierListe) session.getAttribute("session.PanierListe"))
              .In(new Integer(num), date))
            ((PanierListe) session.getAttribute("session.PanierListe"))
                .Liste.add(
                    new Item(
                        new Spectacle(nom, new Integer(num)),
                        new Representation(new Integer(num), s.parse(date))));
        } else {
          // creation d'un nouveau panier
          PanierListe p = new PanierListe();
          p.Liste.add(
              new Item(
                  new Spectacle(new String(nom), new Integer(num)),
                  new Representation(new Integer(num), s.parse(date))));
          session.setAttribute("session.PanierListe", p);
        }
      }
      // attention desormais le caddie est obligatoirement alloué
      if (session.getAttribute("session.PanierListe") != null && date != null && num != null) {
        out.println("contenu  actuel du caddie:<br>");
        out.println(((PanierListe) session.getAttribute("session.PanierListe")).toString());
        out.println(
            "<h1>Veuillez selectionner une place pour la representation numero: "
                + num
                + "a la date du : "
                + date
                + ":</h1><br>");
        // Affichage des places Dispo pour la representation:
        Utilisateur user = Utilitaires.Identification(this);
        out.println(Utilitaires.AffichagePlaceAchat(user, num, date));
        out.println("<form class=\"link\" action=Validate \"method=POST>\n");
        out.println("<button type=\"submit\">VALIDER LE PANIER</button>\n");
        out.println("</form>");
      } else out.println("Le caddie est vide<br>");

      out.println("<hr><p><font color=\"#FFFFFF\"><a href=\"/index.html\">Accueil</a></p>");
      out.close();

    } catch (Exception e) { // Catch exception if any
      out.println("Error: " + e.getMessage());
    }
  }
Esempio n. 3
0
  /**
   * cette methode permet de Recuperation de la liste de tous les spectacles de la saison. ent
   * construisant une une page web decrivant ces spectacles.
   *
   * @param req an HttpServletRequest object that contains the request the client has made of the
   *     servlet
   * @param res an HttpServletResponse object that contains the response the servlet sends to the
   *     client
   * @throws ServletException if the request for the GET could not be handled
   * @throws IOException if an input or output error is detected when the servlet handles the GET
   *     request
   */
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    ServletOutputStream out = res.getOutputStream();
    HttpSession session = req.getSession(true);
    res.setContentType("text/html");
    out.println("<HEAD><TITLE> Programme de la saison </TITLE></HEAD>");
    out.println("<BODY bgproperties=\"fixed\" background=\"/images/rideau.JPG\">");
    out.println("<font color=\"#FFFFFF\"><h1> Programme de la saison </h1>");
    out.println("<FORM METHOD=POST>");
    if (session.isNew()) {

      session.putValue("expand", null);
      session.putValue("rslt", null);
    }

    int[] expand = (int[]) session.getValue("expand");
    Vector<Spectacle> rslt = (Vector<Spectacle>) session.getValue("rslt");
    try {
      Utilisateur user = Utilitaires.Identification(this);

      if (rslt == null) {
        out.println("<p><i><font color=\"#FFFFFF\">actualy NEW</i></p>");

        rslt = Utilitaires.getProgramme(user);
        session.putValue("rslt", rslt);
        if (rslt.isEmpty()) {
          out.println(" Liste vide <br>");
        } else {
          expand = new int[rslt.size()];
          Arrays.fill(expand, 0);
          session.putValue("expand", expand);
          for (int i = 0; i < rslt.size(); i++) {
            out.println(
                "<INPUT TYPE=SUBMIT NAME=LR"
                    + rslt.elementAt(i).getNum()
                    + " VALUE="
                    + "\"+\" >  "
                    + rslt.elementAt(i).getNom()
                    + "<br>");
          }
        }
      } else {

        for (int i = 0; i < rslt.size(); i++) {
          if (req.getParameter("LR" + rslt.elementAt(i).getNum()) != null) {
            expand[i] = 1;
          } else if (req.getParameter("less" + rslt.elementAt(i).getNum()) != null) {
            expand[i] = 0;
          }
          if (expand[i] == 0) {
            out.println(
                "<INPUT TYPE=SUBMIT NAME=LR"
                    + rslt.elementAt(i).getNum()
                    + " VALUE="
                    + "\"+\" >"
                    + rslt.elementAt(i).getNom()
                    + "<br>");

          } else {
            out.println(
                "<INPUT TYPE=SUBMIT NAME=less"
                    + rslt.elementAt(i).getNum()
                    + " VALUE="
                    + "\"-\" >"
                    + rslt.elementAt(i).getNom()
                    + "<br>");
            out.println(Utilitaires.listerRepresentations(user, rslt.elementAt(i).getNum()));
          }
        }
      }

    } catch (Exception e) {
      out.println(e.getMessage());
    }
    out.println("</FORM></BODY>");
    out.println("<hr><p><font color=\"#FFFFFF\"><a href=\"/index.html\">Accueil</a></p>");

    out.close();
  }