转:
session的遍历:
java.util.Enumeration e = request.getSession().getAttributeNames(); while( e.hasMoreElements()) { String sessionName=(String)e.nextElement(); out.println(" session item name="+sessionName); out.println(" session item value="+request.getSession().getAttribute(sessionName)); }
request的遍历:
Map map = new HashMap(); map = request.getParameterMap(); for(Iterator iter = map.entrySet().iterator();iter.hasNext();){ Map.Entry element = (Map.Entry)iter.next(); String strKey = element.getKey().toString(); out.println(" key="+strKey); String[] value=(String[])element.getValue(); if(value.length>0){ for(int i=0;i<value.length;i++) out.println(" value"+String.valueOf(i)+"="+value[i].toString()); } int a=1; }