关于html与serverlet的问题
serverlet的内容
----------------------------------------------
package showcart;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class showcart extends HttpServlet implements SingleThreadModel {
private static final String CONTENT_TYPE = "text/html; charset=GBK ";
//Initialize global variables
public void init() throws
ServletException {
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException,
IOException {
response.setContentType(CONTENT_TYPE);
String[] items = { "电视机 ", "电冰箱 ", "电脑 "};
HttpSession session = request.getSession(true);
Integer itemCount = (Integer) session.getAttribute( "itemCount ");
if (itemCount == null) {
itemCount = new Integer(0);
}
PrintWriter out = null;
try {
out = response.getWriter();
} catch (Exception e) {}
//取得POST上来的表单信息
String[] itemsSelected;
String itemName;
itemsSelected = request.getParameterValues( "item ");
//将选中的商品放入会话对象
if (itemsSelected != null) {
for (int i = 0; i < itemsSelected.length; i++) {
itemName = itemsSelected[i];
&nbs