struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave J Dandeneau" <Dave.Danden...@viant.com>
Subject BUG: Null strings getting converted to 'null' was Websphere and 'null' strings
Date Fri, 15 Feb 2002 16:06:06 GMT
I know that a few other people have been confused by this bug, so I hope this clears things
up. The bug is just a small quirk in the Option Tag code. It seems that StringBuffer works
differently on the different JDKs. Here is an example:

StringBuffer sb = new StringBuffer();
String x = null;
sb.append("|");
sb.append(x);
sb.append("|");

System.out.println(sb.toString());

On our Websphere instance which seems to be using jdk 1.3.0 we get this output:
|null|

On a tomcat instance using jdk1.3.1_01 we get this output:
||

After many hours of debugging we found a location in the OptionTag code (org.apache.struts.taglib.OptionTag
and org.apache.struts.taglib.html.OptionTag) that was having this problem. It occurs when
the value field is filled out. It looks something like this:

results.append("<option value=\"");
results.append(value);
results.append("\"");

We added a fix that looks like this:

results.append("<option value=\"");
if (value != null) {
	results.append(value);
}
results.append("\"");

I am sure that this is also a bug in other tag code regarding this issue. I am going to add
this to bugzilla today. 

Thanks,
Dave Dandeneau

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message