use of com.genexus.servlet.http.ICookie in project JavaClasses by genexuslabs.
the class GXWebObjectStub method dumpRequestInfo.
private void dumpRequestInfo(HttpContext httpContext) {
IHttpServletRequest request = httpContext.getRequest();
StringBuffer sBuffer = new StringBuffer();
String nl = System.getProperty("line.separator");
sBuffer.append("Request Information");
sBuffer.append(nl + "Url: ");
sBuffer.append(request.getRequestURL());
sBuffer.append(nl + "HttpHeaders: " + nl);
for (Enumeration<String> headerNames = request.getHeaderNames(); headerNames.hasMoreElements(); ) {
String header = headerNames.nextElement();
sBuffer.append(header);
sBuffer.append(":");
sBuffer.append(request.getHeader(header));
}
sBuffer.append(nl + "HttpCookies: " + nl);
ICookie[] cookies = httpContext.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
sBuffer.append(cookies[i].getName());
sBuffer.append(":");
sBuffer.append(cookies[i].getValue());
}
}
logger.debug(sBuffer.toString());
}
use of com.genexus.servlet.http.ICookie in project JavaClasses by genexuslabs.
the class HttpContextWeb method setCookieRaw.
public byte setCookieRaw(String name, String value, String path, java.util.Date expiry, String domain, double secure, Boolean httpOnly) {
if (response != null) {
ICookie cookie = new Cookie(name, value);
if (path.trim().length() > 0)
cookie.setPath(path.trim());
if (!expiry.equals(CommonUtil.nullDate())) {
long expiryTime = ((expiry.getTime() - new Date().getTime()) / 1000);
if (expiryTime < 0) {
expiryTime = 0;
}
cookie.setMaxAge((int) expiryTime);
}
if (domain.trim().length() > 0)
cookie.setDomain(domain.trim());
cookie.setSecure(secure != 0);
if (servletContext.getMajorVersion() >= 3)
// Requiere servlet version 3.0
cookie.setHttpOnly(httpOnly);
response.addCookie(cookie);
cookies.put(name, value);
}
return 0;
}
Aggregations