Пример #1
0
 // Evaluate the body and add the data for the first vector element
 // to the bodyContent object.
 @Override
 public void doInitBody() {
   count = 0;
   product = (Product) products.get(count);
   pageContext.setAttribute("code", product.getCode());
   pageContext.setAttribute("description", product.getDescription());
   double price = product.getPrice();
   String priceAsString = currency.format(price);
   pageContext.setAttribute("price", priceAsString);
   count++;
 }
Пример #2
0
 @Override
 public int doAfterBody() throws JspException {
   try {
     if (count < products.size()) {
       product = (Product) products.get(count);
       pageContext.setAttribute("code", product.getCode());
       pageContext.setAttribute("description", product.getDescription());
       pageContext.setAttribute("price", currency.format(product.getPrice()));
       count++;
       return EVAL_BODY_AGAIN;
     } else {
       JspWriter out = bodyContent.getEnclosingWriter();
       bodyContent.writeOut(out);
       return SKIP_BODY;
     }
   } catch (IOException ioe) {
     System.err.println("IOException doAfterBody: " + ioe);
     return SKIP_BODY;
   }
 }