folder = createFolder(request.getSession(), folderPath,
if (contextPath.substring(1).equals(theRealPath.getContext())) {   imagePath = contextPath + folderPath; }  folder = createFolder(request.getSession(), folderPath,imagePath,
    public void doGet(HttpServletRequest request, HttpServletResponse response)            throws IOException, ServletException    {        response.setContentType("text/html");        String pathInfo = request.getPathInfo();        String queryString = request.getQueryString();        String pathTranslated = request.getPathTranslated();        String requestURI = request.getRequestURI();        String requestURL = request.getRequestURL().toString();        // contextPath := "/JGallery"        String contextPath = request.getContextPath();        String servletPath = request.getServletPath();        // servletPath := "/galleries" with path mapping        // servletPath= "/testalbum/CRW_9753.html" with ext mapping        // /myfolder/subfolder/myimage.html        // gets split into /myfolder/subfolder/ (which is used as key for the Folder object)        // and imageName myimage.html        String folderPath = servletPath.substring(0, servletPath                .lastIndexOf('/') + 1);        String imageName = servletPath                .substring(servletPath.lastIndexOf('/') + 1);        // getServletContext().log("folderPath: "+folderPath);                                String folderRealPath = null;        String forward = null;        Folder folder = getFolder(request.getSession(), folderPath);        try        {            if (null == folder)            {                RealPath theRealPath = PathHelper.getHttpRealPath(                        getServletContext(), folderPath, dirmapping);                if (null == theRealPath)                {                    response.sendError(HttpServletResponse.SC_NOT_FOUND,                            request.getRequestURI());                    return;                }                folderRealPath = theRealPath.getRealPath();                folder = createFolder(request.getSession(), folderPath,                        folderRealPath, contextPath);                folder.loadFolder();            }            int n = folder.setFileName(imageName);            if (Folder.INDEX == n)            {                forward = folder.getIndexJsp();            }            else            {                forward = folder.getSlideJsp();            }            request.setAttribute("folder", folder);            request.setAttribute("image", folder.getImage());        }        catch (GalleryNotFoundException e)        {            response.sendError(HttpServletResponse.SC_NOT_FOUND, request                    .getRequestURI());            return;        }        catch (GalleryException e)        {            throw new ServletException(e.getMessage());            //            request.setAttribute("javax.servlet.error.exception",e);            //          forward = "/errorpage.jsp";        }        RequestDispatcher requestDispatcher = getServletContext()                .getRequestDispatcher(forward);        requestDispatcher.forward(request, response);    }