「Java」http.Cookieの値を取得するサンプル
説明
Cookie の値はクライアントを一意に識別できるため、Cookie は一般にセッション管理に使用されます。
サンプルコード
public void getRequestInfo(HttpServletRequest request) {
Cookie cookies[] = request.getCookies();
if(cookies !=null) {
for(int i=0; i < cookies.length; i++)
if(cookies[i].getName().equals(xxx)) {
String cookieVal = cookies[i].getValue();
//some code
}
}
}
public void getRequestInfo(HttpServletRequest request) {
Cookie cookies[] = request.getCookies();
if(cookies !=null) {
for(int i=0; i < cookies.length; i++)
if(cookies[i].getName().equals(xxx)) {
String cookieVal = cookies[i].getValue();
//some code
}
}
}
public void getRequestInfo(HttpServletRequest request) { Cookie cookies[] = request.getCookies(); if(cookies !=null) { for(int i=0; i < cookies.length; i++) if(cookies[i].getName().equals(xxx)) { String cookieVal = cookies[i].getValue(); //some code } } }