Hi,
We don't have any scope attribute in <jsp:setProperty> and <jsp:getProperty>. For using the scope we have declare in <jsp:useBean> tag.
when you click submit button on the html page, it will invoke TestBean.jsp.
In TestBean.jsp we are creating a object of the
java bean. If we will mention the scope there in <jsp:useBean>, it will put the created object into respective scope otherwise it will be in page scope.
So using the <jsp:getProperty> in this example has no relation with the scope.
The following two will give you the same result.
1.TestBean.jsp
<jsp:useBean id="person" type="foo.Person" class="foo.Employee" scope="request">
<jsp:setProperty name="person" property="name" param="userName" />
</jsp:useBean>
<jsp:setProperty name="person" property="name" />
2.TestBean.jsp
<jsp:useBean id="person" type="foo.Person" class="foo.Employee">
<jsp:setProperty name="person" property="name" param="userName" />
</jsp:useBean>
<jsp:setProperty name="person" property="name" />
It will not print null.
Using scope means, you are specifying where to put the bean object after creating it.
<jsp:getProperty> will look for it starting from the page scope to application scope.
Thanks
Chittaranjan