import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest;
//----------------------- public static Cookie getCookie(HttpServletRequest request, String name) throws Exception {
Cookie[] cookies = request.getCookies(); if(cookies!=null) { String username = ""; String id = ""; String level = ""; String governid = ""; DoradoContext ctx = DoradoContext.getContext(); for (int i = 0; i < cookies.length; i++) { Cookie c = cookies[i]; if(c.getName().equalsIgnoreCase("name")) { username = c.getValue(); username =new String(username.getBytes("ISO8859_1"),"gbk"); ctx.setAttribute(DoradoContext.SESSION, "name", username); System.out.println(username); } else if(c.getName().equalsIgnoreCase("id")) { id = c.getValue(); ctx.setAttribute(DoradoContext.SESSION, "id", id); System.out.println(id); } else if(c.getName().equalsIgnoreCase("level")) { level = c.getValue(); ctx.setAttribute(DoradoContext.SESSION, "level", level); } else if(c.getName().equalsIgnoreCase("governid")) { governid = c.getValue(); ctx.setAttribute(DoradoContext.SESSION, "governid", governid); System.out.println(governid); } } //for } //if return null; } //-----------------------
|