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.
In a servlet code, it does -- req.setAttribute("MyObj", o); then it does a forward(req, res); to forward it to "My.jsp". Question is: in "My.jsp", are the following three totally euivalent ? 1. <% Object o = req.getAttribute("MyObj"); %> result = <%= o.getSomthing() %> 2.<jsp:useBean id="MyObj" class=".." scope="request /> result = <%= MyObj.getSomething() %> 3.<jsp:useBean id="MyObj" class=".." scope="request /> result = <jsp:getProperty name-="MyObj" property="somthing" /> Thanks, Ian
Yes the three parts of code are equivalent. ummmmm....we need to use a little caution. They will be equivalent ONLY when a object called "MyObj" already exists in the request scope. If not the first option will return null. The other two options will create a new object with a ref of MyObj and return (since the "class" atttribute of the useBean tag was used). Just clarifying.... - satya