⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showquote_jsp.java

📁 EJB实践的服务器是用SUN的服务器
💻 JAVA
字号:
package examples;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import examples.ProductItem;
import examples.LineItem;
import java.text.NumberFormat;

public final class showQuote_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static java.util.Vector _jspx_dependants;

  public java.util.List getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			"error.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n<HTML>\r\n    <head><title> Jasmine's Shopping Cart page </title></head>\r\n    <body>\r\n        ");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "title.jsp", out, false);
      out.write("\r\n\t\r\n        \r\n        \r\n        \r\n        <form action=\"/jasmine/showQuote\" method=\"get\"> \r\n                <center><table>\r\n                    <tr>\r\n\t\t\t<th align=left> Name </TH>\r\n\t\t\t<th align=left> Quantity </TH>\r\n\t\t\t<th align=left> Individual Base Price </TH>\r\n\t\t\t<th align=left> Discount </TH>\r\n\t\t\t<th align=left><strong> Total Price </strong></TH>\r\n\t\t\t<th align=left>Modify Quantity</TH>\r\n                    </tr>\r\n                    ");

                    // get the lineItems from the request object and displays in a table format.
                    java.util.Enumeration lineItems = ((java.util.Vector) request.getAttribute("lineItems")).elements();
                    double subTotal=((Double)request.getAttribute("subTotal")).doubleValue();
                    double taxes=((Double)request.getAttribute("taxes")).doubleValue();
                    double total=((Double)request.getAttribute("total")).doubleValue();
   
                    while (lineItems.hasMoreElements()) {
                        LineItem li = (LineItem) lineItems.nextElement();
                        int quantity     = li.getQuantity();
                        double discount  = li.getDiscount();
                        ProductItem product  = li.getProductItem();
                        String productID = product.getProductID();
                        double basePrice = product.getBasePrice();
                    
      out.write("\r\n                    <tr>\r\n                        <td bgcolor=\"#ffffaa\"><a href=\"/jasmine/catalog?productId=");
      out.print(product.getProductID());
      out.write("\"><b>");
      out.print(product.getName());
      out.write("<b></td>\r\n                        <td align=\"right\" bgcolor=\"#ffffff\">");
      out.print(quantity);
      out.write("</td>\r\n                        <td bgcolor=\"#ffffaa\" align=\"right\">");
      out.print(NumberFormat.getCurrencyInstance().format(basePrice));
      out.write("</td>\r\n                        <td bgcolor=\"#ffffaa\" align=\"right\">");
      out.print(NumberFormat.getCurrencyInstance().format(discount));
      out.write("</td>\r\n                        <td bgcolor=\"#ffffaa\" align=\"right\">");
      out.print(NumberFormat.getCurrencyInstance().format((basePrice* quantity) - discount ));
      out.write("</td>\r\n                        <td><input type=\"text\" name=\"");
      out.print(productID);
      out.write("\" value=\"");
      out.print(quantity);
      out.write("\"></td>\r\n                    </tr>\r\n                    ");
 } 
      out.write("\r\n                </table></center>\r\n                <br>\r\n                <center><table>\r\n                    <tr>\r\n                        <td colspan=\"2\" align=\"right\" bgcolor=\"#ffffff\"> Subtotal:</td>\r\n                        <td bgcolor=\"#ffffaa\" align=\"right\"> ");
      out.print(NumberFormat.getCurrencyInstance().format(subTotal));
      out.write("</td>\r\n                        <td> <br></td>          \r\n                    </tr>\r\n                    <tr>\r\n                        <td colspan=\"2\" align=\"right\" bgcolor=\"#ffffff\">Sales Tax: </td>\r\n                        <td bgcolor=\"#ffffaa\" align=\"right\">");
      out.print(NumberFormat.getCurrencyInstance().format(taxes));
      out.write("</td>\r\n                        <td><br></td>\r\n                    </tr>\r\n                    <tr>\r\n                        <td colspan=\"2\" align=\"right\" bgcolor=\"ffffff\"> <font color=\"ff0000\"> <strong>Grand Total:</strong></font> </td>\r\n                        <td bgcolor=\"#ffffaa\" align=\"right\">");
      out.print(NumberFormat.getCurrencyInstance().format(total));
      out.write("</td>\r\n                        <td><br></td>   \r\n                    </tr>\r\n                </table></center>\r\n                <!--\r\n                    Print out links and buttons for user feedback.\r\n                    When the customer clicks a button to perform an \r\n                    action (such as submitting an order), sends request to\r\n\t\t    the servlet with necessary parameters to process the request.\r\n                //-->\r\n                <p>\r\n                <A href=\"/jasmine/catalog\">See the Catalog</A>\r\n                <input type=\"reset\" value=\"Reset Values\"> &nbsp; &nbsp; &nbsp;\r\n                <input type=\"submit\" name=\"Update\" value=\"Update Quantities\"> &nbsp; &nbsp; &nbsp;\r\n                <input type=\"submit\" name=\"Order\" value=\"Submit Order\"> &nbsp; &nbsp; &nbsp;\r\n                <input type=\"submit\" name=\"Clear\" value=\"Clear Cart\"> &nbsp; &nbsp; &nbsp;\r\n\r\n        ");
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "footer.jsp", out, false);
      out.write("\r\n        </form>\r\n    </body>\r\n</html>\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -