@ Override protected void doGet ( final HttpServletRequest _req , final HttpServletResponse _resp ) throws ServletException { String fileName = _req . getRequestURI ( ) ; fileName = fileName . substring ( fileName . lastIndexOf ( ' ' ) + 1 ) ; try { final Person pers = Context . getThreadContext ( ) . getPerson ( ) ; if ( pers != null ) { final File file = getFile ( pers . getId ( ) , fileName ) ; if ( file != null && file . exists ( ) ) { _resp . setContentType ( getServletContext ( ) . getMimeType ( file . getName ( ) ) ) ; _resp . setContentLength ( ( int ) file . length ( ) ) ; _resp . setDateHeader ( "Last-Modified" , System . currentTimeMillis ( ) ) ; _resp . setDateHeader ( "Expires" , System . currentTimeMillis ( ) ) ; _resp . addHeader ( "Content-Disposition" , "inline; filename=\"" + file . getName ( ) + "\"" ) ; _resp . setHeader ( "Cache-Control" , "max-age=10" ) ; final FileInputStream input = new FileInputStream ( file ) ; IOUtils . copy ( input , _resp . getOutputStream ( ) ) ; } } } catch ( final EFapsException e ) { FileServlet . LOG . error ( "EFapsException" , e ) ; throw new ServletException ( e ) ; } catch ( final IOException e ) { FileServlet . LOG . error ( "IOException" , e ) ; throw new ServletException ( e ) ; } }
Search for the requested file in the folder corresponding to the user of the context .