package.html :  » EJB-Server » GlassFish » servlet » javax » servlet » jsp » Java Open Source

Java Open Source » EJB Server » GlassFish 
GlassFish » servlet » javax » servlet » jsp » package.html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<!--
  - The Apache Software License, Version 1.1
  -
  - Copyright (c) 1999 The Apache Software Foundation.  All rights 
  - reserved.
  -
  - Redistribution and use in source and binary forms, with or without
  - modification, are permitted provided that the following conditions
  - are met:
  -
  - 1. Redistributions of source code must retain the above copyright
  -    notice, this list of conditions and the following disclaimer. 
  -
  - 2. Redistributions in binary form must reproduce the above copyright
  -    notice, this list of conditions and the following disclaimer in
  -    the documentation and/or other materials provided with the
  -    distribution.
  -
  - 3. The end-user documentation included with the redistribution, if
  -    any, must include the following acknowlegement:  
  -       "This product includes software developed by the 
  -        Apache Software Foundation (http://www.apache.org/)."
  -    Alternately, this acknowlegement may appear in the software itself,
  -    if and wherever such third-party acknowlegements normally appear.
  -
  - 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
  -    Foundation" must not be used to endorse or promote products derived
  -    from this software without prior written permission. For written 
  -    permission, please contact apache@apache.org.
  -
  - 5. Products derived from this software may not be called "Apache"
  -    nor may "Apache" appear in their names without prior written
  -    permission of the Apache Group.
  -
  - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - SUCH DAMAGE.
  - ====================================================================
  -
  - This software consists of voluntary contributions made by many
  - individuals on behalf of the Apache Software Foundation.  For more
  - information on the Apache Software Foundation, please see
  - <http://www.apache.org/>.
  -
  -->
</head>
<body bgcolor="white">
Classes and interfaces for the Core JSP 2.1 API.
<p>
The javax.servlet.jsp package contains a number of classes and
interfaces that describe and define the contracts between a JSP page
implementation class and the runtime environment provided for an
instance of such a class by a conforming JSP container.
</p>

<h2>JSP Page Implementation Object Contract</h2>
<p>
This section describes the basic contract between a JSP Page
implementation object and its container.
</p>
<p>
The main contract is defined by the classes 
{@link javax.servlet.jsp.JspPage}
and {@link javax.servlet.jsp.HttpJspPage}.
The {@link javax.servlet.jsp.JspFactory} class describes the mechanism to
portably instantiate all needed runtime objects,
and {@link javax.servlet.jsp.JspEngineInfo} provides basic information on
the current JSP container. Class {@link javax.servlet.jsp.JspApplicationContext}
stores application-scoped information relevant to JSP containers.
It was added in JSP 2.1 to support the integration of the unified
Expression Language.
</p>
<p>
None of these classes are intended to be used
by JSP page authors; an example of how these classes may be
used is included below.
</p>

<h2>Implicit Objects</h2>

The {@link javax.servlet.jsp.PageContext} object and the 
{@link javax.servlet.jsp.JspWriter}
are available by default as implicit objects.

<h2>Exceptions</h2>

<p>
The {@link javax.servlet.jsp.JspException} class is the base class for all JSP
exceptions.  The {@link javax.servlet.jsp.JspTagException} and 
{@link javax.servlet.jsp.SkipPageException} exceptions are used by the
tag extension mechanism.</p>
For JSP error pages, the {@link javax.servlet.jsp.ErrorData} class encapsulates information 
about the error.

</p>

<h2>An Implementation Example</h2>

<p> An instance of an implementation dependent subclass of the
{@link javax.servlet.jsp.PageContext} 
abstract base class can be created by a JSP implementation class at
the beginning of it's <code>_jspService()</code> method via an
implementation default {@link javax.servlet.jsp.JspFactory}.

<p>Here is one example of how to use these classes

<p>
<code>
<pre>
 public class foo implements Servlet {

 // ...

public void _jspService(HttpServletRequest request,
      HttpServletResponse response)
       throws IOException, ServletException {

    JspFactory  factory     = JspFactory.getDefaultFactory();
    PageContext pageContext = factory.getPageContext(
          this,
          request,
          response,
          null,  // errorPageURL
          false, // needsSession
          JspWriter.DEFAULT_BUFFER,
          true   // autoFlush
              );

    // initialize implicit variables for scripting env ...

    HttpSession session = pageContext.getSession();
    JspWriter   out     = pageContext.getOut();
    Object      page    = this;

    try {
        // body of translated JSP here ...
    } catch (Exception e) {
        out.clear();
        pageContext.handlePageException(e);
    } finally {
        out.close();
    factory.releasePageContext(pageContext);
    }
}
</pre>
</code>

</body>
</html>
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.