• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet filter exception handling

 
Jefferson Parke
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
 
danny liu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just use Log4j from apache.
Dan
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic