Brian Slezak wrote:
>
> > >     When a JSP page updates a bean from a form, and a form field is blank,
> does
> > > it just skip calling the setXxxx method, or does it call the setXxxx method
> and
> > > pass a String with a value of ""?
> >
> > It doesn't call the setXxxx method at all if the parameter value is an empty
> > string ("blank"). This is the defined behavior per the spec.
> >
> > Hans
> > --
> > Hans Bergsten           [EMAIL PROTECTED]
> > Gefion Software         http://www.gefionsoftware.com
>
>     Ok if this is true then how has the corresponding parameter of that matching
> empty string in the form been initialized? After posting a form of course.
>
>     My thing is that after I post a form, request.getParameter() does not return
> a null value like it did BEFORE I posted the form.  This means that my Bean is
> being passed a "" String, thereby initializing the Bean property.
>
> Anyone know why this is?

Okay, let's set stage here to make sure we talk about the same thing. What
I responded to earlier was what the JSP spec says about calling bean access
methods automatically when <jsp:setProperty name="foo" property="*"> is used.
This is what I referred to, from section 2.13.2.1:

  If you set propertyName to * then the tag will iterate over the current
  ServletRequest parameters, matching parameter names and value type(s) to
  property names and setter method type(s), setting each matched property to
  the value of the matching parameter. If a parameter has a value of "", the
  corresponding property is not modified.

If you're talking about something else, such as using request.getParameter()
in a scriptlet to manually set a bean property value, then the rules are
different. If you call the bean's access method like this, the property will
of course be initialized to "". Same thing if you use a <jsp:setProperty>
action like this:

  <jsp:setProperty name="foo" property="bar"
    value="<%= request.getParameter(\"bar\") %>" />

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to