最近看了一个JSP文件,初学JSP,可有点不明白的地方, 请教大家为什么<% 
   String[] items=cart.getItems();
   for(int i=0;i<items.length;i++)
   {
 %>
 <li><%= items[i] %>
 <% 
  } 
上面那个代码能在页面上显示出多条记录呢,按我的理解应该只有一条记录的,
carts.jsp的内容<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<% 
 request.setCharacterEncoding("gb2312");
 %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<jsp:useBean id="cart" scope="session" class="sessions.DummyCart"/>
<jsp:setProperty name="cart" property="item" value="<%=request.getParameter(\"item\")%>"/>
<jsp:setProperty name="cart" property="submit" value="<%=request.getParameter(\"submit\")%>"/>
<% 
   cart.processRequest();
 %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<p>您当前选择了如下CD:</p>
<p>&nbsp; </p>
<ol>
<% 
   String[] items=cart.getItems();
   for(int i=0;i<items.length;i++)
   {
 %>
 <li><%= items[i] %>
 <% 
  } 
 %>
</ol> 
</body>DummyCart.java的内容package sessions;
import java.util.Vector;
import java.util.Enumeration;
public class DummyCart {
   
Vector v=new Vector();
String submit=null;
String item=null;
private void addItem(String name){
v.addElement(name);
}

private void removeItem(String name){
v.removeElement(name);
}

public void setItem(String name){
 item=name;
}

public void setSubmit(String s){
submit=s;
}

public String[] getItems(){
String[] s=new String[v.size()];
v.copyInto(s);
return s;
}

public void processRequest(){
if(submit.equals("add"));
 addItem(item);
 if(submit.equals("remove"))
 removeItem(item);
reset();

}

private void reset(){
submit =null;
item=null;
}
}</html>
<%@ include file="carts.htm" %>
carts.htm的内容<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<form id="form1" name="form1" method="post" action="carts.jsp">
  <p>
    <select name="item" size="1" id="item">
      <option>阿甘正传</option>
      <option>狮子王</option>
      <option>云中漫步</option>
      <option>秋日传奇</option>
    </select>
</p>
  <p>
    <input name="submit" type="submit" id="submit" value="add" >
</p>
  <p>
    <input name="submit" type="submit" id="submit" value="remove" >
  </p>
</form>
</body>
</html>