Source:
public String renderPage(HttpRequest request, HttpResponse response) { RequestLookup requestLookup = createRequestLookup(request, response); API api = new API(sessionRegistry, requestLookup); Theme theme = getRenderingTheme(api); try { return renderPageUri(request.getUriWithoutContextPath(), null, requestLookup, api, theme); } catch (SessionNotFoundException e) { String loginPageUri = configuration.getLoginPageUri().orElseThrow(() -> e); throw new PageRedirectException(requestLookup.getContextPath() + loginPageUri, e); } catch (PageRedirectException e) { throw e; } catch (PageNotFoundException e) { String uriWithoutContextPath = request.getUriWithoutContextPath(); String correctedUriWithoutContextPath = uriWithoutContextPath.endsWith("/") ? uriWithoutContextPath.substring(0, uriWithoutContextPath.length() - 1) : (uriWithoutContextPath + "/"); if (hasPage(correctedUriWithoutContextPath)) { if (request.getMethod().equals("GET")) { String correctedUri = request.getContextPath() + correctedUriWithoutContextPath; if (request.getQueryString() != null) { correctedUri = correctedUri + '?' + request.getQueryString(); } throw new PageRedirectException(correctedUri, e); } else { return renderErrorPage(new PageNotFoundException( e.getMessage() + " Retry with correct URI ending " + correctedUriWithoutContextPath, e), requestLookup, api, theme); } } else { return renderErrorPage(e, requestLookup, api, theme); } } catch (HttpErrorException e) { return renderErrorPage(e, requestLookup, api, theme); } catch (UUFException e) { return renderErrorPage(new HttpErrorException(HttpResponse.STATUS_INTERNAL_SERVER_ERROR, e.getMessage(), e), requestLookup, api, theme); } }

Target:
public String renderPage(HttpRequest request, HttpResponse response) { RequestLookup requestLookup = createRequestLookup(request, response); API api = new API(sessionRegistry, requestLookup); Theme theme = getRenderingTheme(api); try { return renderPageUri(request.getUriWithoutContextPath(), null, requestLookup, api, theme); } catch (SessionNotFoundException e) { String loginPageUri = configuration.getLoginPageUri().orElseThrow(() -> e); throw new PageRedirectException(requestLookup.getContextPath() + loginPageUri, e); } catch (PageRedirectException e) { throw e; } catch (PageNotFoundException e) { String uriWithoutContextPath = request.getUriWithoutContextPath(); String correctedUriWithoutContextPath = uriWithoutContextPath.endsWith("/") ? uriWithoutContextPath.substring(0, uriWithoutContextPath.length() - 1) : (uriWithoutContextPath + "/"); if (hasPage(correctedUriWithoutContextPath)) { if (request.isGetRequest()) { String correctedUri = request.getContextPath() + correctedUriWithoutContextPath; if (request.getQueryString() != null) { correctedUri = correctedUri + '?' + request.getQueryString(); } throw new PageRedirectException(correctedUri, e); } else { String message = e.getMessage() + " Retry with correct URI ending " + correctedUriWithoutContextPath; return renderErrorPage(new PageNotFoundException(message, e), requestLookup, api, theme); } } else { return renderErrorPage(e, requestLookup, api, theme); } } catch (HttpErrorException e) { return renderErrorPage(e, requestLookup, api, theme); } catch (UUFException e) { return renderErrorPage(new HttpErrorException(HttpResponse.STATUS_INTERNAL_SERVER_ERROR, e.getMessage(), e), requestLookup, api, theme); } }