aspose file tools*
The moose likes Servlets and the fly likes Catching an Exception inside a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Catching an Exception inside a Servlet" Watch "Catching an Exception inside a Servlet" New topic
Author

Catching an Exception inside a Servlet

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi ,


This is the scenario . I have a servlet calling a DAO Layer which is implemented in Hibernate . I want to show an appropiate page when an exception occurs for which i had configured exceptions and locations inside web.xml file.

If an User Defined Exception (say RecordNotFoundException) is thrown inside the DAO Layer .

Is it sufficient to just use throw new RecordNotFoundException inside the DAO Layer ? or is it necessary the servlet should also catch this exception ??



Please help.


Save India From Corruption - Anna Hazare.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Ravi Pavan wrote:
Is it sufficient to just use throw new RecordNotFoundException inside the DAO Layer ?

Yes

Ravi Pavan wrote:
is it necessary the servlet should also catch this exception ??


Not Required

Hope this helps
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Yes it helped .Thanks a lot.

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Ravi Pavan wrote:Yes it helped .Thanks a lot.


You Are Welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Catching an Exception inside a Servlet