public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // tengo que eliminar al usuario de la sesión HttpSession session = request.getSession(false); String next = "/error.html"; if (session != null) { User user = (User) session.getAttribute("user"); session.removeAttribute("user"); session.invalidate(); next = "/login.html"; // JSP destino } RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(next); dispatcher.forward(request, response); }
/** all processing methods end up here */ private void startHereCommon() throws BeanException { // try to get the linkKey if already set in input properties try { hPubLinkKey = inputProps.getHPubLinkKey(); } catch (Exception e) { } // if running in Web environment and either the ejb access handle or // the linkKey are null, try to get them from the HttpSession if (oHttpServletRequest != null) { HttpSession theWebsession = oHttpServletRequest.getSession(false); if (theWebsession != null) { synchronized (theWebsession) { try { if (tracing == true) { traceArgs[0] = this; traceArgs[1] = "HttpSession.getId()=" + theWebsession.getId(); try { traceMethod.invoke(o, traceArgs); } catch (Exception x) { } } String theKey = KEY_WEBCONN + inputProps.getHPubStartChainName(); // if linkKey or access handle is null try to get it from Websession HPubEJB2HttpSessionBindingListener sbl = (HPubEJB2HttpSessionBindingListener) theWebsession.getAttribute(theKey); if ((hPubLinkKey == null) && (sbl != null)) { hPubLinkKey = sbl.getLinkKey(); if (tracing == true) { traceArgs[0] = this; traceArgs[1] = "HttpSession.getAttribute(hPubLinkKey)=" + hPubLinkKey; try { traceMethod.invoke(o, traceArgs); } catch (Exception x) { } } inputProps.setHPubLinkKey(hPubLinkKey); } if ((hPubAccessHandle == null) && (sbl != null)) { hPubAccessHandle = sbl.getEjbHandle(); if (tracing == true) { traceArgs[0] = this; traceArgs[1] = "HttpSession.getAttribute(hPubAccessHandle)=" + hPubAccessHandle; try { traceMethod.invoke(o, traceArgs); } catch (Exception x) { } } } // set the ejb handle to null before removing the Session Binding // Listener object if (auditing == true) { if (sbl != null) auditArgs[0] = "\n---\nOUT:" + this.getClass().getName() + " " + theKey + " " + hPubAccessHandle + " " + hPubLinkKey + " " + theWebsession.getId(); else // error - object not found in HttpSession auditArgs[0] = "\n---\nERR:" + this.getClass().getName() + " " + theKey + " " + theWebsession.getId(); auditArgs[1] = theWebsession; try { auditMethod.invoke(o, auditArgs); } catch (Exception x) { } } if (sbl != null) sbl.setEjbHandle(null); theWebsession.removeAttribute(theKey); } catch (IllegalStateException e) { } } } } // if either of required properties are still null then the ejb cannot // be accessed - throw an exception. if ((hPubAccessHandle == null) || (hPubLinkKey == null)) { String errMsg = (new Date(System.currentTimeMillis())).toString() + " HPS5951 " + this.getClass().getName() + ": hPubAccessHandle==null || hPubLinkKey==null"; System.err.println(errMsg); if (tracing == true) { traceArgs[0] = this; traceArgs[1] = errMsg; try { traceMethod.invoke(o, traceArgs); } catch (Exception x) { } } throw new BeanException(errMsg); } else { if (tracing == true) { traceArgs[0] = this; traceArgs[1] = "hPubAccessHandle=" + hPubAccessHandle + ",hPubLinkKey=" + hPubLinkKey; try { traceMethod.invoke(o, traceArgs); } catch (Exception x) { } } } // get the EJB object from the handle try { ejb = (com.ibm.HostPublisher.EJB.HPubEJB2) javax.rmi.PortableRemoteObject.narrow( hPubAccessHandle.getEJBObject(), com.ibm.HostPublisher.EJB.HPubEJB2.class); } catch (Exception e) { String errMsg = (new Date(System.currentTimeMillis())).toString() + " HPS5952 " + this.getClass().getName() + ": getEJBObject(): " + e.getClass().getName() + ": " + e.getMessage(); System.err.println(errMsg); if (tracing == true) { traceArgs[0] = this; traceArgs[1] = errMsg; try { traceMethod.invoke(o, traceArgs); } catch (Exception x) { } } throw new BeanException(errMsg); } // if ejb handle, go invoke the HPubEJB's main business method. if (ejb != null) { try { outputProps = (CrownCounselIndexGetList_Properties) ejb.processIO(inputProps); inputProps = outputProps; inputProps.setInitialCall(false); } catch (Exception e) { String errMsg = (new Date(System.currentTimeMillis())).toString() + " HPS5953 " + this.getClass().getName() + ": processIO(" + inputProps.getClass().getName() + "): " + e.getClass().getName() + ": " + e.getMessage(); System.err.println(errMsg); if (tracing == true) { traceArgs[0] = this; traceArgs[1] = errMsg; try { traceMethod.invoke(o, traceArgs); } catch (Exception x) { } } throw new BeanException(errMsg); } } endHereCommon(); return; }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); HttpSession session = request.getSession(false); String reseller = null; if (session != null && session.getAttribute("reseller") != null) reseller = "%" + session.getAttribute("reseller") + "%"; List<LicenseData> searchResult = null; if (reseller != null) { /* session.setAttribute("fieldsearch", true); session.removeAttribute("datesearch");*/ if (request.getParameter("so") != null && !request.getParameter("so").isEmpty()) { log.info( "Search Fields : Sales Order Search " + request.getParameter("so") + " for reseller " + session.getAttribute("reseller")); searchResult = getSearchByFieldResults(reseller, request.getParameter("so"), "so"); session.setAttribute("so", request.getParameter("so")); session.removeAttribute("enduser"); session.removeAttribute("ek"); session.setAttribute("label", "Sales Order"); session.setAttribute("value", request.getParameter("so")); } else if (request.getParameter("enduser") != null && !request.getParameter("enduser").isEmpty()) { log.info( "Search Fields : End User Search " + request.getParameter("enduser") + " for reseller " + session.getAttribute("reseller")); searchResult = getSearchByFieldResults(reseller, request.getParameter("enduser"), "enduser"); session.setAttribute("enduser", request.getParameter("enduser")); session.removeAttribute("so"); session.removeAttribute("sno"); session.removeAttribute("ek"); session.setAttribute("label", "End User"); session.setAttribute("value", request.getParameter("enduser")); } else if (request.getParameter("ek") != null && !request.getParameter("ek").isEmpty()) { log.info( "Search Fields : Entitlement Key Search " + request.getParameter("ek") + " for reseller " + session.getAttribute("reseller")); searchResult = getSearchByFieldResults(reseller, request.getParameter("ek"), "ek"); session.setAttribute("ek", request.getParameter("ek")); session.removeAttribute("so"); session.removeAttribute("sno"); session.removeAttribute("enduser"); session.setAttribute("label", "Entitlement Key"); session.setAttribute("value", request.getParameter("ek")); } else if (request.getParameter("sno") != null && !request.getParameter("sno").isEmpty()) { log.info( "Search Fields : Serial Number Search " + request.getParameter("sno") + " for reseller " + session.getAttribute("reseller")); searchResult = getSearchByFieldResults(reseller, request.getParameter("sno"), "sno"); session.setAttribute("sno", request.getParameter("sno")); session.removeAttribute("ek"); session.removeAttribute("so"); session.removeAttribute("enduser"); request.setAttribute("sno", 1); session.setAttribute("label", "Serial Number"); session.setAttribute("value", request.getParameter("sno")); } else if (request.getParameter("po") != null && !request.getParameter("po").isEmpty()) { log.info( "Search Fields : Purchase Order Search " + request.getParameter("po") + " for reseller " + session.getAttribute("reseller")); searchResult = getSearchByFieldResults(reseller, request.getParameter("po"), "po"); session.setAttribute("po", request.getParameter("po")); session.setAttribute("label", "Purchase Order"); session.setAttribute("value", request.getParameter("po")); } else if (request.getParameter("hm") != null && !request.getParameter("hm").isEmpty()) { log.info( "Search Fields : HM ID Search " + request.getParameter("hm") + " for reseller " + session.getAttribute("hm")); searchResult = getSearchByFieldResults(reseller, request.getParameter("hm"), "hm"); session.setAttribute("hm", request.getParameter("hm")); session.setAttribute("label", "Hive Manager ID"); session.setAttribute("value", request.getParameter("hm")); } session.setAttribute("fieldSearchList", searchResult); String nextJSP = "/viewFieldSearchResult.jsp"; RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP); dispatcher.forward(request, response); } else { log.info("Search Fields : Reseller Blank "); String nextJSP = "/login.jsp"; RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP); dispatcher.forward(request, response); } }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); // All request in GET method must be certificated Object obj = session.getAttribute("device_id"); if (!(obj instanceof Long)) { // Client must be login first, then use Mobile service response.setStatus(404); return; } response.setContentType("text/plain"); PrintWriter out = response.getWriter(); // Here is tracked's id Long device_id = (Long) obj; // Determine operation type String op = request.getParameter("op"); if (op == null) op = ""; // Get current track Long track_id = null; obj = session.getAttribute("track_id"); if (obj instanceof Long) { track_id = (Long) obj; } if (op.equals("logout")) { // Client request a logout operation session.removeAttribute("device_id"); session.removeAttribute("track_id"); out.print("OK," + device_id); } else if (op.equals("latlng")) { // Client insert update it's location in latitude/longitude // If it's a first waypoint, create a new track if (track_id == null) { track_id = db.newTrack(device_id).getResult().getTrackID(); session.setAttribute("track_id", track_id); } // Parse latitude, longitude from request double lat = Double.parseDouble(request.getParameter("lat")); double lng = Double.parseDouble(request.getParameter("lng")); long speed = -1L; try { // Try to get speed from request speed = Long.parseLong(request.getParameter("spd")); } catch (Exception ex) { } if (speed < 0) { // Client don't send speed to server try { // Calculate speed manually double lastLat = (Double) session.getAttribute("latitude"); double lastLng = (Double) session.getAttribute("longitude"); long time = (Long) session.getAttribute("time"); long distance = Utils.getDistance(lastLat, lastLng, lat, lng); speed = distance * 1000 / Math.abs(time - System.currentTimeMillis()); } catch (Exception ex) { speed = 0L; } } // Insert new point into server ServiceResult<CWaypoint> result = db.insertWaypoint(track_id, lat, lng, speed); CWaypoint cwaypoint = result.getResult(); if (result.isOK()) { // OK,latitude,longitude,speed(m/s),time,trackid session.setAttribute("latitude", lat); session.setAttribute("longitude", lng); session.setAttribute("time", cwaypoint.getTime().getTime()); out.print( "OK," + cwaypoint.getLat() + "," + cwaypoint.getLng() + "," + cwaypoint.getSpeed() + "," + cwaypoint.getTime().getTime() + "," + cwaypoint.getTrackID()); } } else if (op.equals("cellid")) { // Client send it's location by cellular technique if (track_id == null) { track_id = db.newTrack(device_id).getResult().getTrackID(); session.setAttribute("track_id", track_id); } try { int cell = Integer.parseInt(request.getParameter("cell")); int lac = Integer.parseInt(request.getParameter("lac")); Geocode geocode = Utils.getLocation(cell, lac); out.println(geocode.getLatitude() + "," + geocode.getLongitude()); } catch (Exception ex) { } // TODO Implements cellular method to calculate location of a mobile out.println("Not implement"); } else if (op.equals("newtrack")) { // Client request to create a new track track_id = db.newTrack(device_id).getResult().getTrackID(); session.setAttribute("track_id", track_id); out.print("OK," + track_id); } else if (op.equals("changepass")) { String newpass = request.getParameter("newpass"); if (newpass != null) { CTracked ctracked = new CTracked(); ctracked.setUsername(device_id); ctracked.setPassword(newpass); if (db.updateTracked(ctracked).isOK()) { out.println("OK," + device_id); } } } else if (op.equals("config")) { CTracked ctracked = db.getTracked(device_id).getResult(); Integer interval = ctracked.getIntervalGps(); if (interval == null) interval = 10; out.print("OK," + interval + ","); byte[] b = ctracked.getSchedule(); if (b == null) { for (int i = 0; i < 23; i++) { out.print("1."); } out.println(1); } else { for (int i = 0; i < 23; i++) { out.print(b[i] + "."); } out.println(b[23]); } } else if (op.equals("amilogin")) { out.println("OK"); } }
/** * Perform form authentication. Called from SecurityHandler. * * @return UserPrincipal if authenticated else null. */ public Principal authenticate( UserRealm realm, String pathInContext, HttpRequest httpRequest, HttpResponse httpResponse) throws IOException { HttpServletRequest request = (ServletHttpRequest) httpRequest.getWrapper(); HttpServletResponse response = httpResponse == null ? null : (HttpServletResponse) httpResponse.getWrapper(); // Handle paths String uri = pathInContext; // Setup session HttpSession session = request.getSession(response != null); if (session == null) return null; // Handle a request for authentication. if (uri.substring(uri.lastIndexOf("/") + 1).startsWith(__J_SECURITY_CHECK)) { // Check the session object for login info. FormCredential form_cred = new FormCredential(); form_cred.authenticate( realm, request.getParameter(__J_USERNAME), request.getParameter(__J_PASSWORD), httpRequest); String nuri = (String) session.getAttribute(__J_URI); if (nuri == null || nuri.length() == 0) { nuri = request.getContextPath(); if (nuri.length() == 0) nuri = "/"; } if (form_cred._userPrincipal != null) { // Authenticated OK if (log.isDebugEnabled()) log.debug("Form authentication OK for " + form_cred._jUserName); session.removeAttribute(__J_URI); // Remove popped return URI. httpRequest.setAuthType(SecurityConstraint.__FORM_AUTH); httpRequest.setAuthUser(form_cred._jUserName); httpRequest.setUserPrincipal(form_cred._userPrincipal); session.setAttribute(__J_AUTHENTICATED, form_cred); // Sign-on to SSO mechanism if (realm instanceof SSORealm) { ((SSORealm) realm) .setSingleSignOn( httpRequest, httpResponse, form_cred._userPrincipal, new Password(form_cred._jPassword)); } // Redirect to original request if (response != null) { response.setContentLength(0); response.sendRedirect(response.encodeRedirectURL(nuri)); } } else if (response != null) { if (log.isDebugEnabled()) log.debug("Form authentication FAILED for " + form_cred._jUserName); if (_formErrorPage != null) { response.setContentLength(0); response.sendRedirect( response.encodeRedirectURL(URI.addPaths(request.getContextPath(), _formErrorPage))); } else { response.sendError(HttpResponse.__403_Forbidden); } } // Security check is always false, only true after final redirection. return null; } // Check if the session is already authenticated. FormCredential form_cred = (FormCredential) session.getAttribute(__J_AUTHENTICATED); if (form_cred != null) { // We have a form credential. Has it been distributed? if (form_cred._userPrincipal == null) { // This form_cred appears to have been distributed. Need to reauth form_cred.authenticate(realm, httpRequest); // Sign-on to SSO mechanism if (form_cred._userPrincipal != null && realm instanceof SSORealm) { ((SSORealm) realm) .setSingleSignOn( httpRequest, httpResponse, form_cred._userPrincipal, new Password(form_cred._jPassword)); } } else if (!realm.reauthenticate(form_cred._userPrincipal)) // Else check that it is still authenticated. form_cred._userPrincipal = null; // If this credential is still authenticated if (form_cred._userPrincipal != null) { if (log.isDebugEnabled()) log.debug("FORM Authenticated for " + form_cred._userPrincipal.getName()); httpRequest.setAuthType(SecurityConstraint.__FORM_AUTH); httpRequest.setAuthUser(form_cred._userPrincipal.getName()); httpRequest.setUserPrincipal(form_cred._userPrincipal); return form_cred._userPrincipal; } else session.setAttribute(__J_AUTHENTICATED, null); } else if (realm instanceof SSORealm) { // Try a single sign on. Credential cred = ((SSORealm) realm).getSingleSignOn(httpRequest, httpResponse); if (httpRequest.hasUserPrincipal()) { form_cred = new FormCredential(); form_cred._userPrincipal = request.getUserPrincipal(); form_cred._jUserName = form_cred._userPrincipal.getName(); if (cred != null) form_cred._jPassword = cred.toString(); if (log.isDebugEnabled()) log.debug("SSO for " + form_cred._userPrincipal); httpRequest.setAuthType(SecurityConstraint.__FORM_AUTH); session.setAttribute(__J_AUTHENTICATED, form_cred); return form_cred._userPrincipal; } } // Don't authenticate authform or errorpage if (isLoginOrErrorPage(pathInContext)) return SecurityConstraint.__NOBODY; // redirect to login page if (response != null) { if (httpRequest.getQuery() != null) uri += "?" + httpRequest.getQuery(); session.setAttribute( __J_URI, request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + URI.addPaths(request.getContextPath(), uri)); response.setContentLength(0); response.sendRedirect( response.encodeRedirectURL(URI.addPaths(request.getContextPath(), _formLoginPage))); } return null; }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { int i = 1; HttpSession session = request.getSession(true); agendaSeq = request.getParameter("agendaSeq"); decision = request.getParameter("decision"); decisionLevel = request.getParameter("decisionLevel"); decisionSeqno = request.getParameter("decisionSeqno"); parentDecision = request.getParameter("parentDecision"); sortSeq = request.getParameter("sortSeq"); numbering = request.getParameter("numbering"); formName = request.getParameter("formName"); dueDate = request.getParameter("dueDate"); decisionSeq = request.getParameter("decisionSeq"); decisionCategory = request.getParameter("decisionCat"); String str3 = (String) session.getAttribute("decisionMtgCode"); session.removeAttribute("errmsg"); if ((this.decision == null) || (this.decision.length() == 0)) { this.errorMssg = "The decision is not specified."; i = 0; } if (i != 0) { Connection conn = null; DBConnectionPool dbPool = null; try { dbPool = TvoDBConnectionPoolFactory.getConnectionPool(request); conn = dbPool.getConnection(); if (conn != null) { MeetingDecision md = (MeetingDecision) session.getAttribute("mtgdecision"); if (md == null) { md = (MeetingDecision) Beans.instantiate( super.getClass().getClassLoader(), "cms.admin.meeting.bean.MeetingDecision"); session.setAttribute("mtgdecision", md); } if (md != null) { md.setDBConnection(conn); md.setDecisionSeq(this.decisionSeq); md.setAgendaSeq(this.agendaSeq.trim()); md.setDecision(this.decision); md.setDecisionLevel(this.decisionLevel); md.setDecisionSeqno(this.decisionSeqno.trim()); md.setParentDecision(this.parentDecision); md.setSortSeq(this.sortSeq); md.setNumbering(this.numbering); md.setDueDate(this.dueDate); md.setDecisionCategory(decisionCategory); String action = request.getParameter("action"); if (action.equals("Update")) { if (md.updateMtgDecision()) { i = 1; } else { i = 0; this.errorMssg = "Update Not Successful"; session.setAttribute("errmsg", md.getErrorMessage() + md.getSQL()); } } else if (action.equals("Remove")) { if (md.removeMtgDecision(request, super.getServletContext(), this.agendaSeq)) { i = 1; } else { this.errorMssg = "Delete not Successful"; i = 0; } } else if (action.equals("updateDecCat")) { if (md.updateDecisionCategory()) { i = 1; } else { this.errorMssg = "Update not Successful"; i = 0; } } } else { i = 0; this.errorMssg = "Meeting Decision object is not available."; } } else { i = 0; this.errorMssg = "Connection to database is not available."; } } catch (Exception ex) { this.errorMssg = "Error"; ex.printStackTrace(); session.setAttribute("errmsg", ex.toString()); i = 0; } finally { dbPool.returnConnection(conn); } } if (i != 0) CommonFunction.printAlert( request, response, "Update Successful", "eMeeting.jsp?action=Decision&meetingCode=" + str3 + "#" + this.formName); else CommonFunction.printAlert( request, response, this.errorMssg, "eMeeting.jsp?action=Decision&meetingCode=" + str3 + "#" + this.formName); }
/** * 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"); request.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); try { String lien = ""; HttpSession sessionHttp = request.getSession(); // Pour le log du personnel if (request.getParameter("login") != null && request.getParameter("pwd") != null) { String login = request.getParameter("login"); String pwd = request.getParameter("pwd"); // On crypte le mot de passe String pwdCrypt = cryptPassword(pwd); Personnel lePersonnel = new Personnel(); // On récupère un objet de type Personnel grâce à la fonction de connexion de cette classe lePersonnel = this.getUnPersonnel().connexionPersonnel(login, pwdCrypt); if (!lePersonnel.getLogin().equals("loginPwdErrone")) { if (lePersonnel.getLogin().equals("superAdmin")) { ArrayList<Service> lesServices = this.getUnService().rechercherServices(); request.setAttribute("lesServices", lesServices); lien = "/Vue/adminProfils.jsp"; } else { lien = "/Vue/apercuDossiers.jsp"; } } else { lien = "/index.jsp?e=loginMdpErrone&login="******"/Vue/creationDossier.jsp?login="******"&pwd=" + pwdCrypt; sessionHttp.setAttribute("personnel", lePersonnel); // Pour la déconnexion du personnel /*} else if (request.getParameter("co").equals("logout")) { sessionHttp.removeAttribute("personnel"); lien = "/index.jsp";*/ // Déconnexion du personnel } else if (request.getParameter("co") != null) { if (request.getParameter("co").equals("logout")) { sessionHttp.removeAttribute("personnel"); lien = "/index.jsp"; } // Gestion du menu } else if (request.getParameter("page") != null) { if (request.getParameter("page").equals("apercuDossiers")) { lien = "/Vue/apercuDossiers.jsp"; } // Recherche d'un dossier } else if (request.getParameter("recherche_dossier") != null) { String recherche = request.getParameter("recherche_dossier"); ArrayList<Patient> lesPatients = new ArrayList<Patient>(); lesPatients = this.getUnPatient().rechercherPatients(recherche, 2); request.setAttribute("lesPatients", lesPatients); request.setAttribute("recherche", recherche); lien = "/Vue/apercuDossiers.jsp"; // Ajout d'un profil de personnel } else if (request.getParameter("login_ajout_profil") != null) { String nom = StringToMySQL(request.getParameter("nom_ajout_profil").toUpperCase()); String prenom = StringToMySQL(request.getParameter("prenom_ajout_profil")); String login = StringToMySQL(request.getParameter("login_ajout_profil")); String pwd = request.getParameter("pwd_ajout_profil"); String pwdCrypt = cryptPassword(pwd); String telDom = request.getParameter("telDom_ajout_profil"); String telPort = request.getParameter("telPort_ajout_profil"); String dateNaiss = dateToMySQL(request.getParameter("dateNaiss_ajout_profil")); String lieuNaiss = StringToMySQL(request.getParameter("lieuNaiss_ajout_profil")); String dateEmbauch = dateToMySQL(request.getParameter("dateEmbauch_ajout_profil")); String specMed = request.getParameter("speMed_ajout_profil"); Boolean adminBool = false; if (request.getParameter("affect_ajout_profil").equals("1")) { adminBool = true; } String adresse = StringToMySQL(request.getParameter("adr_ajout_profil")); String cp = request.getParameter("cp_ajout_profil"); String ville = StringToMySQL(request.getParameter("ville_ajout_profil")); int idService = Integer.parseInt(request.getParameter("service_ajout_profil")); Adresse sonAdresse = new Adresse(0, adresse, cp, ville); Service sonService = new Service(idService, ""); Personnel lePersonnel = new Personnel( 0, nom, prenom, login, pwdCrypt, telDom, telPort, dateNaiss, lieuNaiss, dateEmbauch, specMed, adminBool, sonAdresse, sonService); this.getUnPersonnel().ajouterPersonnel(lePersonnel); lien = "/index.jsp"; // Lien vers la page de création d'un nouveau dossier } else if (request.getParameter("btn_lien_creation_dossier") != null) { ArrayList<Service> lesServices = this.getUnService().rechercherServices(); request.setAttribute("lesServices", lesServices); lien = "/Vue/creationDossier.jsp"; // Lien vers la page de création d'une nouvelle prescription (traitement ou bien // intervention chirurgicale) } else if (request.getParameter("type_lien_creation_prescription") != null) { request.setAttribute("idDossier", request.getParameter("id_dossier")); if (request.getParameter("type_lien_creation_prescription").equals("intervention")) { lien = "/Vue/creationChirurgie.jsp"; } else { lien = "/Vue/creationPrescription.jsp"; } // Création d'un dossier et d'un patient } else if (request.getParameter("nom_ajout_patient") != null) { String nom_patient = StringToMySQL(request.getParameter("nom_ajout_patient").toUpperCase()); String prenom_patient = request.getParameter("prenom_ajout_patient"); String adr_patient = StringToMySQL(request.getParameter("rue_ajout_patient")); String cp_patient = request.getParameter("cp_ajout_patient"); String ville_patient = StringToMySQL(request.getParameter("ville_ajout_patient")); String num_secu_patient = request.getParameter("num_secu_ajout_patient") + request.getParameter("num_secu2_ajout_patient"); String complementaire_dossier = StringToMySQL(request.getParameter("complementaire_ajout_dossier")); String nom_personne_prevenir_dossier = StringToMySQL( request.getParameter("nom_personne_prevenir_ajout_dossier").toUpperCase()); String prenom_personne_prevenir_dossier = request.getParameter("prenom_personne_prevenir_ajout_dossier"); String tel_personne_prevenir_dossier = request.getParameter("tel_personne_prevenir_ajout_dossier"); String nom_personne_confiance_dossier = StringToMySQL( request.getParameter("nom_personne_confiance_ajout_dossier").toUpperCase()); String prenom_personne_confiance_dossier = request.getParameter("prenom_personne_confiance_ajout_dossier"); String tel_personne_confiance_dossier = request.getParameter("tel_personne_confiance_ajout_dossier"); String medecin_traitant_dossier = StringToMySQL(request.getParameter("medecin_traitant_ajout_dossier")); String tel_medecin_traitant_dossier = request.getParameter("tel_medecin_traitant_ajout_dossier"); int chambre_patient = Integer.parseInt(request.getParameter("chambre_ajout_patient")); Service sonService = new Service(0, ""); Chambre saChambre = new Chambre(chambre_patient, 0, true, sonService); Dossier sonDossier = new Dossier( 0, complementaire_dossier, nom_personne_prevenir_dossier, nom_personne_confiance_dossier, medecin_traitant_dossier, prenom_personne_prevenir_dossier, prenom_personne_confiance_dossier, tel_personne_prevenir_dossier, tel_personne_confiance_dossier, tel_medecin_traitant_dossier, false, false); Adresse sonAdresse = new Adresse(0, adr_patient, cp_patient, ville_patient); Patient lePatient = new Patient( 0, nom_patient, prenom_patient, num_secu_patient, sonAdresse, sonDossier, saChambre); this.getUnPatient().ajouterPatient(lePatient); lien = "/Vue/apercuDossiers.jsp"; // Lien pour afficher les informations sur un dossier } else if (request.getParameter("champ_visualisation_dossier") != null) { Personnel lePersonnel = (Personnel) sessionHttp.getAttribute("personnel"); String idPatient = request.getParameter("champ_visualisation_dossier"); ArrayList<Patient> lesPatients = new ArrayList<Patient>(); lesPatients = this.getUnPatient().rechercherPatients(idPatient, 1); Patient lePatient = new Patient(); lePatient = lesPatients.get(0); // Si le personnel est administratif if (lePersonnel.getAdminBool()) { ArrayList<Service> lesServices = this.getUnService().rechercherServices(); request.setAttribute("lesServices", lesServices); ArrayList<Chambre> lesChambres = this.getUneChambre() .rechercherChambresLibres( lePatient.getUneChambre().getUnService().getIdService().toString()); request.setAttribute("lesChambres", lesChambres); request.setAttribute("lePatient", lePatient); lien = "/Vue/modifDossier.jsp"; // Si le personnel est un médecin } else { int idDossier = lePatient.getUnDossier().getId(); ArrayList<Prescription> lesPrescriptions = this.getUnePrescription().rechercherPrescriptions("" + idDossier); request.setAttribute("lesPrescriptions", lesPrescriptions); String stringIdDossier = "" + idDossier; request.setAttribute("idDossier", stringIdDossier); lien = "/Vue/apercuPrescriptions.jsp"; } // Modification d'un dossier et d'un patient } else if (request.getParameter("nom_modif_patient") != null) { String nom_patient = StringToMySQL(request.getParameter("nom_modif_patient").toUpperCase()); String prenom_patient = request.getParameter("prenom_modif_patient"); String adr_patient = StringToMySQL(request.getParameter("rue_modif_patient")); String cp_patient = request.getParameter("cp_modif_patient"); String ville_patient = StringToMySQL(request.getParameter("ville_modif_patient")); String num_secu_patient = request.getParameter("num_secu_modif_patient") + request.getParameter("num_secu2_modif_patient"); String complementaire_dossier = StringToMySQL(request.getParameter("complementaire_modif_dossier")); String nom_personne_prevenir_dossier = StringToMySQL( request.getParameter("nom_personne_prevenir_modif_dossier").toUpperCase()); String prenom_personne_prevenir_dossier = request.getParameter("prenom_personne_prevenir_modif_dossier"); String tel_personne_prevenir_dossier = request.getParameter("tel_personne_prevenir_modif_dossier"); String nom_personne_confiance_dossier = StringToMySQL( request.getParameter("nom_personne_confiance_modif_dossier").toUpperCase()); String prenom_personne_confiance_dossier = request.getParameter("prenom_personne_confiance_modif_dossier"); String tel_personne_confiance_dossier = request.getParameter("tel_personne_confiance_modif_dossier"); String medecin_traitant_dossier = StringToMySQL(request.getParameter("medecin_traitant_modif_dossier")); String tel_medecin_traitant_dossier = request.getParameter("tel_medecin_traitant_modif_dossier"); int chambre_patient = Integer.parseInt(request.getParameter("chambre_modif_patient")); int idService = Integer.parseInt(request.getParameter("service")); int idPatient = Integer.parseInt(request.getParameter("id_modif_patient")); int idDossier = Integer.parseInt(request.getParameter("idDossier_modif_patient")); int idAdresse = Integer.parseInt(request.getParameter("idAdresse_modif_patient")); String ancienneChambre = request.getParameter("idChambre_modif_patient"); Service sonService = new Service(idService, ""); Chambre saChambre = new Chambre(chambre_patient, 0, true, sonService); Dossier sonDossier = new Dossier( idDossier, complementaire_dossier, nom_personne_prevenir_dossier, nom_personne_confiance_dossier, medecin_traitant_dossier, prenom_personne_prevenir_dossier, prenom_personne_confiance_dossier, tel_personne_prevenir_dossier, tel_personne_confiance_dossier, tel_medecin_traitant_dossier, false, false); Adresse sonAdresse = new Adresse(idAdresse, adr_patient, cp_patient, ville_patient); Patient lePatient = new Patient( idPatient, nom_patient, prenom_patient, num_secu_patient, sonAdresse, sonDossier, saChambre); this.getUnPatient().modifierPatient(lePatient, ancienneChambre); lien = "/Vue/apercuDossiers.jsp"; // Affichage des informations d'une prescription } else if (request.getParameter("champ_visualisation_prescription") != null) { String idPrescription = request.getParameter("champ_visualisation_prescription"); Prescription laPrescription = this.getUnePrescription().rechercherUnePrescription(idPrescription); request.setAttribute("laPrescription", laPrescription); lien = "/Vue/apercuUnePrescription.jsp"; // Ajout d'une prescription d'un traitement } else if (request.getParameter("nom_medecin_ajout_prescription") != null) { String idDossier = request.getParameter("id_dossier"); ArrayList<Medicament> lesMedicaments = new ArrayList<Medicament>(); Personnel lePersonnel = (Personnel) sessionHttp.getAttribute("personnel"); String idPersonnel = "" + lePersonnel.getId(); Enumeration flds = request.getParameterNames(); while (flds.hasMoreElements()) { String element = (String) flds.nextElement(); String[] tab_med = element.split("medic"); int length = tab_med.length; if (length > 1) { int num = Integer.parseInt(tab_med[1]); String nom_medic = StringToMySQL(request.getParameter(element)); String nom_poso = StringToMySQL(request.getParameter("poso" + num)); Medicament leMedicament = new Medicament(0, nom_medic, nom_poso); lesMedicaments.add(leMedicament); } // String value = request.getParameter(test);*/ } this.getUnePrescription().creerPrescription(lesMedicaments, idPersonnel, idDossier); ArrayList<Prescription> lesPrescriptions = this.getUnePrescription().rechercherPrescriptions("" + idDossier); request.setAttribute("lesPrescriptions", lesPrescriptions); String stringIdDossier = "" + idDossier; request.setAttribute("idDossier", stringIdDossier); lien = "/Vue/apercuPrescriptions.jsp"; // Ajout d'une intervention chirurgicale } else if (request.getParameter("nom_medecin_ajout_intervention") != null) { String idDossier = request.getParameter("id_dossier"); Personnel lePersonnel = (Personnel) sessionHttp.getAttribute("personnel"); String idPersonnel = "" + lePersonnel.getId(); InterChirurgicale lInterChirurgicale = new InterChirurgicale( 0, StringToMySQL(request.getParameter("type_creation_inter")), StringToMySQL(request.getParameter("remarque_creation_inter"))); this.getUnePrescription() .creerInterChirurgicale(lInterChirurgicale, idPersonnel, idDossier); ArrayList<Prescription> lesPrescriptions = this.getUnePrescription().rechercherPrescriptions("" + idDossier); request.setAttribute("lesPrescriptions", lesPrescriptions); String stringIdDossier = "" + idDossier; request.setAttribute("idDossier", stringIdDossier); lien = "/Vue/apercuPrescriptions.jsp"; // Gestion de la sortie des patients } else if (request.getParameter("champ_sortie_id_patient") != null) { // Si c'est pour la sortie du patient if (request.getParameter("champ_sortie_patient_type").equals("sortie")) { // Si c'est un médecin if (request.getParameter("champ_sortie_patient_type_personnel").equals("Medecin")) { // On autorise la sortie this.getUnDossier().autoriserSortie(request.getParameter("champ_sortie_id_patient")); } else { // On enregistre la sortie this.getUnDossier().enregistrerSortie(request.getParameter("champ_sortie_id_patient")); } lien = "/Vue/apercuDossiers.jsp"; // Si c'est pour l'admission du patient } else { String idPatient = request.getParameter("champ_sortie_id_patient"); ArrayList<Patient> lesPatients = new ArrayList<Patient>(); lesPatients = this.getUnPatient().rechercherPatients(idPatient, 1); Patient lePatient = new Patient(); lePatient = lesPatients.get(0); ArrayList<Service> lesServices = this.getUnService().rechercherServices(); request.setAttribute("lesServices", lesServices); ArrayList<Chambre> lesChambres = this.getUneChambre() .rechercherChambresLibres( lePatient.getUneChambre().getUnService().getIdService().toString()); request.setAttribute("lesChambres", lesChambres); request.setAttribute("lePatient", lePatient); lien = "/Vue/modifDossier.jsp"; } } else { lien = "/index.jsp"; } getServletContext().getRequestDispatcher(lien).forward(request, response); } finally { out.close(); } }