01: package forum;
02:
03: import javax.servlet.*;
04: import javax.servlet.http.*;
05:
06: public class Cookies {
07:
08: public static String getCookies(Cookie[] cookies,
09: String cookieName, String defaultValue) {
10:
11: if (!cookies.equals(null)) {
12: Cookie cookie;
13: for (int i = 0; i < cookies.length; i++) {
14: cookie = cookies[i];
15: if (cookieName.equals(cookie.getName())) {
16: return cookie.getValue();
17: }
18: }
19: }
20: return (defaultValue);
21: }
22: }
|