Hi,

Pls. see below the exert from JSP Specs.

If That Helps

Amit Ghaste
 ____________________________________________________

Omitting the extends Attribute
If the extends attribute of the language directive (see Section 2.7.1, "The
page
Directive") in a JSP page is not used, the JSP engine can generate any class
that satisfies the
contract described in TABLE 3-1 when it transforms the JSP page.
In the following code examples, CODE EXAMPLE 3-1 illustrates a generic HTTP
superclass
named ExampleHttpSuper. CODE EXAMPLE 3-2 shows a subclass named _jsp1344
that
extends ExampleHttpSuper and is the class generated from the JSP page. By
using
separate _jsp1344 and ExampleHttpSuper classes, the JSP translator needs not
discover if the JSP page includes a declaration with jspInit() or
jspDestroy(); this
simplifies very significantly the implementation.

CODE EXAMPLE 3-1 A Generic HTTP Superclass
imports javax.servlet.*;
imports javax.servlet.http.*;
imports javax.servlet.jsp.*;
/**
* An example of a superclass for an HTTP JSP class
*/
abstract class ExampleHttpSuper implements HttpJspPage {
private ServletConfig config;
final public void init(ServletConfig config) throws ServletException {
this.config = config;
jspInit();
}
final public ServletConfig getServletConfig() {
return config;
}
// This one is not final so it can be overridden by a more precise method
public String getServletInfo() {
return "A Superclass for an HTTP JSP"; // maybe better?
}
final public void destroy() throws ServletException {
jspDestroy();
}
/**
* The entry point into service.
*/
final public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
// casting exceptions will be raised if an internal error.
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
_jspService(request, resonse);
/**
* abstract method to be provided by the JSP processor in the subclass
* Must be defined in subclass.
*/
abstract public void _jspService(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException;
}

CODE EXAMPLE 3-2 The Java Class Generated From a JSP Page

imports javax.servlet.*;
imports javax.servlet.http.*;
imports javax.servlet.jsp.*;
/**
* An example of a class generated for a JSP.
*
* The name of the class is unpredictable.
* We are assuming that this is an HTTP JSP page (like almost all are)
*/
class _jsp1344 extends ExampleHttpSuper {
// Next code inserted directly via declarations.
// Any of the following pieces may or not be present
// if they are not defined here the superclass methods
// will be used.
public void jspInit() {....}
public void jspDestroy() {....}
// The next method is generated automatically by the
// JSP processor.
// body of JSP page
public void _jspService(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
// initialization of the implicit variables
HttpSession session = request.getSession();
ServletContext context =
getServletConfig().getServletContext();
// for this example, we assume a buffered directive
JSPBufferedWriter out = new
JSPBufferedWriter(response.getWriter());
// next is code from scriptlets, expressions, and static text.
}
}



Using the extends Attribute
If the JSP author uses extends, the generated class is identical to the one
shown in
CODE EXAMPLE 3-2, except that the class name is the one specified in the
extends attribute.
The contract on the JSP Page implementation class does not change. The JSP
engine should
check (usually through reflection) that the provided superclass:
* Implements HttpJspPage if the protocol is HTTP, or JspPage otherwise.
* All of the methods in the Servlet interface are declared final.
Additionally, it is the responsibility of the JSP author that the provided
superclass satisfies:
* The service() method of the Servlet API invokes the _jspService() method.
* The init(ServletConfig) method stores the configuration, makes it
available as
getServletConfig, then invokes jspInit.
* The destroy method invokes jspDestroy.
A JSP Engine may give a fatal translation error if it detects that the
provided superclass does
not satisfy these requirements, but most JSP Engines will not check them.




The page Directive
The page directive defines a number of page dependent attributes and
communicates these
to the JSP engine.
A translation unit (JSP source file and any files included via the include
directive) can
contain more than one instance of the page directive, all the attributes
will apply to the
complete translation unit (i.e. page directives are position independent).
However, there shall
be only one occurrence of any attribute/value defined by this directive in a
given translation
unit with the exception of the "import" attribute; multiple uses of this
attribute are
cumulative (with ordered set union semantics). Other such multiple
attribute/value
(re)definitions result in a fatal translation error.
The attribute/value namespace is reserved for use by this, and subsequent,
JSP
specification(s).
Unrecognized attributes or values result in fatal translation errors.

Examples
The following directive provides some user-visible information on this JSP
page:
<%@ page info="my latest JSP Example V1.1" %>
The following directive requests no buffering, indicates that the page is
thread safe, and
provides an error page.
<%@ page buffer="none" isThreadSafe="yes" errorPage="/oops.jsp" %>
The following directive indicates that the scripting language is based on
Java, that the types
declared in the package com.myco are directly available to the scripting
code, and that a
buffering of 16K should be used.
<%@ page language="java" import="com.myco.*" buffer="16k" %>
2.7.1.1 Syntax
<%@ page page_directive_attr_list %>
page_directive_attr_list ::= { language=" scriptingLanguage"}
{ extends=" className"}
{ import=" importList"}
{ session="true|false" }
{ buffer="none| sizekb" }
{ autoFlush="true| false" }
{ isThreadSafe="true|false" }
{ info=" info_text" }
{ errorPage=" error_url" }
{ isErrorPage="true|false" }
{ contentType="ctinfo" }


ITH

Amit
> -----Original Message-----
> From: Tom Santos [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, January 03, 2000 7:05 AM
> To:   [EMAIL PROTECTED]
> Subject:      Extends tag
>
> I was reading a JSP file, and at the top, there was a statement like:
>
> <%@ extends="com.someone.somewhere" %>
>
> It looks like that is used to subclass from a servlet.  Does anyone know
> where this tag is defined?  I can't find it in the docs.
>
> -Tom-
>
> ==========================================================================
> =
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> FAQs on JSP can be found at:
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to