1 2 24 25 26 27 28 29 package com.lutris.http; 30 31 import java.io.Serializable ; 32 33 import javax.servlet.http.Cookie ; 34 35 36 52 public class SerializableCookie implements Serializable { 53 54 private String name; 55 private String value; 56 private String comment; 57 private String domain; 58 private int maxAge; 59 private String path; 60 private boolean secure; 61 private int version; 62 63 69 public SerializableCookie(Cookie cookie) { 70 name = cookie.getName(); 71 value = cookie.getValue(); 72 comment = cookie.getComment(); 73 domain = cookie.getDomain(); 74 maxAge = cookie.getMaxAge(); 75 path = cookie.getPath(); 76 secure = cookie.getSecure(); 77 version = cookie.getVersion(); 78 } 79 80 81 86 public Cookie getCookie() { 87 Cookie cookie = new Cookie (name, value); 88 if (comment != null) 89 cookie.setComment(comment); 90 if (domain != null) 91 cookie.setDomain(domain); 92 cookie.setMaxAge(maxAge); 93 if (path != null) 94 cookie.setPath(path); 95 cookie.setSecure(secure); 96 cookie.setVersion(version); 97 return cookie; 98 } 99 100 101 107 public String toString() { 108 return "SerializableCookie:" + 109 "\n name = " + name + 110 "\n value = " + value + 111 "\n comment = " + comment + 112 "\n domain = " + domain + 113 "\n maxAge = " + maxAge + 114 "\n path = " + path + 115 "\n secure = " + secure + 116 "\n version = " + version; 117 } 118 119 } 120 121 122 | Popular Tags |