wood burning stoves 2.0*
The moose likes JSP and the fly likes NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "NullPointerException" Watch "NullPointerException" New topic
Author

NullPointerException

amit bhadre
Ranch Hand

Joined: Jan 23, 2006
Posts: 124
How to Handle NullPointerException in JSP?


Thanks advance who ever answers this question.


regards
amit bhadre
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

It is not advicable to catch RuntimeException and its subclasses.

Do you have any specific reasons to do? If so,

1. Write a JSP with page attribute isErrorPage="true", so that you will get exception implicit object avaliable for you to see what exception occured.

2. In the other JSP you can add errorPage="<pointing to the previous JSP>".

OR

1. Step-1 above

2. In web.xml(Deployment Decriptor),

<error-page>
<exception-type>java.lang.NullPointerException</exception-type>
<location>(pointing to the previous JSP you created)</location>
</error-page>


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

If you think you can recover from the exception I would suggest a c : catch block. What part of your code throws this ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
 
GeeCON Prague 2014
 
subject: NullPointerException