aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes About PageContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "About PageContext" Watch "About PageContext" New topic
Author

About PageContext

Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
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
Sumit Amar
Ranch Hand

Joined: Jun 08, 2002
Posts: 180
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.


SCJP, SCWCD, OCA, OCP-DBA 9i, <a href="http://brainbench.com/transcript.jsp?pid=2232802" target="_blank" rel="nofollow">BCIP</a>, MCP, MCAD, MCSD.NET, MCDBA, MCTS (SQL 05), MCITP (DBD, DBA)
Jignesh Malavia
Author
Ranch Hand

Joined: May 18, 2001
Posts: 81
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
Amer Khan
Ranch Hand

Joined: Apr 05, 2003
Posts: 163
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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About PageContext