源码地带 > 电路图 > 电子资料下载 > Applet >JAVA学习 > 查看压缩包源码

JAVA学习

源代码在线查看: dummycart.java

软件大小: 1316 K
上传用户: vicegle
关键词: JAVA
下载地址: 免注册下载 普通下载 VIP

相关代码

				import javax.servlet.http.*;
				import javax.servlet.*;
				import java.util.*;
				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(HttpServletRequest request)
					{
						//判断submit的值
						submit = (String)request.getParameter("submit");
					//	System.out.println(submit);
						item = (String)request.getParameter("item");
						if(submit.equals("null"))
						 addItem(item);
						if(submit.equals("add"))
						  addItem(item);
						else if(submit.equals("remove"))
						  removeItem(item);
						// 重置submit的值
						reset();
					}
					
					private void reset()
					{
						submit = null;
						item = null;
				  }
				}			

相关资源