-
1. Re: using cookie in jsf
healeyb Jun 8, 2012 1:35 PM (in response to smithadsouza)Well, what have you done so far?
-
2. Re: using cookie in jsf
smithadsouza Jun 11, 2012 2:09 AM (in response to healeyb)public void setTestCookie() {
String cookieValue;
Cookie cookie = new Cookie("cookieKey", "cookieValue");
cookie.setDomain("localhost");
cookie.setPath("/");
cookie.setMaxAge(365);
cookie.setValue(accommodation.getAccommodationDetails().getAccommodationId()+"/"+accommodation.getAccommodationDetails().getAccommodationName()+"/"+accommodation.getHotelImagepath()+"/"+accommodation.getRating());
response.addCookie(cookie);
//getting the cookies
Cookie[] cookies = request.getCookies();//HERE AM NOT GETTING COOKIE NAME AND VALUE
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
if (cookies[i].getName().equals("cookieKey")) {
cookieValue = cookies[i].getValue();
System.out.println("cookie value:"+cookieValue);
StringTokenizer stringSeparate=new StringTokenizer(cookieValue, "/");
while(stringSeparate.hasMoreTokens()){
String key = stringSeparate.nextToken();
System.out.println(key);
stringMap.put("cookieID",key);
}//end of while
}//end of if
}//end of for
} //end of if
}//end of setTestCookie method
in firefox browser cookie list,am not able to find the cookie name..
-
3. Re: using cookie in jsf
smithadsouza Jun 27, 2012 4:56 AM (in response to smithadsouza)This issue ia resolved.. cuz i had done some mistake