All I need to do is avoid any failure due to null in my JSP. Do we test null as -
Easiest way is the EL 'empty' operator:
This checks if the variable is null, an empty string, an empty array or collection etc. and is pretty useful. It will certainly catch the case you are looking for.
Note however that if you are using EL, it suppresses almost all occurrences of null anyway - you'll rarely (if ever) see a NullPointerException. This can be useful when you want to suppress NPEs but don't want to have to write explicit exception handling code!
With JSTL you would need to take account of the possibilities for nulls as the tags don't suppress NPEs like EL does. So you would either have to use the 'empty' operator above to check for nulls up-front, or alternatively use <c:catch> to handle the exceptions yourself.
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )