Hello everybody 🙂
I have misunderstanging in setPropety in using Bean ?
when I make like this
<jsp:setProperty name="myBean" property="*">
I have to make the field names of the form the same as attribute names in myBean
in order to make match between values is HTTPRequest and the attributes of myBean,
if I use onther names in the form fields, values are reached null values.
but If I ever want to use the form values in the same jsp page , and define Bean that holds the values of the form, it doesn’t make sence if I use other names in the form fields rather than the same name of bean attributes !! why is that ??
see here, the name of password field is “password” , and the name of attribute of myBean is pass, and even that it works !
//index.jsp page
<form method="post" action="index.jsp">
Enter Your email:<input type="text" name="email"/>
<br/>
Enter Your Password :<input type="password" name ="pass">
<br/>
<input type="submit" name ="submit"/>
</form>
<jsp:useBean id="info" class="beans.info" scope="page">
<jsp:setProperty name="info" property="*"/>
</jsp:useBean>
Your email is : <jsp:getProperty name="info" property="email"/>
<br/>
Your Pass is : <jsp:getProperty name="info" property="pass"/>
</body>
can some one tell me what has happened?
Edit: I make modification to the code.
The name of your password field is also
pass.Other cause could be that you aren’t running the code you think you’re running. Note that the bean name
infoois wrong.