public void addCookie ( Cookie cookie ) { // // Note: this method is overwritten in servlet 4.0 // if ( com . ibm . ejs . ras . TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) { //306998.15 logger . logp ( Level . FINE , CLASS_NAME , "addCookie" , "Adding cookie --> " + cookie . getName ( ) , "[" + this + "]" ) ; } // d151464 - check the include flag WebAppDispatcherContext dispatchContext = ( WebAppDispatcherContext ) getRequest ( ) . getWebAppDispatcherContext ( ) ; if ( dispatchContext . isInclude ( ) == true ) { if ( com . ibm . ejs . ras . TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) //306998.15 logger . logp ( Level . FINE , CLASS_NAME , "addCookie" , nls . getString ( "Illegal.from.included.servlet" , "Illegal from included servlet" ) , "addCookie cookie --> " + cookie . getName ( ) ) ; //311717 } else { if ( ! _ignoreStateErrors && isCommitted ( ) ) { // log a warning (only the first time)...ignore headers set after response is committed IServletWrapper wrapper = dispatchContext . getCurrentServletReference ( ) ; if ( logWarningActionNow ( wrapper ) ) { logAlreadyCommittedWarning ( new Throwable ( ) , "addCookie" ) ; } else { logger . logp ( Level . FINE , CLASS_NAME , "addCookie" , "Cannot set header. Response already committed." ) ; } } else { _response . addCookie ( cookie ) ; } } }
Uses the given HTTP response message to assign a new value to a browser - specific cookie . Updates the response to restrict caching of sensitive cookie - related data .