JSP Error Page usage

Hi all.

I have a JSP error page. When the exception occurs in one of our JSPs, it gets redirected to the error page us usual.

I want to get hold the name of the page the error occured in. If I get request.getHeader("referer") it gives me the name of the page before that, but not actually the one where the error occured.

Any ideas please?

[364 byte] By [_NBee_a] at [2007-11-27 6:02:12]
# 1

the error will contain the "stacktrace", this stacktrace will tell you which servlet or JSP was the root cause of the error.

The error page is reached through a forward, not a redirect, so if you want to get the page that caused the error you need to fetch the current page name using one of the HttpServletRequest methods, not by fetching the referrer.

gimbal2a at 2007-7-12 16:43:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
The "referer" is the page on which you clicked a link to make the current request.The closest I think you can get is the url of the page you invoked.you could try request.getRequestURI();or maybe request().getAttribute("javax.servlet.forward.request_uri")
evnafetsa at 2007-7-12 16:43:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Yes! request.getAttribute("javax.servlet.forward.request_uri") does the trick. Many thanks.
_NBee_a at 2007-7-12 16:43:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Having said that, I found that it doesn't work on an old version of Tomcat, 4.0.6. Probably because it supports the old JSP/Servlet specification.Any ideas what that key would be for the old version?
_NBee_a at 2007-7-12 16:43:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

I don't have Tomcat 4 running here, but I can tell you that you can get all attribute names using request.getAttributeNames().

Enumeration attributeNames = request.getAttributeNames();

while (attributeNames.hasMoreElements()) {

String attributeName = (String) attributeNames.nextElement();

System.out.println(attributeName + " = " + request.getAttribute(attributeName));

}

might help in debugging.

BalusCa at 2007-7-12 16:43:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...