Well, hello Bill,

First Q.

I like to run all my bean property getters through an encoding function,
which you can also use to capture the "null" value.  Assuming you are doing
all your data manipulation in beans and then returning the values to JSP
through getXyz() methods called from <jsp:getProperty> tags, I do something
like:

public class ABean {
  private String aProperty = null;

  public String getAProperty( ) {
    return(JSPUtil.toHtml(this.aProperty));
  }

}

My JSPUtil class contains a lot of static methods to do various simple
JSP-related functions, including "encoding" String values so they are HTML
friendly.  For example:

  static String toHtml (String value) {
    if (value == null)
      return "";
    else
      return JSPUtil.encodeHtml(value);  // I must write this one day...
  }

I then create overloaded versions of the toHtml method for floats, ints,
booleans, other specific classes etc as needed.  They are produce a String
value, which they run through the toHtml(String) method.  This way you can
capture the "null"s and also handle HTML character entities etc in one
place.  I do a similar thing for encoding the values that will end up as
HTML tag attribute values - eg. double quotes kill them.

Second

Yes, there are archives, they can be found at http://archives.javasoft.com.
I though they were listed at the bottom of each message to this list, but it
doesn't seem to be there now.

Regards

Drew Cox

> -----Original Message-----
> From: Bill White [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, January 21, 2000 8:35 AM
> To:   [EMAIL PROTECTED]
> Subject:      null in HTML fields plus other stuff
>
> Hi folks:
>
>
>
> First:
>
> What is the best way to keep the word 'null' from appearing in the HTML
> text input fields on a form?  I'm using JSP, JDBC and JavaBeans to return
> properties and populate the values on a form.  When the value in the
> database is null, the word 'null' appears in the field.  I'm sure I can
> use an 'if' statement before each field in my script to check for a null
> value, but is there a better way to fix this?
>
>
>
> Second:
>
> I really like this forum.  It is extremely helpful since very little is
> known about JSP except by those of us who are interested enough in it to
> make it work through trial and error.  Is there some reason that this
> forum is not posted on a web site in a sort of discussion format?  It
> would be nice to be able to search all the previous discussion threads and
> it might avoid repeat questions.
>
>
>
> thanks
>
> Bill
> [EMAIL PROTECTED]
>
> ==========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST". FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to