public void commit ( ) { if ( isCommitted ( ) ) { return ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Committing: " + this ) ; } if ( null == this . response . getHeader ( "Content-Language" ) ) { // content-language not yet set, add now this . response . setHeader ( "Content-Language" , getLocale ( ) . toString ( ) . replace ( ' ' , ' ' ) ) ; } if ( null != this . response . getHeader ( "Content-Encoding" ) ) { this . response . removeHeader ( "Content-Length" ) ; } // if a session exists, store the set-cookie in the response now SessionInfo info = this . request . getSessionInfo ( ) ; if ( null != info ) { SessionConfig config = info . getSessionConfig ( ) ; if ( config . usingCookies ( ) && null != info . getSession ( ) ) { // create a session cookie now boolean add = true ; HttpCookie existing = this . response . getCookie ( config . getIDName ( ) ) ; if ( null != existing ) { if ( ! info . getSession ( ) . getId ( ) . equals ( existing . getValue ( ) ) ) { // some other session cookie existed but doesn't match // the current session, remove it this . response . removeCookie ( existing ) ; } else { // this session already exists add = false ; } } if ( add ) { this . response . addCookie ( convertCookie ( SessionInfo . encodeCookie ( info ) ) ) ; } } } // end-if-request-session-exists }
When headers are being marshalled out this message moves to committed state which will disallow most further changes .