JAVA2(J2ME)实用编程的150个范例

源代码在线查看: dummycart.java

软件大小: 1379 K
上传用户: laoniu
关键词: JAVA2 J2ME 150 编程
下载地址: 免注册下载 普通下载 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;
				  }
				}			

相关资源