问题描述
- session转化为cookie??????????
-
HttpSession session=request.getSession(true);
ArrayList previousItems=(ArrayList)session.getAttribute("previousItems");
if(previousItems == null){
previousItems=new ArrayList();
session.setAttribute("previousItems", previousItems);
}
String newItem=request.getParameter("newItem");
String title="Item Purchased";
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println(""); //wo xie de
try {
synchronized(previousItems){
if(newItem !=null){
previousItems.add(newItem);
}
if(previousItems.isEmpty()){
out.println("No Items");
}else{
out.println("Items:");
out.println("- ");
- "+(String)previousItems.get(i)+"
for(int i=0; i
out.println("");
}
out.println("");
}
}
session.invalidate();
out.println("Back");} finally { out.close(); } 想请问一下这个怎么用cookie实现
解决方案
cookie和session
cookie与session
cookie&session
时间: 2024-10-23 20:53:02