I have changed code to below to make it work.final String gotoPath =
xssApi.filterHTML(request.getParameter(gotoParam)); final URI gotoUri =
new URI(gotoPath, false); if (StringUtils.isNotEmpty(gotoPath)) { final
Resource gotoPathResource =
request.getResourceResolver().resolve(gotoUri.getPath()); if (null !=
gotoPathResource && null != gotoPathResource.adaptTo(Page.class)) {
response.sendRedirect(gotoPath); return; } } redirect(request, response,
redirectPath);