public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String fechaHora = request.getParameter("FechaHora"); String place = request.getParameter("Place"); String idlocalteam = request.getParameter("Idlocalteam"); String idvisitteam = request.getParameter("Idvisitteam"); String ronda = request.getParameter("Ronda"); String id = request.getParameter("id"); PartidosBean partidosBean = new PartidosBean(); partidosBean.setIdpartido(id); partidosBean.setDatetime(fechaHora); partidosBean.setPlace(place); EquiposBean localteam = new EquiposBean(); localteam.setIdequipo(idlocalteam); EquiposBean visitteam = new EquiposBean(); visitteam.setIdequipo(idvisitteam); partidosBean.setIdlocalteam(localteam); partidosBean.setIdvisitteam(visitteam); partidosBean.setRonda(ronda); String opcion = request.getParameter("opcion"); /*if(opcion.equalsIgnoreCase("Agregar")){ boolean status=AddPartido(partidosBean); if(status) request.setAttribute("Status",true); else request.setAttribute("Status",false); }*/ /*if(opcion.equalsIgnoreCase("Eliminar")){ boolean status=DeletePartido(partidosBean); if(status) request.setAttribute("Status",true); else request.setAttribute("Status",false); }*/ if (opcion.equalsIgnoreCase("Editar")) { boolean status = EditPartido(partidosBean); if (status) request.setAttribute("Status", true); else request.setAttribute("Status", false); } // Mostramos los Equipos de los 8 Grupos EquiposDAO equiposDAO = new EquiposDAO(); List<EquiposBean> equipos = equiposDAO.getTodosEquipos(); request.setAttribute("Equipos", equipos); // Consultamos los Partidos Existentes PartidosDAO partidosDAO = new PartidosDAO(); List<PartidosBean> partidos = partidosDAO.getTodosPartidos(); request.setAttribute("Partidos", partidos); request.getRequestDispatcher("/WEB-INF/Partidos.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"); } }
/** * Sell a current holding of stock shares for the given trader. Dispatch to the Trade Portfolio * JSP for display * * @param userID The User buying shares * @param symbol The stock to sell * @param indx The unique index identifying the users holding to sell * @param ctx the servlet context * @param req the HttpRequest object * @param resp the HttpResponse object * @exception javax.servlet.ServletException If a servlet specific exception is encountered * @exception javax.io.IOException If an exception occurs while writing results back to the user */ void doSell( ServletContext ctx, HttpServletRequest req, HttpServletResponse resp, String userID, Integer holdingID) throws ServletException, IOException { String results = ""; try { OrderDataBean orderData = tAction.sell(userID, holdingID, TradeConfig.orderProcessingMode); req.setAttribute("orderData", orderData); req.setAttribute("results", results); } catch (java.lang.IllegalArgumentException e) { // this is a user error so I will // just log the exception and then later on I will redisplay the portfolio page // because this is just a user exception Log.error( e, "TradeServletAction.doSell(...)", "illegal argument, information should be in exception string", "user error"); } catch (Exception e) { // log the exception with error page throw new ServletException( "TradeServletAction.doSell(...)" + " exception selling holding " + holdingID + " for user =" + userID, e); } requestDispatch(ctx, req, resp, userID, TradeConfig.getPage(TradeConfig.ORDER_PAGE)); }
// 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); }
/** * Display User Profile information such as address, email, etc. for the given Trader Dispatch to * the Trade Account JSP for display * * @param userID The User to display profile info * @param ctx the servlet context * @param req the HttpRequest object * @param resp the HttpResponse object * @param results A short description of the results/success of this web request provided on the * web page * @exception javax.servlet.ServletException If a servlet specific exception is encountered * @exception javax.io.IOException If an exception occurs while writing results back to the user */ void doAccount( ServletContext ctx, HttpServletRequest req, HttpServletResponse resp, String userID, String results) throws javax.servlet.ServletException, java.io.IOException { try { AccountDataBean accountData = tAction.getAccountData(userID); AccountProfileDataBean accountProfileData = tAction.getAccountProfileData(userID); ArrayList orderDataBeans = (TradeConfig.getLongRun() ? new ArrayList() : (ArrayList) tAction.getOrders(userID)); req.setAttribute("accountData", accountData); req.setAttribute("accountProfileData", accountProfileData); req.setAttribute("orderDataBeans", orderDataBeans); req.setAttribute("results", results); requestDispatch(ctx, req, resp, userID, TradeConfig.getPage(TradeConfig.ACCOUNT_PAGE)); } catch (java.lang.IllegalArgumentException e) { // this is a user error so I will // forward them to another page rather than throw a 500 req.setAttribute("results", results + "could not find account for userID = " + userID); requestDispatch(ctx, req, resp, userID, TradeConfig.getPage(TradeConfig.HOME_PAGE)); // log the exception with an error level of 3 which means, handled exception but would // invalidate a automation run Log.error( "TradeServletAction.doAccount(...)", "illegal argument, information should be in exception string", e); } catch (Exception e) { // log the exception with error page throw new ServletException( "TradeServletAction.doAccount(...)" + " exception user =" + userID, e); } }
private void forwardToErrorPage( HttpServletRequest request, HttpServletResponse response, String userMessage, XDebug xdebug) throws ServletException, IOException { request.setAttribute("xdebug_object", xdebug); request.setAttribute(QueryBuilder.USER_ERROR_MESSAGE, userMessage); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/jsp/error.jsp"); dispatcher.forward(request, response); }
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("......................"); } }
private void setGeneticProfiles(HttpServletRequest request) throws DaoException { CancerStudy cancerStudy = (CancerStudy) request.getAttribute(CANCER_STUDY); GeneticProfile mutProfile = cancerStudy.getMutationProfile(); if (mutProfile != null) { request.setAttribute(MUTATION_PROFILE, mutProfile); } GeneticProfile cnaProfile = cancerStudy.getCopyNumberAlterationProfile(true); if (cnaProfile != null) { request.setAttribute(CNA_PROFILE, cnaProfile); } }
/** * 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 controller(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { hsession = HibernateUtil.currentSession(); sessione = request.getSession(); tx = hsession.beginTransaction(); String action = request.getParameter("action"); if (action == null) action = "home"; /*if(action.equals("login")) login(request, response);*/ Users u = (Users) sessione.getAttribute("user"); if (u == null) { throw new LoginException(); } else if (u.getTipo().intValue() < 2) { throw new LoginException(); } if (action.equals("home")) accedi(request, response); else if (action.equals("chiudi")) chiudiBilancio(request, response); } catch (LoginException e) { Avviso err = new Avviso(e.getMessage()); request.setAttribute("err", err); nextview = "/./error.jsp"; } catch (Exception e) { Avviso err = new Avviso("Errore indefinito. Ricorda di non usare il tasto REFRESH di Explorer!"); request.setAttribute("err", err); System.out.println(e.getMessage()); nextview = "/./error.jsp"; } finally { RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextview); if (dispatcher != null) { response.encodeURL(nextview); dispatcher.forward(request, response); } HibernateUtil.closeSession(); } }
/** * Register a new trader given the provided user Profile information such as address, email, etc. * Dispatch to the Trade Home JSP for display * * @param userID The User to create * @param passwd The User password * @param fullname The new User fullname info * @param ccn The new User credit card info * @param money The new User opening account balance * @param address The new User address info * @param email The new User email info * @return The userID of the new trader * @param ctx the servlet context * @param req the HttpRequest object * @param resp the HttpResponse object * @exception javax.servlet.ServletException If a servlet specific exception is encountered * @exception javax.io.IOException If an exception occurs while writing results back to the user */ void doRegister( ServletContext ctx, HttpServletRequest req, HttpServletResponse resp, String userID, String passwd, String cpasswd, String fullname, String ccn, String openBalanceString, String email, String address) throws ServletException, IOException { String results = ""; try { // Validate user passwords match and are atleast 1 char in length if ((passwd.equals(cpasswd)) && (passwd.length() >= 1)) { AccountDataBean accountData = tAction.register( userID, passwd, fullname, address, email, ccn, new BigDecimal(openBalanceString)); if (accountData == null) { results = "Registration operation failed;"; System.out.println(results); req.setAttribute("results", results); requestDispatch(ctx, req, resp, userID, TradeConfig.getPage(TradeConfig.REGISTER_PAGE)); } else { doLogin(ctx, req, resp, userID, passwd); results = "Registration operation succeeded; Account " + accountData.getAccountID() + " has been created."; req.setAttribute("results", results); } } else { // Password validation failed results = "Registration operation failed, your passwords did not match"; System.out.println(results); req.setAttribute("results", results); requestDispatch(ctx, req, resp, userID, TradeConfig.getPage(TradeConfig.REGISTER_PAGE)); } } catch (Exception e) { // log the exception with error page throw new ServletException( "TradeServletAction.doRegister(...)" + " exception user =" + userID, e); } }
/** * Retrieve the current portfolio of stock holdings for the given trader Dispatch to the Trade * Portfolio JSP for display * * @param userID The User requesting to view their portfolio * @param ctx the servlet context * @param req the HttpRequest object * @param resp the HttpResponse object * @param results A short description of the results/success of this web request provided on the * web page * @exception javax.servlet.ServletException If a servlet specific exception is encountered * @exception javax.io.IOException If an exception occurs while writing results back to the user */ void doPortfolio( ServletContext ctx, HttpServletRequest req, HttpServletResponse resp, String userID, String results) throws ServletException, IOException { try { // Get the holdiings for this user Collection quoteDataBeans = new ArrayList(); Collection holdingDataBeans = tAction.getHoldings(userID); // Walk through the collection of user // holdings and creating a list of quotes if (holdingDataBeans.size() > 0) { Iterator it = holdingDataBeans.iterator(); while (it.hasNext()) { HoldingDataBean holdingData = (HoldingDataBean) it.next(); QuoteDataBean quoteData = tAction.getQuote(holdingData.getQuoteID()); quoteDataBeans.add(quoteData); } } else { results = results + ". Your portfolio is empty."; } req.setAttribute("results", results); req.setAttribute("holdingDataBeans", holdingDataBeans); req.setAttribute("quoteDataBeans", quoteDataBeans); requestDispatch(ctx, req, resp, userID, TradeConfig.getPage(TradeConfig.PORTFOLIO_PAGE)); } catch (java.lang.IllegalArgumentException e) { // this is a user error so I will // forward them to another page rather than throw a 500 req.setAttribute("results", results + "illegal argument:" + e.getMessage()); requestDispatch(ctx, req, resp, userID, TradeConfig.getPage(TradeConfig.PORTFOLIO_PAGE)); // log the exception with an error level of 3 which means, handled exception but would // invalidate a automation run Log.error( e, "TradeServletAction.doPortfolio(...)", "illegal argument, information should be in exception string", "user error"); } catch (Exception e) { // log the exception with error page throw new ServletException( "TradeServletAction.doPortfolio(...)" + " exception user =" + userID, e); } }
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()); // } }
void doWelcome( ServletContext ctx, HttpServletRequest req, HttpServletResponse resp, String status) throws ServletException, IOException { req.setAttribute("results", status); requestDispatch(ctx, req, resp, null, TradeConfig.getPage(TradeConfig.WELCOME_PAGE)); }
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException { try { ConnectionPool conPool = getConnectionPool(); if (!realAuthentication(request, conPool)) { String queryString = request.getQueryString(); if (request.getQueryString() == null) { queryString = ""; } // if user is not authenticated send to signin response.sendRedirect( response.encodeRedirectURL(URLAUTHSIGNIN + "?" + URLBUY + "?" + queryString)); } else { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Expires", "0"); response.setHeader("Pragma", "no-cache"); response.setContentType("text/html"); String errorMessage = processRequest(request, response, conPool); if (errorMessage != null) { request.setAttribute(StringInterface.ERRORPAGEATTR, errorMessage); RequestDispatcher rd = getServletContext().getRequestDispatcher(PATHUSERERROR); rd.include(request, response); } } } catch (Exception e) { throw new ServletException(e); } }
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 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); }
private void accedi(HttpServletRequest request, HttpServletResponse response) { Query q = hsession.createQuery("FROM Anno ORDER BY anno"); request.setAttribute("listaanni", q.list()); nextview = "/bilancio/home.jsp"; }
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 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); }
protected void doGet(HttpServletRequest request, HttpServletResponse response) { try { request.setAttribute("body", "/WEB-INF/jsp/testimonial.jsp"); layoutPage.forward(request, response); } catch (Exception e) { e.printStackTrace(); } }
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(); } }
protected void index(HttpServletRequest request, HttpServletResponse response) { ISocialmore sm = Socialmore.connect(this); IUser user = User.getSession(request); if (sm == null || user == null) { forwardTo(request, response, "Sessions/login"); return; } try { ArrayList<IMessage> inbox = (ArrayList<IMessage>) user.getInbox(); request.setAttribute("inbox", inbox); } catch (RemoteException e) { request.setAttribute("flash", "We are sorry! :( Your inbox is temporaly unavailable..."); forwardTo(request, response, "Users/index"); } forwardTo(request, response, "Messages/index"); }
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); } }
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); } }