• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Design issue- should ActionServlet catch all exceptions

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the code:
try{
userController.createUser(userDetails);
}catch(CreateException ex){
s.setAttribute("user.failure.create","something");
return mapping.findForward("failure");
}
I am trying to insert an entity and userController is a session bean to which a value object( a standard java bean) is being passed. The createUser method of session bean throws just one CreateException.
My question is: Should I handle just CreateException in the servlet. Obviously the container could throw EJBEXception (or any of the run time exceptions too). Or should all clietn handle catch(Exception e) {}.
thanks.
- walk rustin
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Walker Rustin:
My question is: Should I handle just CreateException in the servlet. Obviously the container could throw EJBEXception (or any of the run time exceptions too). Or should all clietn handle catch(Exception e) {}.


IMO,
Remote EJB Client - CreateException, RemoteException
Local EJB Client - CreateException, EJBException.(Runtime exception)
Trying to catch all exceptions at different places may not be a good idea. You could allow other run time exceptions to percolate to the JSP/Struts layer and catch it one place and redirect the user to an custom-error page.
If you try posting this in the EJB forum, you are likely to get more answers.....
 
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic