购物车jsp错误

时间:2013-01-30 10:25:32

标签: java html jsp

我正在尝试制作购物车,下面是显示的代码。如果用户没有购物车,则会创建一个并显示所有行,例如产品的pip和ean编号。

<%-- 
    Document   : DisplayShoppingCart
    Created on : Jan 24, 2013, 12:48:06 PM
    Author     : Faiza
--%>
<%@ page language="java" import="model.*,java.util.*,java.text.*" %>

<%-- Show the header with the shopping cart image --%>
<table border="0">
<tr><td><img src="Drug-basket-icon.png"><td><h1>Shopping Cart</h1>
</table>

<%
// Get the current shopping cart from the user's session.
    ShoppingCart cart = (ShoppingCart) session.getAttribute("ShoppingCart");

// If the user doesn't have a shopping cart yet, create one.
    if (cart == null)
    {
        cart = new ShoppingCart();
        session.setAttribute("ShoppingCart", cart);
    }
// Get the items from the cart.
    Vector items = cart.getItems();


// If there are no items, tell the user that the cart is empty.
    if (items.size() == 0)
    {
        out.println("<h3>Your shopping cart is empty.</h3>");
    }
    else
    {
%>
<%-- Display the header for the shopping cart table --%>
<br>
<table border=4>
<tr><th>EAN</th><th>PIP</th><th>Name</th><th>Description</th><th>Supplier ID</th><th>Price</th><th>Quantity</th></tr>
<%

        int numItems = items.size();

// Get a formatter to write out currency values.
        NumberFormat currency = NumberFormat.getCurrencyInstance();

        for (int i=0; i < numItems; i++)
        {
            Item item = (Item) items.elementAt(i);

// Print the table row for the item.
            out.print("<tr><td>");
            out.print(item.EAN);
            out.print("</td><td>");
            out.print(item.PIP);
            out.print("</td><td>");
            out.print(item.name);
            out.print("</td><td>");
            out.print(item.description);
            out.print("</td><td>");
            out.print(item.SupplierID);
            out.print("</td><td>");
             out.print(item.price);
            out.print("</td><td>");
             out.print(item.quantity);
            out.print("</td><td>");
            out.print(currency.format(item.price));

// Print out a link that allows the user to delete an item from the cart.
            out.println("</td><td>"+
                "<a href=\"/shoppingcart/RemoveItemServlet?item="+
                i+"\">Remove</a></td></tr>");
        }
    }
%>
</table>

我得到的错误是在下面我尝试了一切,但我不明白这是什么意思

pe Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 14 in the generated java file
Syntax error on token ";", delete this token

Stacktrace:
  org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
  org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
  org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:469)
  org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
  org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
  org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
  org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)**

1 个答案:

答案 0 :(得分:0)

删除;来自进口声明。