@Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        // Get input stream from resource
        InputStream input = resource.asStream();

        // If resource does not exist, return not found
        if (input == null) {
            logger.debug("Resource does not exist: \"{}\"", request.getServletPath());
            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
            return;
        }

        try {

            // Write headers
            doHead(request, response);

            // If not modified since "If-Modified-Since" header, return not modified
            long ifModifiedSince = request.getDateHeader("If-Modified-Since");
            if (resource.getLastModified() - ifModifiedSince < 1000) {
                logger.debug("Resource not modified: \"{}\"", request.getServletPath());
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                return;
            }

            int length;
            byte[] buffer = new byte[BUFFER_SIZE];

            // Write resource to response body
            OutputStream output = response.getOutputStream();
            while ((length = input.read(buffer)) != -1)
                output.write(buffer, 0, length);

        }

        // Ensure input stream is always closed
        finally {
            input.close();
        }

    }
Creates a new ResourceServlet which serves the given Resource for all
HTTP GET requests.

@param resource
    The Resource to serve.
guacamole/src/main/java/org/apache/guacamole/resource/ResourceServlet.java