wood burning stoves 2.0*
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
 
wood burning stoves
 
subject: Catching an Exception inside a Servlet
 
Similar Threads
Difference between DAO,DTO,ACTION FORM, ENTITY CLASSES, SERVICES,FORM, MODEL CLASSES
Where to open Hibernate Session and Transactions
Its not necessary to use SLSB, or is it?
Correct manage of trasactions.
Spring Transaction