Well I would most certainly not be doing SQL on a JSP page or passing a result set to a JSP page, but the general problem is that when the result of a scriptlet expression is null, it translates to the
string "null" in the output as you have discovered.
One solution is to do something along the lines of:
(assuming that the scripting variable 'whatever' is a String -- extrapolate to the approriate conersion if not)