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.
Bear Bibeault wrote:There is no "deviation from the rule".
What is being returned from the method is a PageContext instance.
Remember that it is possible to refer to an extended class by one of its ancestors. In this case, the method could return any class that extends JspContext. In this case, it's a PageContext.
but when we see the return type of getJspContext() it returns JspContext and if getJspContext() was to return pageContext instance,there would have been no need to cast the result of getJspContext() method to PageContext.
Then why do we cast it?