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 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);
  }
Ejemplo n.º 3
0
  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);
  }