• 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

Servlet filter exception handling

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any recommended approach to catching exceptions thrown by servlet filters, in the literal sense, not just an error-page forward? Specifically, I am using the jCIFS NTLM authentication filter (http://jcifs.samba.org/src/docs/ntlmhttpauth.html) and want to catch exceptions such as java.net.UnknownHostException thrown when one of the filters' arguments is invalid. I want to catch exceptions thrown by servlet filters, log them, and then forward to an appropriate error page. Any recommendations?
Thanks,
Jeff
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just use Log4j from apache.
Dan
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can declare an error handler for any particular exception in the web.xml file.
(Log4j can in no way help catch the exception and forward).
[ May 03, 2004: Message edited by: Bear Bibeault ]
 
Jefferson Parke
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you say error handler, are you referring to the error-page web.xml definition? If so, this is not quite what I am looking for. Error-page simply forwards the request to some URL but doesn't forward the exception with it (or does it?). I need the ability to log the exception first then forward to some URL. What were you referring to?
Thanks,
Jeff
 
Jefferson Parke
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see that attributes with keys that start with "javax.servlet.error" are forwarded in the request object to the target of the <error-page>. I'll just use the information provided by those attributes to create a log entry. Thanks.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I see that attributes with keys that start with "javax.servlet.error" are forwarded in the request object to the target of the <error-page>


Exactly. Any info you need to process the error is available.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic