Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Servlet_bib;
- import java.io.IOException;
- import java.util.List;
- import javax.ejb.EJB;
- import javax.naming.Context;
- import javax.naming.InitialContext;
- import javax.naming.NamingException;
- import javax.servlet.ServletException;
- import javax.servlet.annotation.WebServlet;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import couche.DAO.Adherent;
- import couche.DAO.Enseignant;
- import couche.DAO.Etudiant;
- import couche.metier.LibraryLocal;
- @WebServlet(name="cs", urlPatterns={"/controleur"})
- public class Controleur_servlet extends HttpServlet{
- @EJB
- private LibraryLocal metier ;
- private Boolean v =false;
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- metier.AjouterEnseignant(new Enseignant());
- metier.AjouterAdherent(new Adherent());
- HttpSession session = request.getSession();
- if(session.getAttribute("logind") != "work") {
- String test= "<div class=\"col-md-4 col-md-push-1 animate-box\" data-animate-effect=\"fadeInRight\">\r\n" +
- " <div class=\"form-wrap\">\r\n" +
- " <div class=\"tab\">\r\n" +
- " <ul class=\"tab-menu\">\r\n" +
- " <li class=\"active gtco-first\"><a href=\"#\" data-tab=\"signup\">Login</a></li>\r\n" +
- " \r\n" +
- " </ul>\r\n" +
- " <div class=\"tab-content\">\r\n" +
- "\r\n" +
- " <div class=\"tab-content-inner active\" data-content=\"signup\">\r\n" +
- " <form method=\"post\">\r\n" +
- " <div class=\"row form-group\">\r\n" +
- " <div class=\"col-md-12\">\r\n" +
- " <label for=\"username\">Email</label>\r\n" +
- " <input type=\"text\" class=\"form-control\" id=\"username\" name=\"email\">\r\n" +
- " </div>\r\n" +
- " </div>\r\n" +
- " <div class=\"row form-group\">\r\n" +
- " <div class=\"col-md-12\">\r\n" +
- " <label for=\"password\">password</label>\r\n" +
- " <input type=\"password\" class=\"form-control\" id=\"password\" name=\"password\">\r\n" +
- " </div>\r\n" +
- " </div>\r\n" +
- " \r\n" +
- "\r\n" +
- " <div class=\"row form-group\">\r\n" +
- " <div class=\"col-md-12\">\r\n" +
- " <input type=\"submit\" class=\"btn btn-primary\" value=\"Login\" name=\"submit\">\r\n" +
- " </div>\r\n" +
- " </div>\r\n" +
- " </form> \r\n" +
- " </div>\r\n" +
- "\r\n" +
- " \r\n" +
- " </div>\r\n" +
- " </div>\r\n" +
- " </div>\r\n" +
- " </div>";
- request.setAttribute("test", test);
- }
- if(session.getAttribute("logind") == "work") {
- String afflogout="<li><a href='?id=78'>logout</a></li>";
- request.setAttribute("afflogout",afflogout);
- String idl = request.getParameter("id");
- if(idl!=null) {
- if(idl.equals("78")) {
- session.removeAttribute("logind");
- response.sendRedirect("./controleur");
- }
- }
- String interface_cher=" <div id=\"gtco-subscribe\">\r\n" +
- " <div class=\"gtco-container\">\r\n" +
- " <div class=\"row animate-box fadeInUp animated-fast\">\r\n" +
- " <div class=\"col-md-8 col-md-offset-2 text-center gtco-heading\">';\r\n" +
- " <h2>find the book </h2>\r\n" +
- " \r\n" +
- " </div>\r\n" +
- " </div>\r\n" +
- " <div class=\"row animate-box fadeInUp animated-fast\">\r\n" +
- " <div class=\"col-md-8 col-md-offset-2\">\r\n" +
- " <form method=\"post\" name=\"form_login\" onsubmit=\"return Is"
- + "Empty()\">\r\n" +
- " <form class=\"form-inline\">\r\n" +
- " <div class=\"col-md-6 col-sm-6\">\r\n" +
- " <div class=\"form-group\">\r\n" +
- " <label for=\"email\" class=\"sr-only\">book name</label>\r\n" +
- " <input type=\"text\" name=\"bokkr\" class=\"form-control\" id=\"email\" placeholder=\"book name\">\r\n" +
- " </div>\r\n" +
- " </div>\r\n" +
- " <div class=\"col-md-6 col-sm-6\">\r\n" +
- " <button type=\"submit\" name=\"finder\" class=\"btn btn-default btn-block\" value='FIND'>FIND</button>\r\n" +
- " </div>\r\n" +
- " </form>\r\n" +
- " </form>\r\n" +
- " </div>\r\n" +
- " </div>\r\n" +
- " </div>\r\n" +
- " </div>";
- request.setAttribute("interface_cher", interface_cher);
- }
- request.getRequestDispatcher("Home.jsp").forward(request, response);
- }
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- String user =request.getParameter("email");
- String pass =request.getParameter("password");
- String action=request.getParameter("submit");
- if(action!=null) {
- if(action.equals("Login")) {
- int ad = metier.RechercheAdherent(user, pass);
- if(ad!=0) {
- HttpSession session = request.getSession();
- session.setAttribute("logind", "work");
- }
- else {
- String testlogin="<script>alert(\"user or pass incorecte\");</script>";
- request.setAttribute("testlogin",testlogin);
- }
- }
- }
- String mot_livre=request.getParameter("bokkr");
- String action_recherche=request.getParameter("finder");
- if(action_recherche!=null) {
- if(action_recherche.equals("FIND")) {
- String affiche_book ="<div><form method='post'><table border='1'>\r\n" +
- "<tr><td><img src=\"./images/v.png\" height=\"130\" width=\"130\"></td>\r\n" +
- "<td> test0</td>\r\n" +
- "<td><button name='reservation' value='test' class='btn btn-default btn-block'> reserver</button></td></tr>\r\n" +
- "</table></form></div>";
- request.setAttribute("affiche_book",affiche_book);
- }
- }
- doGet(request, response);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement