/** * Forward's the request to the configured error page. * * @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The servlet request instance * @param \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse The servlet response instance * * @return void */ protected function forwardToErrorPage(HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse) { // query whether or not we've an error page configured if ($formLoginConfig = $this->getConfigData()->getFormLoginConfig()) { if ($formErrorPage = $formLoginConfig->getFormErrorPage()) { // initialize the location to redirect to $location = $formErrorPage->__toString(); if ($baseModifier = $servletRequest->getBaseModifier()) { $location = $baseModifier . $location; } // redirect to the configured error page $servletRequest->setDispatched(true); $servletResponse->setStatusCode(307); $servletResponse->addHeader(Protocol::HEADER_LOCATION, $location); return; } } // redirect to the default error page $servletRequest->setAttribute(RequestHandlerKeys::ERROR_MESSAGE, 'Please configure a form-error-page when using auth-method \'Form\' in the login-config of your application\'s web.xml'); $servletRequest->setDispatched(true); $servletResponse->setStatusCode(500); }