• Post Reply Bookmark Topic Watch Topic
  • New Topic

throwing exceptions in JSP

 
Keynes Paul Paul
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I'm using error pages to handle html error codes 500 and 400 , when the 500 error is handled i see a NullPointerException generated, so I have this error in web.xml so i can handle the error for the entire module. I ahev tested it in my local machine and also it works in the dev server.
Now, to make sure the error page is reliable , i am testing it and I want to simulate an error situation for which i need to generate a null pointer exception, So is there a way to generate this exception?

Regards,
Keynes.
 
Amit Degavekar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi you can always thro nullpointer explicitely by using throws clause.
Otherwise do siple step.
Set any object to null and call it's method.
e.g.
String str = null;
str.toString();
this line will throw NullPointerException

Cheers!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!