This works:
String address1 = HtmlUtil.escape(rs.getString("address1"));
...but i don't want to display "null". So i tried this, which does not work:
String address1 = HtmlUtil.escape(rs.getString("address1") || "");
Is the best option to use this:?
String address1 = HtmlUtil.escape(rs.getString("address1"));
if (address1 == null) address1 = "";
Using ternary operator, you can assign a value with single line of code:
String address1 = (rs.getString("address1") != null) ?
HtmlUtil.escape(rs.getString("address1")) : "";
String address1 = HtmlUtil.escape(rs.getString("address1"));
if (address1 == null || address1.equals("null")) {
address1 = "";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With