aspose file tools*
The moose likes Servlets and the fly likes Tomcat to track NullPointerException (NPE) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tomcat to track NullPointerException (NPE)" Watch "Tomcat to track NullPointerException (NPE)" New topic
Author

Tomcat to track NullPointerException (NPE)

Brian Hsu
Greenhorn

Joined: Aug 04, 2011
Posts: 12
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

Joined: Jan 10, 2002
Posts: 61764
    
  67

Yes, look up error handling in the Servlet Specification.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Brian Hsu
Greenhorn

Joined: Aug 04, 2011
Posts: 12
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

Joined: Jan 10, 2002
Posts: 61764
    
  67

It's not Tomcat-specific.
Brian Hsu
Greenhorn

Joined: Aug 04, 2011
Posts: 12
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
 
subject: Tomcat to track NullPointerException (NPE)