This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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
 
 
subject: Catching an Exception inside a Servlet
 
Similar Threads
Spring Transaction
Its not necessary to use SLSB, or is it?
Difference between DAO,DTO,ACTION FORM, ENTITY CLASSES, SERVICES,FORM, MODEL CLASSES
Correct manage of trasactions.
Where to open Hibernate Session and Transactions