Dear all, I am reading SCWCD Exam Kit... I am confuse about PageContext. This book says that "Although the JSP specification defines these implicit objects as being in the page scope, they are not logically restricted to that scope"... Can you explain what the meaning of that and explain about an example after that sentence? thanks daniel
A JSP page may look a single page even when you statically or dynamically include other pages (components). However the dynamically included pages maintain their own "context" because their translation doesn't occur with the including page. They are merged at request time. I haven't seen that book, but it seems that statement implies this fact.
Originally posted by Fisher Daniel: Can you explain what the meaning of that and explain about an example after that sentence?
Here is an example. Suppose you have two JSP pages hello.jsp and errorHandler.jsp In hello.jsp you set the page directive attribute errorPage=errorHandler.jsp In errorHandler.jsp you set the page directive attribute isErrorPage=true When hello.jsp throws an exception, the container puts the exception object into the request object as an attribute named javax.servlet.jsp.jspException. It then forwards the request to error.jsp. When the receiving error.jsp is translated, the generated servlet accesses the exception like this Throwable exception = (Throwable)request.getAttribute("javax.servlet.jsp.jspEcxception"); Thus, even though the exception implicit object is considered to be in page scope, the implementation is such that it is actually residing in the request scope. Hope that helps, -j
Dont mix 'page' obj with 'pageContext' obj which is an instance of javax.servlet.jsp.PageContext.The pageContext provides programmatic access to all other implict objects.For implicit objects that support attributes, this obj also provides methods for accessing those attributes.in addition it implements methods for transferring control from the current page to another page ,either temporarily ,for generated output to be included in the output of the current page,or permanently to transfer control altogether.The four different implicit object capable of storing attributes are[request,session,application obj and pageContext]these object have different scopes.Page attributes stored in the pageContext abject,only last as long as the processing of a single page.Request attributes stored in pageContext may be passed between pages as control is transferred.Session attributes stored in pageContext persist as long as the session is alive.Application attributes are stored in the pageContext or retained as long as the jsp container is running. cheers Amer
<i>Dare to dream - everything that exists today,was once a figment of someone's imagination, nobody says tomorrow can't be a figment of your today.</i>