I have a bean and a jsp and I can notice was the location of the tag
<jsp:setproperty ...> is very important.
if the tag is just before the <input> , it is not correct for the
display of the value in the select box.
if the tag is before <form> (I suppose), it is OK.
So, what is the rule to know where is the correct location ?
Note: I don't use the property="*" because I produce dynamically the
input forms.

package jspsubmit;
public class Jsp3Bean {
  private String sample = "Start value";
  //Access sample property
  public String getSample() {
    return sample;
  }
  //Access sample property
  public void setSample(String newValue) {
    if (newValue!=null) {
      sample = newValue;
    }
  }
}

and a jsp also very simple

<html>
<head>
<title>
Jsp3
</title>
</head>
<jsp:useBean id="Jsp1BeanId" scope="session" class="jspsubmit.Jsp1Bean" />
<%--
HERE, the jsp:setProperty is correct
--%<
<body>
<form method="post">
<select name="sample">
<option select ><%= Jsp1BeanId.getSample() %></option>
<option>choice 1</option>
<option>choice 2</option>
</select>
<br><br>
<%--
HERE, the jsp:setProperty DOES NOR WORK CORRECTLY
--%<
<jsp:setProperty name="Jsp1BeanId" property="sample" />
<input type="submit" name="Submit" value="Submit">
<br>
Value of Bean property is :<jsp:getProperty name="Jsp1BeanId"
property="sample" />
</form>
</body>
</html>
:

--
Jean-Max Reymond
email: [EMAIL PROTECTED]
tel: 33 (0)6 16 94 25 11

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

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to