Hi, fist.jsp while defining the useBean you have mentioned the scope as session. So the attribute is set at the scope level.
If you could have opted the same thing (i.e) by mentioning the scope as session then you would have got the result as "SecondValue" since you have not done that the second bean have taken the default as "Page" scope and the call for include action is made dynamic you can't see the "secondValue" instead you see "FirstValue".
Even i'm a beginner let me know if anything is wrong.
i applied different scope values to second.jsp and these are the results:
<jsp:useBean id="myBean" class="bean.MyBean" scope="page"/> return me "FirstValue"
<jsp:useBean id="myBean" class="bean.MyBean" scope="session"/> <jsp:useBean id="myBean" class="bean.MyBean" scope="request"/> <jsp:useBean id="myBean" class="bean.MyBean" scope="application"/> all return me "SecondValue"
so it seems that if use a scope lesser than the calling page's bean scope, then all changes made in second.jsp are lost when it returned back to first.jsp?
The puzzling thing to me is why is changes to the bean property lost? Is'nt both jsp pages working only on 1 bean.MyBean object?
But I feel it should return secondvalue only if the scope of bean in second jsp is session otherwise it should return firstvalue as that's the value of myBean set in session.Please share your thoughts on this?
<jsp:useBean id="myBean" class="bean.MyBean" scope="page"/> return me "FirstValue"
in the background it creates a pageContext object i.e. jsp pagecontext when we call <jsp:getProperty > it uses findAttribute() method to get the value.It first looks in page , request,session the application in that order
SCJP 95%<br />SCWCD(waiting for the big)
please buy this thing and then I get a fat cut of the action:
Gift giving made easy with the permaculture playing cards