[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
[Home]
http referer
Hi!
I'm using GNUJSP 1.0.1. I have two JSPs, one of which is an error page like
this:
one.jsp:
<%@page errorPage="error.jsp"%>
<jsp:useBean id="someBean" scope="request" class="..."/>
...
<%
someBean.doSomething();
%>
...
error.jsp:
<%@page isErrorPage = "true" %>
<jsp:useBean id="notifier" class="..."/>
<%
notifier.sendEmail(request,exception);
%>
I have written a bean (notifier) which sends me the stack trace of a JSP
runtime exception by email, but I'm unable to reproduce the URL of the
request which triggered the exception. Normally, I'd get the URL by
request.getHeader("referer"). I've looked into the sources and noticed the
request object is forwarded to the errorPage in method
pageContext.handlePageException() (class PageContextImpl) but it seems as
if the request object in the errorPage is created anew, because the
"referer" header field is not set. Furthermore, request.getRequestURI()
returns the URI of the error page instead of the one which passed the
exception for handling.
Should I write my own implementation of the Exception object or is there
some trick hidden in the bag? I could for example modify the source
(probably JavaEmitter) by including the request URL with the exception
message like this (from java source generated by JavaEmitter):
try {
...
} catch (Throwable e) {
out.clearBuffer ();
Exception ee = new Exception ("url: " +
HttpUtils.getRequestUrl(request) + ": " + e.getMessage());
pageContext.handlePageException(ee);
} finally {
out.flush ();
factory.releasePageContext (pageContext);
}
If it is possible I would rather avoid recompiling the source.
Help appreciated!
Primoz