@Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {

        String url = this.getURL(req);

        LOGGER.debug("Started processing request : {}", url);

        List<String> resourcesToMerge = findResourcesToMerge(req.getContextPath(), url);
        String extensionOrPath = detectExtension(url);//in case of non js/css files it null
        if (extensionOrPath.isEmpty()) {
            extensionOrPath = resourcesToMerge.get(0);//non grouped i.e. non css/js file, we refer it's path in that case
        }

        //If not modified, return 304 and stop
        ResourceStatus status = JSCSSMergeServlet.isNotModified(this.getServletContext(), req, resourcesToMerge, this.turnOffETag);
        if (status.isNotModified()) {
            LOGGER.trace("Resources Not Modified. Sending 304.");
            String ETag = !this.turnOffETag ? status.getActualETag() : null;
            JSCSSMergeServlet.sendNotModified(resp, extensionOrPath, ETag, this.expiresMinutes, this.cacheControl, this.overrideExistingHeaders);
            return;
        }


        //Add appropriate headers
        this.addAppropriateResponseHeaders(extensionOrPath, resourcesToMerge, status.getActualETag(), resp);

        OutputStream outputStream = resp.getOutputStream();
        String contextPathForCss = customContextPathForCSSUrls != null ?
                customContextPathForCSSUrls : req.getContextPath();
        ProcessedResult processedResult = this.processResources(contextPathForCss, outputStream, resourcesToMerge);
        int resourcesNotFound = processedResult.getNumberOfMissingResources();

        if (resourcesNotFound > 0 && resourcesNotFound == resourcesToMerge.size()) { //all resources not found
            resp.sendError(HttpServletResponse.SC_NOT_FOUND);
            LOGGER.warn("All resources are not found. Sending 404.");
            return;
        }
        if (outputStream != null) {
            try {
                resp.setStatus(HttpServletResponse.SC_OK);
                outputStream.close();
            } catch (Exception e) {
                // ignore
            }
        }
        resp.setHeader("Content-Length", String.valueOf(processedResult.contentLength));
        LOGGER.debug("Finished processing Request : {}", url);
    }
@ Override protected void doGet ( HttpServletRequest req , HttpServletResponse resp ) throws ServletException , IOException { String url = this . getURL ( req ) ; LOGGER . debug ( "Started processing request : {}" , url ) ; List < String > resourcesToMerge = findResourcesToMerge ( req . getContextPath ( ) , url ) ; String extensionOrPath = detectExtension ( url ) ; if ( extensionOrPath . isEmpty ( ) ) { extensionOrPath = resourcesToMerge . get ( 0 ) ; } ResourceStatus status = JSCSSMergeServlet . isNotModified ( this . getServletContext ( ) , req , resourcesToMerge , this . turnOffETag ) ; if ( status . isNotModified ( ) ) { LOGGER . trace ( "Resources Not Modified. Sending 304." ) ; String ETag = ! this . turnOffETag ? status . getActualETag ( ) : null ; JSCSSMergeServlet . sendNotModified ( resp , extensionOrPath , ETag , this . expiresMinutes , this . cacheControl , this . overrideExistingHeaders ) ; return ; } this . addAppropriateResponseHeaders ( extensionOrPath , resourcesToMerge , status . getActualETag ( ) , resp ) ; OutputStream outputStream = resp . getOutputStream ( ) ; String contextPathForCss = customContextPathForCSSUrls != null ? customContextPathForCSSUrls : req . getContextPath ( ) ; ProcessedResult processedResult = this . processResources ( contextPathForCss , outputStream , resourcesToMerge ) ; int resourcesNotFound = processedResult . getNumberOfMissingResources ( ) ; if ( resourcesNotFound > 0 && resourcesNotFound == resourcesToMerge . size ( ) ) { resp . sendError ( HttpServletResponse . SC_NOT_FOUND ) ; LOGGER . warn ( "All resources are not found. Sending 404." ) ; return ; } if ( outputStream != null ) { try { resp . setStatus ( HttpServletResponse . SC_OK ) ; outputStream . close ( ) ; } catch ( Exception e ) { } } resp . setHeader ( "Content-Length" , String . valueOf ( processedResult . contentLength ) ) ; LOGGER . debug ( "Finished processing Request : {}" , url ) ; }
/* (non-Javadoc)
@see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)