当前位置: 网站首页 > WEB > jsp

实例讲解JSP Model2体系结构(中)

时间:1970-1-1 08:33:31来源: jsp作者:admin 点击:0次 字体 [ С]

     String url="/jsp/shopping/EShop.jsp";

     ServletContext sc = getServletContext();

     RequestDispatcher rd = sc.getRequestDispatcher(url);

     rd.forward(req, res);

    } else if (action.equals("CHECKOUT")) {

     float total =0;

     for (int i=0; i< buylist.size();i++) {

      CD anOrder = (CD) buylist.elementAt(i);

      float price= anOrder.getPrice();

      int qty = anOrder.getQuantity();

      total += (price * qty);

     }

     total += 0.005;

     String amount = new Float(total).toString();

     int n = amount.indexOf('.');

     amount = amount.substring(0,n+3);

     req.setAttribute("amount",amount);

     String url="/jsp/shopping/Checkout.jsp";

     ServletContext sc = getServletContext();

     RequestDispatcher rd = sc.getRequestDispatcher(url);

     rd.forward(req,res);
发表评论
验证码:
最新评论
相关文章
最热文章