• Post Reply Bookmark Topic Watch Topic
  • New Topic

ServletException("message", causeExObject) Constructor

 
Merrill Cornish
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ServletException class documents three constructors:
ServletException("messageString");
ServletException("messageString", causeExceptionObject);
ServletException(causeExceptionObject);
When I use the first one, the exception implicit object on my errorPage.jsp is a ServletException object with "messageString" as its message--exactly as it should be.
When I use the last one, exception of the causeExceptionObject, as it should be.
However, when I use the middle one--message string AND cause object--then the exception implicit object is just the causeExceptionObject rather than a ServletException object with "messageString" for the message and causeExceptionObject as the cause.
Anyone have any idea why? (I'm using j2sdk1.4.2 for JAVA_HOME).
Merrill
 
Owee Nicolas
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
As mentioned in the definition of this Class:

ServletException
public ServletException(String message,Throwable rootCause)
Constructs a new servlet exception when the servlet needs to throw an exception and include a message about the "root cause" exception that interfered with its normal operation, including a description message.

I'm guessing the included message is only the root cause of the exception and not message of the ServletException. You may want to paste your code so we can have a closer look.
Hope that helps.
[ February 12, 2004: Message edited by: Owee Nicolas ]
 
Merrill Cornish
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmmm. Since ServletException is derived from Exception, and Exception("message", causeExObject) works by throwing a new Exception object with causeExObject accessible by getCause(), I assumed ServletException would work the same way.
As long as I stick to Exceptions and SQLExceptions, it works just fine. SO, I think my code is correct. It's only when the top-level exception is ServletException("message", causeExObject) that it fails.

Merrill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!