public Event perform(HttpServletRequest request) throws HTMLActionException { HttpSession session = request.getSession(); // look up the adventure transportation AdventureComponentManager acm = (AdventureComponentManager) session.getAttribute(AdventureKeys.COMPONENT_MANAGER); Cart cart = acm.getCart(session); String origin = request.getParameter("origin"); // if we are doing a search for a different flight from the cart page if (origin == null) { origin = cart.getOrigin(); } else { cart.setOrigin(origin); } String noTransport = request.getParameter("no_transport"); String showTransport = request.getParameter("show_flights"); Locale locale = new Locale("en", "us"); String destination = cart.getDestination(); // access catalog component and retrieve data from the database List transpDepartureBeans = searchTransportation(origin, destination, locale); List transpReturnBeans = searchTransportation(destination, origin, locale); // places result bean data in the request request.setAttribute("departure_result", transpDepartureBeans); request.setAttribute("return_result", transpReturnBeans); request.setAttribute("search_target", "transportation"); return null; }
// post方式发送email public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); File file = doAttachment(request); EmailAttachment attachment = new EmailAttachment(); attachment.setPath(file.getPath()); attachment.setDisposition(EmailAttachment.ATTACHMENT); attachment.setName(file.getName()); MultiPartEmail email = new MultiPartEmail(); email.setCharset("UTF-8"); email.setHostName("smtp.sina.com"); email.setAuthentication("T-GWAP", "dangdang"); try { email.addTo(parameters.get("to")); email.setFrom(parameters.get("from")); email.setSubject(parameters.get("subject")); email.setMsg(parameters.get("body")); email.attach(attachment); email.send(); request.setAttribute("sendmail.message", "邮件发送成功!"); } catch (EmailException e) { Logger logger = Logger.getLogger(SendAttachmentMailServlet.class); logger.error("邮件发送不成功", e); request.setAttribute("sendmail.message", "邮件发送不成功!"); } request.getRequestDispatcher("/sendResult.jsp").forward(request, response); }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String amount = request.getParameter("amount"); String amount2 = request.getParameter("amount2"); String amount3 = request.getParameter("amount3"); Integer posotita = Integer.parseInt(amount); Integer posotita2 = Integer.parseInt(amount2); Integer posotita3 = Integer.parseInt(amount3); HttpSession session = request.getSession(); if (session.isNew()) { request.setAttribute("sessionVal", "this is a new session"); } else { request.setAttribute("sessionVal", "Welcome Back!"); } double total = ((posotita * 18.50) + (posotita2 * 6.95) + (posotita3 * 1.29)); session.setAttribute("totalVal", total); request.setAttribute("currency", total); request.setAttribute("from", amount); request.setAttribute("from2", amount2); request.setAttribute("from3", amount3); RequestDispatcher view = request.getRequestDispatcher("index.jsp"); view.forward(request, response); }
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { try { GpsImportForm gpsForm = (GpsImportForm) form; User user = (User) req.getSession().getAttribute("user"); int entryId = gpsForm.getEntryId(); String fileName = gpsForm.getFileName(); String title = gpsForm.getTitle(); String activityId = gpsForm.getActivityId(); String xml = gpsForm.getXml(); log.debug(xml); List<GpsTrack> tracks = new TcxParser().parse(xml.getBytes()); GpsTrack track = tracks.get(0); // Horrible hack. createAttachment(user, entryId, fileName, title, activityId, track); createGeotag(fileName, track); req.setAttribute("status", "success"); req.setAttribute("message", ""); log.debug("Returning status: success."); return mapping.findForward("results"); } catch (Exception e) { log.fatal("Error processing incoming Garmin XML", e); req.setAttribute("status", "failure"); req.setAttribute("message", e.toString()); return mapping.findForward("results"); } }
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // read the last post id here ....................... String url = req.getRequestURI(); String urlprt[] = url.split("/"); int urlcount = urlprt.length - 1; JSONParser parserPost = new JSONParser(); JSONObject post = null; String id = urlprt[urlcount]; // read the post here ............................. try { if (id != null) { Object objPost = parserPost.parse(new FileReader("..\\webapps\\Blog\\post\\" + id + ".json")); post = (JSONObject) objPost; String postauthor = post.get("author").toString(); String posttitle = post.get("title").toString(); String postcontent = post.get("content").toString(); JSONArray arr = (JSONArray) post.get("comments"); List<String> list = new ArrayList<String>(); Iterator<String> iterator = arr.iterator(); while (iterator.hasNext()) { list.add(iterator.next()); } int listsz = list.size(); String[] comments = new String[listsz]; for (int i = 0; i < listsz; i++) { comments[i] = list.get(i); } req.setAttribute("title", posttitle); req.setAttribute("content", postcontent); req.setAttribute("author", postauthor); req.setAttribute("comments", comments); req.setAttribute("id", id); req.getRequestDispatcher("/view.jsp").forward(req, res); } } catch (Exception e) { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("get POST ......................"); out.println(e); out.println("......................"); } }
/** * Utilizado como controlador de página para la acción de listar medidores. * * @param request * @param response * @throws ServletException * @throws IOException */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { MedidorModule module = (MedidorModule) context.getBean("medidorModule"); try { List data = module.listado(); request.setAttribute("medidores", data); forward("/listaMedidores.jsp", request, response); } catch (Exception e) { request.setAttribute("mensaje", e.getMessage()); forward("/paginaError.jsp", request, response); } }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { AcueductoModule module = (AcueductoModule) context.getBean("acueductoModule"); try { List data = module.listado(); request.setAttribute("acueductos", data); forward("/listaAcueductos.jsp", request, response); } catch (Exception e) { request.setAttribute("mensaje", e.getMessage()); forward(e.getMessage(), request, response); } }
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // res.setContentType("text/html"); // PrintWriter pw = res.getWriter(); // pw.println("Beer selection advice<br/>"); BeerExpert be = new BeerExpert(); String c = req.getParameter("color"); List result = be.getBrands(c); req.setAttribute("styles", result); String email = getServletConfig().getInitParameter("adminEmail"); RequestDispatcher view = req.getRequestDispatcher("result.jsp"); // try{ view.forward(req, res); // } catch (Exception e) { // System.out.println("some thing wrong in view.forward"); // e.printStackTrace(); // } // Iterator it = result.iterator(); // while(it.hasNext()){ // pw.println("<br/> tyr: " + it.next()); // } }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { /* -- pentru codul scris in java response.setContentType("text/thml"); PrintWriter out = response.getWriter(); out.println("Beer Selection Advice"); */ String c = request.getParameter("color"); /* se adauga clasa BeerExpert */ BeerExpert be = new BeerExpert(); List result = be.getBrands(c); /* out.println("Got beer color " + c); // afisare rezultate din metoda getBrends Iterator it = result.iterator(); while(it.hasNext()){ out.println("try: "+ it.next()); } */ /* cod folosit de aplicatia JSP */ request.setAttribute("styles", result); RequestDispatcher view = request.getRequestDispatcher("result.jsp"); view.forward(request, response); }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { EstacionBombeoModule module = (EstacionBombeoModule) context.getBean("estacionBombeoModule"); try { String presionSalida = request.getParameter("presionSalida"); int presionSalidaObj = Integer.parseInt(presionSalida); String presionEntrada = request.getParameter("presionEntrada"); int presionEntradaObj = Integer.parseInt(presionEntrada); String cantidadBombas = request.getParameter("cantidadBombas"); int cantidadBombasObj = Integer.parseInt(cantidadBombas); String capacidadMaxima = request.getParameter("capacidadMaxima"); int capacidadMaximaObj = Integer.parseInt(cantidadBombas); String idAcueducto = request.getParameter("idAcueducto"); int idAcueductoObj = Integer.parseInt(idAcueducto); String encargado = request.getParameter("encargado"); String tipo = request.getParameter("tipo"); String telefono = request.getParameter("telefono"); String nombreEstacion = request.getParameter("nombreEstacion"); module.insertar( presionSalidaObj, tipo, capacidadMaximaObj, cantidadBombasObj, encargado, telefono, presionEntradaObj, idAcueductoObj, nombreEstacion); response.sendRedirect("listaEstacionBombeos"); } catch (Exception e) { request.setAttribute("mensaje", e.getMessage()); forward(e.getMessage(), request, response); } }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ProfesorRepository profesores = (ProfesorRepository) context.getBean("profesorRepository"); try { String id = request.getParameter("id"); int idProf = Integer.parseInt(id); String cedula = request.getParameter("cedula"); String nombre = request.getParameter("nombre"); String titulo = request.getParameter("titulo"); String area = request.getParameter("area"); String telefono = request.getParameter("telefono"); Profesor prof = profesores.findProfesor(idProf); try { if (cedula != null) prof.setCedula(cedula); if (nombre != null) prof.setNombre(nombre); if (titulo != null) prof.setTitulo(titulo); if (area != null) prof.setArea(area); if (telefono != null) prof.setTelefono(telefono); profesores.updateProfesor(prof); } catch (Exception e) { } response.sendRedirect("listaProfesores"); } catch (Exception e) { request.setAttribute("mensaje", e.getMessage()); forward("/paginaError.jsp", request, response); } }
/*public static boolean isNumeric(String str) { try { int d = Integer.parseInt(str); } catch (NumberFormatException nfe) { return false; } return true; } }*/ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // get parameters from the request String firstName = request.getParameter("firstName"); String alamat = request.getParameter("alamat"); String telepon = request.getParameter("telepon"); String username = request.getParameter("username"); String pass = request.getParameter("pass"); String admin = request.getParameter("admin"); // get a relative file name ServletContext context; // ServletContext context = getServletContext(); String path; // String path = context.getRealPath("/WEB-INF/EmailList.txt"); // use regular Java classes User user = new User(firstName, alamat, telepon, username, pass, admin); // validate the parameters String message = ""; String url = ""; if (firstName.length() == 0 || alamat.length() == 0 || telepon.length() == 0 || username.length() == 0 || pass.length() == 0 || admin.length() == 0) { message = "Mohon isi semua data yang diperlukan"; url = "/tambah_user.jsp"; } else { message = ""; ModifyDB.addUser(user); url = "/display_email_entry.jsp"; } // UserIO.addRecord(user, path); // store the User object in the request object request.setAttribute("user", user); request.setAttribute("message", message); // forward request and response objects to JSP page // String url = "/display_email_entry.jsp"; // url = "/display_email_entry.jsp"; RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url); dispatcher.forward(request, response); }
private void processRequestDefault(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute(QueryBuilder.HTML_TITLE, GlobalProperties.getTitle()); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/jsp/tumormap/tumormap.jsp"); dispatcher.forward(request, response); }
/** * This calls the itemselection.jsp and list all items available for a WorkOrder and a WorkOrder's * item list * * @param workorderid - the WO_ID of the parent WorkOrder * @param request - servlet request * @param response - servlet response */ private void listProducts( long workorderId, WorkOrderDetailRemote workorderdetEJBean, HttpSession session, HttpServletRequest req, HttpServletResponse resp) { try { // If any product object is left over in session remove it session.removeValue("itemObj"); // Create db connection for EJB workorderdetEJBean.connect(); // Get the 2D Array which has the List of Items for the WorkOrder // grouped by the Billing System. Object[][] productList = workorderdetEJBean.getWorkOrderItems(workorderId); // Get the WorkOrder Object WorkOrder workorderObj = workorderdetEJBean.getWorkOrderInfo(workorderId); // Get the List of all Product Names for the WorkOrder String[] productNameList = workorderdetEJBean.getProdList(workorderId); for (int w = 0; w < productNameList.length; w++) USFEnv.getLog() .writeDebug("VALUES INSIDE productNameList is" + productNameList[w], this, null); // Set the attributes to the itemselection JSP req.setAttribute("productNameList", productNameList); req.setAttribute("productList", productList); req.setAttribute("workorderObj", workorderObj); // Release db connection for EJB workorderdetEJBean.release(); // Include the JSP includeJSP(req, resp, ITEM_JSP_PATH, "itemselection"); return; } catch (Exception e) { String errorMsg = "Fail to list products for a WORKORDER " + workorderId; USFEnv.getLog().writeCrit(errorMsg, this, e); errorJSP(req, resp, errorMsg); } }
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String nombreChofer = request.getParameter("nombreChofer"); String telefonoChofer = request.getParameter("telefonoChofer"); float salarioChofer = Float.parseFloat(request.getParameter("salarioChofer")); String choferID = request.getParameter("usernameChofer"); Chofer c = new Chofer(nombreChofer, telefonoChofer, salarioChofer); new ListaChoferes().updateChofer(choferID, c); request.setAttribute("mensaje", "Chofer modificado de manera exitosa"); String color = "10E214"; request.setAttribute("coloreado", color); request.setAttribute("ListaDeChoferes", new ListaChoferes().obtenerChoferes()); request.getRequestDispatcher("VerChoferes.jsp").forward(request, response); }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String deleteProductValue = "false"; try { // Get the form data int productID = Integer.parseInt(request.getParameter("productID")); PrintWriter out = response.getWriter(); DB db = mongo.getDB("FashionFactoryProd"); DBCollection myProducts = db.getCollection("productInfo"); DBCollection myTrending = db.getCollection("myTrending"); BasicDBObject searchQuery = new BasicDBObject(); searchQuery.put("productID", productID); DBCursor cursor = myProducts.find(searchQuery); if (cursor.count() == 0) { deleteProductValue = "false"; request.setAttribute("deleteProductValue", deleteProductValue); RequestDispatcher rd = request.getRequestDispatcher("deleteProduct.jsp"); rd.forward(request, response); } else { int product = 0; while (cursor.hasNext()) { BasicDBObject obj = (BasicDBObject) cursor.next(); product = obj.getInt("productID"); if (product == productID) { myProducts.remove(obj); myTrending.remove(searchQuery); deleteProductValue = "true"; request.setAttribute("deleteProductValue", deleteProductValue); RequestDispatcher rd = request.getRequestDispatcher("deleteProduct.jsp"); rd.forward(request, response); } } } } catch (Exception e) { e.printStackTrace(); } }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ProfesorRepository profesores = (ProfesorRepository) context.getBean("profesorRepository"); try { Collection lista = profesores.findAllProfesor(); List data = new ArrayList(); Iterator itr = lista.iterator(); while (itr.hasNext()) { Profesor prof = (Profesor) itr.next(); ProfesorDTO dto = ProfesorAssembler.Create(prof); data.add(dto); } request.setAttribute("profesores", data); forward("/listaProfesores.jsp", request, response); } catch (Exception e) { request.setAttribute("mensaje", e.getMessage()); forward("/paginaError.jsp", request, response); } }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { GrupoRepository grupos = (GrupoRepository) context.getBean("grupoRepository"); try { Collection lista = grupos.findAllGrupo(); List data = new ArrayList(); Iterator itr = lista.iterator(); while (itr.hasNext()) { Grupo grupo = (Grupo) itr.next(); GrupoDTO dto = GrupoAssembler.CreateDTO(grupo); data.add(dto); } request.setAttribute("grupos", data); forward("/listaGrupos.jsp", request, response); } catch (Exception e) { request.setAttribute("mensaje", e.getMessage()); forward("/paginaError.jsp", request, response); } }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String url = "/index.html"; // get current action String action = request.getParameter("action"); if (action == null) { action = "join"; // default action } // perform action and set URL to appropriate page if (action.equals("join")) { url = "/index.jsp"; // the "join" page } else if (action.equals("add")) { // get parameters from the request String firstName = request.getParameter("firstName"); String lastName = request.getParameter("lastName"); String email = request.getParameter("email"); // store data in User object User user = new User(); user.setEmail(email); user.setFirstName(firstName); user.setLastName(lastName); // validate the parameters String message; if (UserDB.emailExists(user.getEmail())) { message = "This email address already exists.<br>" + "Please enter another email address."; url = "/index.jsp"; } else { message = ""; url = "/thanks.jsp"; UserDB.insert(user); } request.setAttribute("user", user); request.setAttribute("message", message); } getServletContext().getRequestDispatcher(url).forward(request, response); }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); // get parameters from the request String username = request.getParameter("username"); String password = request.getParameter("password"); String message; try { PasswordUtil.checkPasswordStrength(password); message = ""; } catch (Exception e) { message = e.getMessage(); } request.setAttribute("message", message); // hash and salt password String hashedPassword; String salt = ""; String saltedAndHashedPassword; try { hashedPassword = PasswordUtil.hashPassword(password); salt = PasswordUtil.getSalt(); saltedAndHashedPassword = PasswordUtil.hashAndSaltPassword(password); } catch (NoSuchAlgorithmException ex) { hashedPassword = ex.getMessage(); saltedAndHashedPassword = ex.getMessage(); } request.setAttribute("hashedPassword", hashedPassword); request.setAttribute("salt", salt); request.setAttribute("saltedAndHashedPassword", saltedAndHashedPassword); String url = "/index.jsp"; getServletContext().getRequestDispatcher(url).forward(request, response); }
/** * Procesa los llamados a listar marcas * * @param * @return * @throws IOException * @throws ServletException */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { BrandRepository brands = (BrandRepository) context.getBean("brandRepository"); Collection data_brands = brands.findAllBrand(); List param_brands = new ArrayList(); Iterator itr = data_brands.iterator(); while (itr.hasNext()) { Brand brand = (Brand) itr.next(); BrandDTO dto = BrandAssembler.Create(brand); param_brands.add(dto); } request.setAttribute("brands", param_brands); forward("/ListBrands.jsp", request, response); }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String c = request.getParameter("type"); String d = request.getParameter("q"); Expert ce = new Expert(); List result = ce.getTypes(c, d); getServletContext().setAttribute("SAVED_DATA", result); request.setAttribute("styles", result); RequestDispatcher view = request.getRequestDispatcher("result.jsp"); view.forward(request, response); }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Integer etat = (Integer) request.getSession().getAttribute("etat"); if (etat == null) { RequestDispatcher dispatcher = request.getRequestDispatcher("/login.jsp"); dispatcher.forward(request, response); } else { try { String titre = request.getParameter("titre"); String dateSortie = request.getParameter("dateSortie"); String nom = request.getParameter("nom"); String role = request.getParameter("role"); // conversion du parametre dateSortie en SQLDate Date date; try { date = new Date(FormatDate.convertirDate(dateSortie).getTime()); } catch (ParseException e) { throw new Tp6Exception( "Format de la date " + dateSortie + " incorrect. AAAA-MM-JJ attendue."); } // executer la transaction GestionTp6 tp6Update = (GestionTp6) request.getSession().getAttribute("tp6Update"); synchronized (tp6Update) { tp6Update.gestionFilm.ajoutActeurFilm(titre, date, nom, role); } RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/menu.jsp"); dispatcher.forward(request, response); } catch (Tp6Exception e) { List<String> listeMessageErreur = new LinkedList<String>(); listeMessageErreur.add(e.toString()); request.setAttribute("listeMessageErreur", listeMessageErreur); RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/menu.jsp"); dispatcher.forward(request, response); } catch (Exception e) { e.printStackTrace(); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString()); } } }
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * * @param request servlet request * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { assert emf != null; // Make sure injection went through correctly. EntityManager em = null; try { em = emf.createEntityManager(); // query for all the persons in database List persons = em.createQuery("select p from Person p").getResultList(); request.setAttribute("personList", persons); // Forward to the jsp page for rendering request.getRequestDispatcher("ListPerson.jsp").forward(request, response); } catch (Exception ex) { throw new ServletException(ex); } finally { // close the em to release any resources held up by the persistebce provider if (em != null) { em.close(); } } }
/** Metodo para actualizar un servicio existente */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { AveriaRepository averias = (AveriaRepository) context.getBean("averiaRepository"); try { String codAveria = request.getParameter("codAveria"); String descripcion = request.getParameter("descripcion"); String fecha = request.getParameter("fecha"); String servicio_codServicio = request.getParameter("servicio_codServicio"); Averia obj = averias.findAveria(codAveria); try { if (codAveria != null) obj.setCodAveria(codAveria); if (descripcion != null) obj.setDescripcion(descripcion); if (fecha != null) obj.setFecha(fecha); if (servicio_codServicio != null) obj.setServicioCodServicio(servicio_codServicio); } catch (Exception e) { } response.sendRedirect("listaAverias"); } catch (Exception e) { request.setAttribute("mensaje", e.getMessage()); forward("/paginaError.jsp", request, response); } }
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // retrieving values from input fields of matrixinput.jsp String sMatrix1 = request.getParameter("firstMatrix"); String sMatrix2 = request.getParameter("secondMatrix"); // Creating MatrixMultipler object MatrixMultiplier mm = new MatrixMultiplier(); // Passing Strings to convertToObject() method of MatrixMultiplier // convertToObject() is used to convert strings into MatrixBean MatrixBean fMatrix = mm.convertToObject(sMatrix1); MatrixBean sMatrix = mm.convertToObject(sMatrix2); // passing MatrixBean’s objects to multiply() method of // MatrixMultiplier and receiving the product matrix in the form // of MatrixBean MatrixBean rMatrix = mm.multiply(fMatrix, sMatrix); // saving results in database mm.saveResult(rMatrix); // storing the product of matrices into request, so that it can be // retrieved on matrixresult.jsp request.setAttribute("product", rMatrix); // forwarding request to matrixresult.jsp RequestDispatcher rd = request.getRequestDispatcher("matrixresult.jsp"); rd.forward(request, response); } // end processRequest()
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { TuberiaModule module = (TuberiaModule) context.getBean("tuberiaModule"); try { String id = request.getParameter("id"); int idObj = Integer.parseInt(id); String diametro = request.getParameter("diametro"); int diametroObj = Integer.parseInt(diametro); String largo = request.getParameter("largo"); int largoObj = Integer.parseInt(largo); String presionMaxima = request.getParameter("presionMaxima"); int presionMaximaObj = Integer.parseInt(presionMaxima); String idAcueducto = request.getParameter("idAcueducto"); int idAcueductoObj = Integer.parseInt(idAcueducto); String material = request.getParameter("material"); String tipo = request.getParameter("tipo"); String fechaInstalacion = request.getParameter("fechaInstalacion"); String fechaUltimaInspeccion = request.getParameter("fechaUltimaInspeccion"); String estado = request.getParameter("estado"); module.actualizar( idObj, material, diametroObj, tipo, largoObj, presionMaximaObj, fechaInstalacion, fechaUltimaInspeccion, estado, idAcueductoObj); response.sendRedirect("listaTuberias"); } catch (Exception e) { request.setAttribute("mensaje", e.getMessage()); forward("/paginaError.jsp", request, response); } }
public boolean convalida() { boolean tuttoOk = true; Map<String, String> errori = new HashMap<String, String>(); if ((nome == null) || nome.equals("")) { tuttoOk = false; request.setAttribute("nome", nome); errori.put("nome", "campo obbligatorio"); } if ((descrizione == null) || descrizione.equals("")) { tuttoOk = false; request.setAttribute("descrizione", descrizione); errori.put("descrizione", "campo obbligatorio"); } if ((codice == null) || codice.equals("")) { tuttoOk = false; request.setAttribute("codice", codice); errori.put("codice", "campo obbligatorio"); } if (!isInteger(disponibilita)) { tuttoOk = false; request.setAttribute("disponibilita", disponibilita); errori.put("disponibilita", "formato non valido"); } if (!isInteger(prezzo)) { tuttoOk = false; request.setAttribute("prezzo", prezzo); errori.put("prezzo", "formato non valido"); } if (!tuttoOk) request.setAttribute("errori", errori); HttpSession sess = request.getSession(); sess.setAttribute("errori", errori); return tuttoOk; }
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); } }
private void detectErrorResponse(int errorCode) { if (errorCode != HttpServletResponse.SC_ACCEPTED) { origRequest.setAttribute(XSLTFilterConstants.NO_XSLT_PROCESSING, Boolean.TRUE); } }