@Override
    protected void doGet(final HttpServletRequest _req,
                         final HttpServletResponse _res)
        throws ServletException
    {
        String contentName = _req.getRequestURI();
        contentName = contentName.substring(contentName.lastIndexOf('/') + 1);
        try {
            final Cache<String, ContentMapper> cache = InfinispanCache.get().<String, ContentMapper>getCache(
                            StaticContentServlet.CACHENAME);
            final int cacheDuration = Configuration.getAttributeAsInteger(Configuration.ConfigAttribute.CACHE_DURATION);

            if (!cache.containsKey(contentName)) {
                final QueryBuilder queryBldr = new QueryBuilder(CIAdminProgram.StaticCompiled);
                queryBldr.addWhereAttrEqValue(CIAdminProgram.StaticCompiled.Name, contentName);
                final MultiPrintQuery multi = queryBldr.getPrint();
                final SelectBuilder selLabel = new SelectBuilder().file().label();
                final SelectBuilder selLength = new SelectBuilder().file().length();
                multi.addSelect(selLabel, selLength);
                multi.addAttribute(CIAdminProgram.StaticCompiled.Name,
                                CIAdminProgram.StaticCompiled.OID,
                                CIAdminProgram.StaticCompiled.Modified);
                multi.executeWithoutAccessCheck();
                if (multi.next()) {
                    final String name = multi.<String>getAttribute(CIAdminProgram.StaticCompiled.Name);
                    final String file = multi.<String>getSelect(selLabel);
                    final Long filelength = multi.<Long>getSelect(selLength);
                    final DateTime datetime = multi.<DateTime>getAttribute(CIAdminProgram.StaticCompiled.Modified);

                    final ContentMapper mapper = new ContentMapper(name, file, multi.getCurrentInstance().getOid(),
                                    filelength, datetime.getMillis());
                    cache.put(contentName, mapper);
                } else {
                    cache.put(contentName, StaticContentServlet.NULL);
                }
            }
            final ContentMapper contentMapper = cache.get(contentName);
            if (contentMapper != null && !contentMapper.equals(StaticContentServlet.NULL)) {
                final Checkout checkout = new Checkout(contentMapper.oid);

                _res.setContentType(getServletContext().getMimeType(contentMapper.file));
                _res.setDateHeader("Last-Modified", contentMapper.time);
                _res.setDateHeader("Expires", System.currentTimeMillis()
                                + (cacheDuration * 1000));
                _res.setHeader("Cache-Control", "max-age=" + cacheDuration);

                if (supportsCompression(_req)) {
                    _res.setHeader("Content-Encoding", "gzip");

                    final ByteArrayOutputStream bytearray = new ByteArrayOutputStream();
                    final GZIPOutputStream zout = new GZIPOutputStream(bytearray);
                    checkout.execute(zout);
                    zout.close();
                    final byte[] b = bytearray.toByteArray();
                    bytearray.close();
                    _res.getOutputStream().write(b);
                    checkout.close();
                } else {
                    _res.setContentLength((int) contentMapper.filelength);
                    checkout.execute(_res.getOutputStream());
                }
            } else if (BundleMaker.containsKey(contentName)) {
                final BundleInterface bundle = BundleMaker.getBundle(contentName);

                _res.setContentType(bundle.getContentType());
                _res.setDateHeader("Last-Modified", bundle.getCreationTime());
                _res.setDateHeader("Expires", System.currentTimeMillis()
                                + (cacheDuration * 1000));
                _res.setHeader("Cache-Control", "max-age=" + cacheDuration);
                _res.setHeader("Content-Encoding", "gzip");

                int bytesRead;
                final byte[] buffer = new byte[2048];

                final InputStream in = bundle.getInputStream(supportsCompression(_req));
                while ((bytesRead = in.read(buffer)) != -1) {
                    _res.getOutputStream().write(buffer, 0, bytesRead);
                }
            }
        } catch (final IOException e) {
            StaticContentServlet.LOG.error("while reading Static Content", e);
            throw new ServletException(e);
        } catch (final CacheReloadException e) {
            StaticContentServlet.LOG.error("while reading Static Content", e);
            throw new ServletException(e);
        } catch (final EFapsException e) {
            StaticContentServlet.LOG.error("while reading Static Content", e);
            throw new ServletException(e);
        }
    }
@Override
    protected void doGet(final HttpServletRequest _req,
                         final HttpServletResponse _res)
        throws ServletException
    {
        String contentName = _req.getRequestURI();
        contentName = contentName.substring(contentName.lastIndexOf('/') + 1);
        try {
            final Cache<String, ContentMapper> cache = InfinispanCache.get().<String, ContentMapper>getCache(
                            StaticContentServlet.CACHENAME);
            final int cacheDuration = Configuration.getAttributeAsInteger(Configuration.ConfigAttribute.CACHE_DURATION);

            if (!cache.containsKey(contentName)) {
                final QueryBuilder queryBldr = new QueryBuilder(CIAdminProgram.StaticCompiled);
                queryBldr.addWhereAttrEqValue(CIAdminProgram.StaticCompiled.Name, contentName);
                final MultiPrintQuery multi = queryBldr.getPrint();
                final SelectBuilder selLabel = new SelectBuilder().file().label();
                final SelectBuilder selLength = new SelectBuilder().file().length();
                multi.addSelect(selLabel, selLength);
                multi.addAttribute(CIAdminProgram.StaticCompiled.Name,
                                CIAdminProgram.StaticCompiled.OID,
                                CIAdminProgram.StaticCompiled.Modified);
                multi.executeWithoutAccessCheck();
                if (multi.next()) {
                    final String name = multi.<String>getAttribute(CIAdminProgram.StaticCompiled.Name);
                    final String file = multi.<String>getSelect(selLabel);
                    final Long filelength = multi.<Long>getSelect(selLength);
                    final DateTime datetime = multi.<DateTime>getAttribute(CIAdminProgram.StaticCompiled.Modified);

                    final ContentMapper mapper = new ContentMapper(name, file, multi.getCurrentInstance().getOid(),
                                    filelength, datetime.getMillis());
                    cache.put(contentName, mapper);
                } else {
                    cache.put(contentName, StaticContentServlet.NULL);
                }
            }
            final ContentMapper contentMapper = cache.get(contentName);
            if (contentMapper != null && !contentMapper.equals(StaticContentServlet.NULL)) {
                final Checkout checkout = new Checkout(contentMapper.oid);

                _res.setContentType(getServletContext().getMimeType(contentMapper.file));
                _res.setDateHeader("Last-Modified", contentMapper.time);
                _res.setDateHeader("Expires", System.currentTimeMillis()
                                + (cacheDuration * 1000));
                _res.setHeader("Cache-Control", "max-age=" + cacheDuration);

                if (supportsCompression(_req)) {
                    _res.setHeader("Content-Encoding", "gzip");

                    final ByteArrayOutputStream bytearray = new ByteArrayOutputStream();
                    final GZIPOutputStream zout = new GZIPOutputStream(bytearray);
                    checkout.execute(zout);
                    zout.close();
                    final byte[] b = bytearray.toByteArray();
                    bytearray.close();
                    _res.getOutputStream().write(b);
                    checkout.close();
                } else {
                    _res.setContentLength((int) contentMapper.filelength);
                    checkout.execute(_res.getOutputStream());
                }
            } else if (BundleMaker.containsKey(contentName)) {
                final BundleInterface bundle = BundleMaker.getBundle(contentName);

                _res.setContentType(bundle.getContentType());
                _res.setDateHeader("Last-Modified", bundle.getCreationTime());
                _res.setDateHeader("Expires", System.currentTimeMillis()
                                + (cacheDuration * 1000));
                _res.setHeader("Cache-Control", "max-age=" + cacheDuration);
                _res.setHeader("Content-Encoding", "gzip");

                int bytesRead;
                final byte[] buffer = new byte[2048];

                final InputStream in = bundle.getInputStream(supportsCompression(_req));
                while ((bytesRead = in.read(buffer)) != -1) {
                    _res.getOutputStream().write(buffer, 0, bytesRead);
                }
            }
        } catch (final IOException e) {
            StaticContentServlet.LOG.error("while reading Static Content", e);
            throw new ServletException(e);
        } catch (final CacheReloadException e) {
            StaticContentServlet.LOG.error("while reading Static Content", e);
            throw new ServletException(e);
        } catch (final EFapsException e) {
            StaticContentServlet.LOG.error("while reading Static Content", e);
            throw new ServletException(e);
        }
    }
@ Override protected void doGet ( final HttpServletRequest _req , final HttpServletResponse _res ) throws ServletException { String contentName = _req . getRequestURI ( ) ; contentName = contentName . substring ( contentName . lastIndexOf ( ' ' ) + 1 ) ; try { final Cache < String , ContentMapper > cache = InfinispanCache . get ( ) . < String , ContentMapper > getCache ( StaticContentServlet . CACHENAME ) ; final int cacheDuration = Configuration . getAttributeAsInteger ( Configuration . ConfigAttribute . CACHE_DURATION ) ; if ( ! cache . containsKey ( contentName ) ) { final QueryBuilder queryBldr = new QueryBuilder ( CIAdminProgram . StaticCompiled ) ; queryBldr . addWhereAttrEqValue ( CIAdminProgram . StaticCompiled . Name , contentName ) ; final MultiPrintQuery multi = queryBldr . getPrint ( ) ; final SelectBuilder selLabel = new SelectBuilder ( ) . file ( ) . label ( ) ; final SelectBuilder selLength = new SelectBuilder ( ) . file ( ) . length ( ) ; multi . addSelect ( selLabel , selLength ) ; multi . addAttribute ( CIAdminProgram . StaticCompiled . Name , CIAdminProgram . StaticCompiled . OID , CIAdminProgram . StaticCompiled . Modified ) ; multi . executeWithoutAccessCheck ( ) ; if ( multi . next ( ) ) { final String name = multi . < String > getAttribute ( CIAdminProgram . StaticCompiled . Name ) ; final String file = multi . < String > getSelect ( selLabel ) ; final Long filelength = multi . < Long > getSelect ( selLength ) ; final DateTime datetime = multi . < DateTime > getAttribute ( CIAdminProgram . StaticCompiled . Modified ) ; final ContentMapper mapper = new ContentMapper ( name , file , multi . getCurrentInstance ( ) . getOid ( ) , filelength , datetime . getMillis ( ) ) ; cache . put ( contentName , mapper ) ; } else { cache . put ( contentName , StaticContentServlet . NULL ) ; } } final ContentMapper contentMapper = cache . get ( contentName ) ; if ( contentMapper != null && ! contentMapper . equals ( StaticContentServlet . NULL ) ) { final Checkout checkout = new Checkout ( contentMapper . oid ) ; _res . setContentType ( getServletContext ( ) . getMimeType ( contentMapper . file ) ) ; _res . setDateHeader ( "Last-Modified" , contentMapper . time ) ; _res . setDateHeader ( "Expires" , System . currentTimeMillis ( ) + ( cacheDuration * 1000 ) ) ; _res . setHeader ( "Cache-Control" , "max-age=" + cacheDuration ) ; if ( supportsCompression ( _req ) ) { _res . setHeader ( "Content-Encoding" , "gzip" ) ; final ByteArrayOutputStream bytearray = new ByteArrayOutputStream ( ) ; final GZIPOutputStream zout = new GZIPOutputStream ( bytearray ) ; checkout . execute ( zout ) ; zout . close ( ) ; final byte [ ] b = bytearray . toByteArray ( ) ; bytearray . close ( ) ; _res . getOutputStream ( ) . write ( b ) ; checkout . close ( ) ; } else { _res . setContentLength ( ( int ) contentMapper . filelength ) ; checkout . execute ( _res . getOutputStream ( ) ) ; } } else if ( BundleMaker . containsKey ( contentName ) ) { final BundleInterface bundle = BundleMaker . getBundle ( contentName ) ; _res . setContentType ( bundle . getContentType ( ) ) ; _res . setDateHeader ( "Last-Modified" , bundle . getCreationTime ( ) ) ; _res . setDateHeader ( "Expires" , System . currentTimeMillis ( ) + ( cacheDuration * 1000 ) ) ; _res . setHeader ( "Cache-Control" , "max-age=" + cacheDuration ) ; _res . setHeader ( "Content-Encoding" , "gzip" ) ; int bytesRead ; final byte [ ] buffer = new byte [ 2048 ] ; final InputStream in = bundle . getInputStream ( supportsCompression ( _req ) ) ; while ( ( bytesRead = in . read ( buffer ) ) != - 1 ) { _res . getOutputStream ( ) . write ( buffer , 0 , bytesRead ) ; } } } catch ( final IOException e ) { StaticContentServlet . LOG . error ( "while reading Static Content" , e ) ; throw new ServletException ( e ) ; } catch ( final CacheReloadException e ) { StaticContentServlet . LOG . error ( "while reading Static Content" , e ) ; throw new ServletException ( e ) ; } catch ( final EFapsException e ) { StaticContentServlet . LOG . error ( "while reading Static Content" , e ) ; throw new ServletException ( e ) ; } }
The method checks the image from the user interface image object out and
returns them in a output stream to the web client. The name of the user
interface image object must given as name at the end of the path.

@param _req request variable
@param _res response variable
@throws ServletException on error
The method checks the image from the user interface image object out and returns them in a output stream to the web client . The name of the user interface image object must given as name at the end of the path .