Hi,
you need those RTTI stuff. Try this: create a class
public class MyException extends Exception
{
final private String mString = "Boo!";
public String getString()
{
return mString;
}
}
and let some JavaBean throw an object of this class. Now in your error.jsp you can do something like this
String messageToDisplay;
Class myExceptionClass = MyException.class;
Class exceptionClass = exception.getClass();
if (myExceptionClass.isAssignableFrom(exceptionClass))
{
MyException myException = (MyException) exception;
messageToDisplay = myException.getString();
}
else
{
messageToDisplay = exception.getMessage();
}
and write a JSP expression to display the message. I've tried this here with j2sdkee1.2.1, jdk1.3.1 and Tomcat 3.2.3 and it works as expected. Note: This is not bullet proof and there're maybe better solutions. Check the documentation and ask your friends about RTTI.
Further reading: JavaWorld, Java Tip 113: Identify subclasses at runtime, Daniel Le Berre, http://www.javaworld.com/javaworld/javatips/jw-javatip113.html
HTH,
Markus 'howlingmad' Neifer