Problem
This is a follow-up to yesterday\'s (unanswered) question (see here) as I try to find an alternative approach.
I added the basic
The <error-page>
is under the covers served by a RequestDispatcher#forward() call. All details of the original request are available as request attribues which are keyed by the keys as identified by RequestDispatcher#FORWARD_XXX constants:
"javax.servlet.forward.context_path"
"javax.servlet.forward.path_info"
"javax.servlet.forward.query_string"
"javax.servlet.forward.request_uri"
"javax.servlet.forward.servlet_path"
You as starter should know that all request attributes are in EL available via the implicit EL object #{requestScope}
.
So, all with all, this should do in the view:
<p>Unfortunately, the page you requested, #{requestScope['javax.servlet.forward.request_uri']} does not exist</p>
And equivalently, this should do in the bean, if necessary:
String forwardRequestURI = externalContext.getRequestMap().get(RequestDispatcher.FORWARD_REQUEST_URI);
You might be able to get that URL with the "referer" (misspelled) request header.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.36
Java usage: HttpServletRequest - how to obtain the referring URL?