Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Catching Servlet Exceptions

 
Abhijit Sontakey
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write a wrapper around it that does log the exceptions...
 
Abhijit Sontakey
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Martin Simons
Ranch Hand
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,
It solved my problems. Thanks.

Regards
Abhijit
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic