i have jsp page which contains
<jsp:useBean id="RcvMsgTransferTanseekBean" class= "com.test.RcvMsgTransferTanseekBean" />
<jsp:setProperty name="RcvMsgTransferTanseekBean" property="*" />
and bean which contain
private String nId = "";
public void setNId (String value){
this.nId = value;
}
public String getNId(){
return this.nId;
}
i send request to that jsp page
test.jsp?letId=479438&dstId=522375&nId=138393&subject=66666666666&letForInfo=1&shNotMan=true
my problem is that the nId parameter only is still empty.
when i added new line in the jsp
<jsp:setProperty name="RcvMsgTransferTanseekBean" property="nId" />
it works fine, why the 'property="*"' didn't work as the supposed to be ?
The issue is in the name of the property.
The Capitalization and Decapitalization of the CamelCase don't work as you expect for single leading letter. For Setting the value of the property the setter method are used.
And the setter for
nId
issetNId
.The Java Bean Spacification say:
In the Documentation for Introspector:
So in order to find match between parameter and setter:
setNId
, we getNId
.NId
, the value goes in the javaBean,nId
, there is no matching setter found.The Solution: Avoid such cases:
Use more than one small letter at the begin of property names.
In this particular case, instead of
nId
you can usenumId
.OR Change the setter/getter names to
setnId()
andgetnId()
Unexpected behavior by usage of Bean with such property and getter/setter names
<jsp:setProperty name="RcvMsgTransferTanseekBean" property="*" />
just skips the property
nId
. No Error. No Exception.<jsp:setProperty name="RcvMsgTransferTanseekBean" property="nId"/>
throws org.apache.jasper.JasperException: PWC6054: Cannot find any information on property 'nId' in a bean of type 'com.test.RcvMsgTransferTanseekBean'
${RcvMsgTransferTanseekBean.nId}
throws org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: The class 'com.test.RcvMsgTransferTanseekBean' does not have the property 'nId'.