Package Servlet

Source Code of Servlet.DeleteLigne

package Servlet;
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;

import DAO.JDBCGameDAO;
import DAO.JDBCSiteDAO;
import DAO.JDBCTableDAO;
import DAO.JDBCUserDAO;
import Interface.GameDAOInterface;
import Interface.SiteDAOInterface;
import Interface.TableDAOInterface;
import Interface.UserDAOInterface;
import beans.Faq;
import beans.ListOfGames;
import beans.SiteInfo;
import beans.User;
/**
* Servlet implementation class DeleteLigne
*/
public class DeleteLigne extends HttpServlet {
  private static final long serialVersionUID = 1L;
  /**
   * @see HttpServlet#HttpServlet()
   */
  public DeleteLigne() {
    super();
    // TODO Auto-generated constructor stub
  }
  /**
   * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  }
  /**
   * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
   */
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String tableName = request.getParameter("table").toString();
    tableName=tableName.toUpperCase();
    if(tableName.equals("ABONNEMENT")){
      String num_abonnementOLD = request.getParameter("NUM_ABONNEMENT").toString();
      String requete = "delete from ABONNEMENT where NUM_ABONNEMENT=" + num_abonnementOLD;
      TableDAOInterface tableDAO = new JDBCTableDAO();
      tableDAO.faireRequete(requete);
      tableDAO.loadDatas();
      updateSite();
      request.getRequestDispatcher("administration.jsp").forward(request, response);
      return;
    }else if(tableName.equals("JEUX")){
      String num_jeuOLD = request.getParameter("NUM_JEUX").toString();
      String requete = "delete from JEUX where NUM_JEUX=" + num_jeuOLD;
      System.out.println(requete);
      TableDAOInterface tableDAO = new JDBCTableDAO();
      tableDAO.faireRequete(requete);
      tableDAO.loadDatas();
      updateSite();
      request.getRequestDispatcher("administration.jsp").forward(request, response);
      return;
    }else if(tableName.equals("NOTER")){
      String login = request.getParameter("LOGIN").toString();
      String numjeux = request.getParameter(" NUM_JEUX").toString();
      String requete = "delete from NOTER where LOGIN='" + login + "' AND NUM_JEUX=" + numjeux;
      TableDAOInterface tableDAO = new JDBCTableDAO();
      tableDAO.faireRequete(requete);
      tableDAO.loadDatas();
      updateSite();
      request.getRequestDispatcher("administration.jsp").forward(request, response);
      return;
    }else if(tableName.equals("PAGE")){
      String url = request.getParameter("URL").toString();
      String requete = "delete from PAGE where URL='" + url + "'";
      TableDAOInterface tableDAO = new JDBCTableDAO();
      tableDAO.faireRequete(requete);
      tableDAO.loadDatas();
      updateSite();
      request.getRequestDispatcher("administration.jsp").forward(request, response);
      return;
    }else if(tableName.equals("SITE")){
      String idsite = request.getParameter("ID_SITE").toString();
      String requete = "delete from SITE where ID_SITE=" + idsite;
      TableDAOInterface tableDAO = new JDBCTableDAO();
      tableDAO.faireRequete(requete);
      tableDAO.loadDatas();
      updateSite();
      request.getRequestDispatcher("administration.jsp").forward(request, response);
      return;
    }else if(tableName.equals("UTILISATEUR")){
      String login = request.getParameter("LOGIN").toString();
      String requete = "delete from UTILISATEUR where LOGIN='" + login + "'";
      TableDAOInterface tableDAO = new JDBCTableDAO();
      tableDAO.faireRequete(requete);
      tableDAO.loadDatas();
      updateSite();
      request.getRequestDispatcher("administration.jsp").forward(request, response)
      return;
    }else if(tableName.equals("QUESTION_REPONSE")){
      String num_qr = request.getParameter("NUM_QR").toString();
      String requete = "delete from QUESTION_REPONSE where NUM_QR="+num_qr;
      TableDAOInterface tableDAO = new JDBCTableDAO();
      tableDAO.faireRequete(requete);
      tableDAO.loadDatas();
      updateSite();
      request.getRequestDispatcher("administration.jsp").forward(request, response)
      return;
    }
   
  }
  public void updateSite(){
    SiteDAOInterface site = new JDBCSiteDAO();
    ServletContext context = getServletContext();
    site.loadFAQ();
    site.loadListOfGames();
    site.loadSiteInfo();
    context.setAttribute("listOfGames", ListOfGames.getListOfGames());
    context.setAttribute("siteTitre", SiteInfo.getTitre());
    context.setAttribute("siteDescription", SiteInfo.getDescription());
    context.setAttribute("faq",Faq.getFaq());
    GameDAOInterface game = new JDBCGameDAO();
    context.setAttribute("gameOfTheMonth", game.getGameOfTheMonth());   
  }
}
TOP

Related Classes of Servlet.DeleteLigne

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.