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;
}
//-----------------------
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請
點(diǎn)擊舉報。