code: @Override
      void _prepareResponseDataOnlyOnce(HttpServletRequest req) {
          if (req.getAttribute(KEY_INIT) == null) {
              
              String pathInfo = req.getPathInfo();
              
              if (pathInfo == null)
                  pathInfo = "";
              
              String embeddedPath = getMappedDirPath();
  
              if (embeddedPath.endsWith("/")) {
                  embeddedPath = embeddedPath.substring(0, embeddedPath.length() - 1);
              }
  
              embeddedPath = embeddedPath + pathInfo;
  
              if (embeddedPath.endsWith("/")) {
                  embeddedPath = embeddedPath.substring(0, embeddedPath.length() - 1);
              }
  
              InputStream is = EmbeddedFileServlet.class.getResourceAsStream(embeddedPath);
  
              boolean isDir;
  
              if (is == null) {
                  isDir = false;
              } else {
                  try {
                      is.available(); // <-- Workaround to detect embedded directories
                      isDir = false;
                  } catch (NullPointerException ex) {
                      isDir = true;
                      try {
                          is.close();
                      } catch (NullPointerException | IOException ignored) {}
                      is = null;
                  } catch (IOException ex) {
                      isDir = false;
  
                      req.setAttribute(KEY_IO_ERR, ex);
                      req.setAttribute(KEY_INIT, true);
                      req.setAttribute(KEY_IS_DIR, isDir);
                      return;
                  }
              }
              
              req.setAttribute(KEY_IS_DIR, isDir);
  
              if (isDir) {
                  embeddedPath = String.format("%s/%s", embeddedPath, getIndexFilename());
                  is = EmbeddedFileServlet.class.getResourceAsStream(embeddedPath);
              }
  
              req.setAttribute(KEY_INPUT_STREAM, is);
              req.setAttribute(KEY_MIME, _getMimeType(embeddedPath));
              req.setAttribute(KEY_INIT, true);
          }
      }
docs: </editor-fold>