JspPage (Java EE 5)

Java EE API


javax.servlet.jsp Interface JspPage

All Superinterfaces:
Servlet
All Known Subinterfaces:
HttpJspPage

public interface JspPage
extends Servlet

Implements: Servlet
Implemented by: HttpJspPage

JspPage 接口描述 JSP 页面实现类必须满足的一般交互;使用 HTTP 协议的页面是通过 HttpJspPage 接口描述的。

两个方法加一个方法

该接口定义了一个具有 3 个方法的协议;其中只有两个方法:jspInit() 和 jspDestroy() 是此接口的一部分,因为第三个方法:_jspService() 的签名取决于使用的特定协议,并且无法使用 Java 中的一般方式表示。

实现此接口的类负责根据相应的基于 Servlet 的方法调用在适当时间调用上述方法。

jspInit() 和 jspDestroy() 方法可由 JSP 作者定义,但 _jspService() 方法是 JSP 处理器根据 JSP 页面内容自动定义的。

_jspService()

_jspService() 方法对应于 JSP 页面的正文。此方法由 JSP 容器自动定义,不得由 JSP 页面作者定义。

如果使用扩展属性指定了超类,则该超类可以选择在调用 _jspService() 方法之前(或之后)在其 service() 方法中执行某些操作。请参见 JSP 规范 JSP_Engine 章节中有关使用扩展属性的内容。

特定签名取决于 JSP 页面支持的协议。

public void _jspService(ServletRequestSubtype request,
ServletResponseSubtype response)
throws ServletException, IOException;
 
英文文档:

The JspPage interface describes the generic interaction that a JSP Page Implementation class must satisfy; pages that use the HTTP protocol are described by the HttpJspPage interface.

Two plus One Methods

The interface defines a protocol with 3 methods; only two of them: jspInit() and jspDestroy() are part of this interface as the signature of the third method: _jspService() depends on the specific protocol used and cannot be expressed in a generic way in Java.

A class implementing this interface is responsible for invoking the above methods at the appropriate time based on the corresponding Servlet-based method invocations.

The jspInit() and jspDestroy() methods can be defined by a JSP author, but the _jspService() method is defined automatically by the JSP processor based on the contents of the JSP page.

_jspService()

The _jspService()method corresponds to the body of the JSP page. This method is defined automatically by the JSP container and should never be defined by the JSP page author.

If a superclass is specified using the extends attribute, that superclass may choose to perform some actions in its service() method before or after calling the _jspService() method. See using the extends attribute in the JSP_Engine chapter of the JSP specification.

The specific signature depends on the protocol supported by the JSP page.

 public void _jspService(ServletRequestSubtype request,
                             ServletResponseSubtype response)
        throws ServletException, IOException;
 


Method Summary
 void
 void
 
Methods inherited from interface javax.servlet.Servlet
 

Method Detail

public void jspInit()
jspInit() 方法在初始化 JSP 页面时调用。此时调用 getServletConfig() 方法将返回所需的值,这由 JSP 实现(以及扩展属性提到的类,如果存在的话)负责。 JSP 页面可以通过在声明元素中包含该方法的定义重写此方法。 JSP 页面将重新定义来自 Servlet 的 init() 方法。
英文文档:

jspInit

void jspInit()
The jspInit() method is invoked when the JSP page is initialized. It is the responsibility of the JSP implementation (and of the class mentioned by the extends attribute, if present) that at this point invocations to the getServletConfig() method will return the desired value. A JSP page can override this method by including a definition for it in a declaration element. A JSP page should redefine the init() method from Servlet.


public void jspDestroy()
jspDestroy() 方法在 JSP 页面即将被销毁时调用。 JSP 页面可以通过在声明元素中包含该方法的定义重写此方法。 JSP 页面将重新定义来自 Servlet 的 destroy() 方法。
英文文档:

jspDestroy

void jspDestroy()
The jspDestroy() method is invoked when the JSP page is about to be destroyed. A JSP page can override this method by including a definition for it in a declaration element. A JSP page should redefine the destroy() method from Servlet.



Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!