private void saveAttributesBeforeInclude ( final Invocation inv ) { ServletRequest request = inv . getRequest ( ) ; logger . debug ( "Taking snapshot of request attributes before include" ) ; Map < String , Object > attributesSnapshot = new HashMap < String , Object > ( ) ; Enumeration < ? > attrNames = request . getAttributeNames ( ) ; while ( attrNames . hasMoreElements ( ) ) { String attrName = ( String ) attrNames . nextElement ( ) ; attributesSnapshot . put ( attrName , request . getAttribute ( attrName ) ) ; } inv . setAttribute ( "$$paoding-rose.attributesBeforeInclude" , attributesSnapshot ) ; }
Keep a snapshot of the request attributes in case of an include to be able to restore the original attributes after the include .