• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RequestDispatcher.forward ( ) exceptions can be gobbled up ???

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

I have a question about exceptions thrown by RequestDispatcher . forward ( ), can anyone kindly clarify this thing.

I am using RequestDispatcher . forward ( ) to redirect the browser to a static resource � an xls file. Now, I think I can be sure that it doesn�t throw any exceptions, since its forwarded to a static resource, so can I gobble up the exceptions ??

try
{ request.getRequestDispatcher("fullUserList.xls").forward(request,response);
}
catch(IOException e)
{

}
catch(ServletException e)
{

}





thanks.jw
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

do u mean u can leave the catch block empty? I do not think that's a wise decision. You have to put a catch block anyway, so why not print the StackTrace?

Moreover, an exception can still occur if the Excel file is moved elsewhere under the context. That's just one cause. Exceptions are supposed to occur at Runtime, so why take a call when you are writing the code? :roll:
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by john wesley:
can I gobble up the exceptions ??



By the way, why you want it that way?
Isn't it better to catch the exception and handle it in a more appropriate way.
[ September 16, 2005: Message edited by: Adeel Ansari ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic