Here are somethings I can think of:

1) The PageContext class not only encapsulates these objects, but
container specific behavior as well (handlePageException, pushBody,
etc.).  I would imagine the availability of request and response objects
here are mainly used to support these features, and not necessarily for
general accessibility.

2) Also, PageContext provides some convience methods for commonly used
tasks (include, forward, etc.)  which helped minimize the size of
scriplet block in JSPs.

3) PageContext allows a JSP engine to easily initialize a tag library
with a page's state by initializing it with one object instead of many.


Why isn't there a similar PageContext for Servlets?  Because:

1) Behavior such as exception handling (handlePageException) and output
control (pushBody, popBody) are handled by the developer of the servlet.

2) In servlets, any kind of delegation to other layers are handled by
the servlet developer, whereas delegation in JSPs are handled by the
container (JSP taglib).

3) The JSP Spec is a later spec than the Servlet spec, and benefits from
lessons learn from the earlier Serlvet spec.

Calvin


On 23 Jul 2001 17:41:06 +0530, suhas wrote:
> Hi Cyu ,
> I was going through JSPService method -when the jsp gets translated
into
> Servlet where generally we see pageContext instance obtained from the
> JSPFactory  which is actually container specific implementation .
> 
> My question was - Instead of this container only need to pass
> HttpServletRequest and HttpServletResponse objects  as parameters to
the
> _JSPservice method .  We can get the Session object from above
> HttpServletRequest that container sends as parameter . The out object
could
> have been instantiated using JSPWriter.So why was there a need to have
a
> PageContext Class when everything was possible without that  ,in JSP .
> 
> Suppose  PageContext class comes in JSP , then why the same concept
was not
> in Servlet ???
> 
> suhas
> 
> ----- Original Message -----
> From: Calvin Yu <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, July 23, 2001 5:24 PM
> Subject: Re: Basic Question in Servlet/JSP ?
> 
> 
> On 23 Jul 2001 16:29:52 +0530, suhas wrote:
> 
> > Better can't we get this from the container specific implementaion
> > something like PageContext in the Servlet too? .
> >
> 
> Why would we need to?
> 
> Calvin
> 


Reply via email to