void _prepareResponseDataOnlyOnce ( HttpServletRequest req ) { if ( req . getAttribute ( KEY_FILE ) == null ) { String pathInfo = req . getPathInfo ( ) ; if ( pathInfo == null ) pathInfo = "" ; String fileSeparator = System . getProperty ( "file.separator" ) ; String filePath = pathInfo . replaceAll ( Pattern . quote ( "/" ) , fileSeparator ) ; String mappedDirPath = getMappedDirPath ( ) ; File file = new File ( mappedDirPath , filePath ) ; boolean isDirectory = file . isDirectory ( ) ; req . setAttribute ( KEY_IS_DIR , isDirectory ) ; if ( isDirectory ) file = new File ( mappedDirPath , getIndexFilename ( ) ) ; req . setAttribute ( KEY_FILE , file ) ; req . setAttribute ( KEY_MIME , __getMimeType ( file ) ) ; req . setAttribute ( KEY_LAST_MODIFIED , file . exists ( ) ? file . lastModified ( ) : 0 ) ; } }
prepares the response data associated with given request .