wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes exception-type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "exception-type" Watch "exception-type" New topic
Author

exception-type

shanthisri mocherla
Ranch Hand

Joined: Sep 05, 2005
Posts: 119
Hi friends,
I'm not clear with line in HFSJ page 595.(there are no dumb questions)

Question:
what are you allowed to declare as an exception type in <exception-type>??Answer:

Anything that's throwable so that includes java.lang.Error,runtime exceptions, and any checked exception(as long as the checked exception class is on the Container's classpath,of course)


Can anyone please expand this and expalin me clearly.
Thank you very much
shanthi
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

Question:
what are you allowed to declare as an exception type in <exception-type>??Answer:

Anything that's throwable so that includes java.lang.Error,runtime exceptions, and any checked exception(as long as the checked exception class is on the Container's classpath,of course)


The <exception-type> requires the full class name of the Throwable type, which we want to catch by this mechanism. As the type is "Throwable" we can catch Errors, Run-time Exceptions and Checked Exception. Checked Exceptions are ususlly declare in the method defination throws clause, if you want to propogate the exceptions to the outer world (i.e to Exception handling mechanism).

any checked exception(as long as the checked exception class is on the Container's classpath


If it is required to define custom exceptions for exception handling the user usullay define the checked exceptions. So these checked exception clsses must be accessible to container , so it should be in the container's classpath. If the containe can not find Exception class it will be error.

Hope it help

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: exception-type
 
Similar Threads
ArithmeticException
Explanation required(exception handling)?????
Regarding throwing java.rmi.RemoteException
IllegalArgumentException
difference between error and runtime exception