This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Person is an abstract bean class n Employee extends it.
Now this code wudnt work. I want to know why... as far as i cud understand is as we have not mentioned the scope in useBean tag, by default it wud be page. In the servlet we have set the person attribute at request scope, so useBean wont find any attribute named person in page scope n thus give error.Am i understanding it correctly...If anyone can help???
Yes you are right. Another consideration: <jsp:setProperty> as used in this example will never be executed, also if you put your bean in page scope. It is only executed when a bean isn't in scope and you use the class or beanName attribute to create or load an istance of the bean.
Joined: Sep 08, 2005
Paolo thanx for the confirmation. But now if i have this code in my servlet wud it work......
Though you are setting attribute of the same type, the scope is different, so the useBean doesn't find the attribute. Also, only type is defined in usBean so no new object will be created. If you define the "scope" attribute to "request", you have to forward the same request from servlet code to target jsp.