Null values

In Java, you can distinguish between a String variable whose value is null and one whose value is an empty String. Likewise, in a relational database, you can distinguish between a column or parameter whose value is null and one whose value is an empty String. However, in an HTML page, when looking at output or entering data in a form, no universal mechanism is defined for distinguishing a null value from an empty String.

To help deal with this situation, the JSP SQL tags provide a nullToken attribute that you can use to specify a String to represent null values for columns and parameters. This String represents the null value both when a column or parameter value is retrieved and written to the JSP output, and when a value is set in the JSP for a column or parameter.

If you specify the nullToken attribute on an x:select, x:modify, or x:procedureCall action, it serves as a default when getting and setting any columns and parameters of that object. You can also override the attribute on each action that gets or sets a column or parameter. If the attribute is not specified either at the level of the object or the level of the action that gets or sets a value, the default is to use an empty String to represent null values.

Because of the way JSP files are processed in WebSphere, specifying nullToken="" cannot be distinguished from omitting the nullToken attribute and taking the default. Likewise, specifying value="" cannot be distinguished from omitting the attribute (which has no default). Since you need to be able to specify the empty String as either the value of a column or parameter or as the desired null token, we provide the special value &empty to represent an empty String in these attributes. We also provide the special value &null to represent a null Object reference. These are similar to character entities in HTML, and allow you to specify values that are difficult or impossible to express otherwise.

If you specify nullToken="&null", null values are represented as null Object references. When a null Object reference is passed to WebSphere 3.5's JSP output writer, it writes the characters "null" to the JSP output. (In some earlier versions, it wrote an empty String.) If you then pass the characters "null" back in as the value for a column or parameter, it will be set to the characters "null" in the database, not a null. You would have to use a scriptlet to pass an actual null Object reference in order to set a null in the database. Because of the added work required to complete this round-trip, it is more likely that you will want to specify the nullToken as either &empty or the characters "null".

The following actions have the nullToken attribute: x:select, x:modify, x:procedureCall, x:getColumn, x:setColumn, x:column, x:getParameter, and x:parameter.