• 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

Catching Servlet Exceptions

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I need help in ctahing the exceptions thrown by a servlet that is used in the following manner:

<img src=/webapp//abhijit/servlet/<ServletName>?&<params/>
The problem is that the servlet specified is a third party servlet, hence the exceptions thrown by the servlet are not logged in the log file. I need to catch the exception thrown by the servlet or log it using Log4j logging. Can anybody help me in this regard. Any help will be appreciated.

Regards
Abhijit
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depending on how the servlet is written (ie whether it needs special configuration) you may be able to get away wiuth th wrapping it in your own servlet and treating their servlet as a class:



Dave
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Write a wrapper around it that does log the exceptions...
 
Abhijit Sontakey
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The servlet is a thoird party servlet. I don't have its source code and hence can't catch the exception. Can you help me in handling such a servlet.

Regards
Abhijit
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried the example presented from David O'Meara. You don't need
that servlets source code to at least try what he suggested, since, in
order for it to be a servlet at all, it must implement the Servlet
interface. Wrap those methods in a class of your own calling the other
servlet as a normal class and redirect the server configuartion to point to
your new servlet instead of the original.
 
Abhijit Sontakey
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,
It solved my problems. Thanks.

Regards
Abhijit
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeroen T Wenting:
Write a wrapper around it that does log the exceptions...



Great minds

Glad it worked.
Note that the example given was quicjk and dirt and there are improvements that can be made. BUT if it isn't a problem it's it's only woirth spending enough time to get it done.
 
reply
    Bookmark Topic Watch Topic
  • New Topic