• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat to track NullPointerException (NPE)

 
Brian Hsu
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, here goes my first post

I have an existing Java web application that's using Apache + Tomcat as servers. There's one thing that's been bothering me a lot: tracking NPEs. Obviously if I know where every possible place a NPE could occur then I could catch them all and do an appropriate action (eg. email notification) but this is not possible for programmers. Currently when the app encounters an unexpected NPE, it just stops and the webpage simply displays an ugly error message to site users and developers have no clue of that happening. What I'm trying to achieve here is:

Can Tomcat handle NPE (and also perhaps all kinds of exceptions) by redirecting users to a proper error page and notifying site administrator with an email?

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, look up error handling in the Servlet Specification.
 
Brian Hsu
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Yes, look up error handling in the Servlet Specification.


So something like this for Tomcat:

<error-page>
<exception-type>NullPointerException</exception-type>
<location>error.jsp</location>
</error-page>

But how can I notify someone of this error through email with information like where the original exception came from etc...?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not Tomcat-specific.
 
Brian Hsu
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:It's not Tomcat-specific.


Thanks That does the first part of redirecting users to a proper error page. What about the second part of notifying someone with detailed information?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic