%-- csaCookies.jsp: CSA Cookie Test --%> <%@ page language="java" contentType="text/html" %> <%@ page import = "java.io.*" %> <%@ page import = "java.net.*" %> <%@ page import = "java.util.Date" %> <%@ page import = "java.text.SimpleDateFormat" %>
found cookie on iteration <%= ii %>
<% if ((idx = cookieValue.indexOf("[")) > 0) { try { prevTS = Long.parseLong(cookieValue.substring(0,idx)); cookieAge = currTS - prevTS; %>Found CSA cookie <%= cookieValue %>, with age = <%= cookieAge %> msec
<% } catch (Exception e) { %>Found CSA cookie <%= cookieValue %>, but exception finding its age
<% } } else { %>Found CSA cookie <%= cookieValue %>, but cannot determine its age
<% } // Do NOT remove the current existing cookie ... // aCookie.setMaxAge(0); // response.addCookie(aCookie); csaCookieCnt++; } } // If client config cookie was found ... if (csaCookieCnt > 0) { %>Found total of <%= csaCookieCnt %> CSA cookie(s)
<% } else { %>Found no CSA cookies
<% } // Setup new cookieValue for cookie to be created ... // eg "1056644836107[jmcd]2003-06-26 12:27:16 (EDT)[dom][path]" //cvBuff.append(currTS + "["); cvBuff.append(currTS + "" + currTS); if ((serverName != null) && !serverName.equals("")) { if ((snLen = serverName.length()) >= 4) { // cvBuff.append(serverName.substring(0,4)); } else { // cvBuff.append(serverName); } } // cvBuff.append("]" + ts); if ((cookieDomain != null) && !cookieDomain.equals("")) { // cvBuff.append("" + cookieDomain); } if ((cookiePath != null) && !cookiePath.equals("")) { //cvBuff.append(cookiePath); } cookieValue = cvBuff.toString(); // Set replacement cookie ... newCookie = new Cookie(cookieName, cookieValue); newCookie.setMaxAge(cookieMaxAge); if ((cookiePath != null) && !cookiePath.equals("")) { newCookie.setPath(cookiePath); } if ((cookieDomain != null) && !cookieDomain.equals("")) { newCookie.setDomain(cookieDomain); } %>Add new CSA cookie with value <%= cookieValue %> ...
cookie domain is <%= cookieDomain %> and cookie path is <%= cookiePath %>
<% response.addCookie(newCookie); %>