JspFactory (Java EE 5)

Java EE API


javax.servlet.jsp Class JspFactory

java.lang.Object
  extended by javax.servlet.jsp.JspFactory

public abstract class JspFactory
extends Object


JspFactory 是一个抽象类,它定义了许多在运行时可供 JSP 页面使用的工厂方法,以创建用来支持 JSP 实现的各种接口和类的实例。

在初始化期间,相应 JSP 引擎实现将实例化此类的与实现相关的子类,并通过使用静态 setDefaultFactory() 方法注册用此类创建的实例使其可供 JSP 实现类全局使用。

PageContext 和 JspEngineInfo 类是可从工厂创建的唯一与实现相关的类。

JSP 页面作者不应使用 JspFactory 对象。

英文文档:

The JspFactory is an abstract class that defines a number of factory methods available to a JSP page at runtime for the purposes of creating instances of various interfaces and classes used to support the JSP implementation.

A conformant JSP Engine implementation will, during it's initialization instantiate an implementation dependent subclass of this class, and make it globally available for use by JSP implementation classes by registering the instance created with this class via the static setDefaultFactory() method.

The only implementation-dependent classes that can be created from the factory are: PageContext, JspEngineInfo, and JspApplicationContext.

With the exception of JspApplicationContext, JspFactory objects should not be used by JSP application developers.


Constructor Summary
 
Method Summary
static JspFactory
abstract  JspEngineInfo
abstract  JspApplicationContext
abstract  PageContext
abstract  void
static void
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public JspFactory()
唯一的构造方法。(由子类构造方法调用,通常是隐式的)。
英文文档:

JspFactory

public JspFactory()
Sole constructor. (For invocation by subclass constructors, typically implicit.)

Method Detail

public static void setDefaultFactory(JspFactory deflt)

设置此实现的默认工厂。除 JSP 引擎运行时之外的任何主体调用此方法都是不合法的。

deflt 默认工厂实现
英文文档:

setDefaultFactory

public static void setDefaultFactory(JspFactory deflt)

set the default factory for this implementation. It is illegal for any principal other than the JSP Engine runtime to call this method.

Parameters:
deflt - The default factory implementation

public static JspFactory getDefaultFactory()
返回此实现的默认工厂。
return 此实现的默认工厂
英文文档:

getDefaultFactory

public static JspFactory getDefaultFactory()
Returns the default factory for this implementation.

Returns:
the default factory for this implementation

abstract public PageContext getPageContext(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int buffer, boolean autoflush)

获得调用 Servlet 和目前挂起的请求和响应的与实现相关的 javax.servlet.jsp.PageContext 抽象类的实例。

为了获得正被处理的请求的 PageContext 对象,此方法通常在 JSP 实现类的 _jspService() 方法处理的早期调用。

调用此方法将导致调用 PageContext.initialize() 方法。返回的 PageContext 被正确初始化。

通过此方法获得的所有 PageContext 对象都将通过调用 releasePageContext() 释放。

servlet 请求的 servlet
request servlet 上挂起的当前请求
response servlet 上挂起的当前响应
errorPageURL 请求 JSP 的错误页面的 URL,或者为 null
needsSession 如果 JSP 参与会话,则该参数为 true
buffer 缓冲区的大小(以字节为单位),如果没有缓冲区,则该参数为 PageContext.NO_BUFFER,如果使用实现默认值,则该参数为 PageContext.DEFAULT_BUFFER。
autoflush 缓冲区溢出时缓冲区是应该对输出流进行自动刷新,还是应该抛出 IOException?
return 页面上下文
See also javax.servlet.jsp.PageContext
英文文档:

getPageContext

public abstract PageContext getPageContext(Servlet servlet,
                                           ServletRequest request,
                                           ServletResponse response,
                                           String errorPageURL,
                                           boolean needsSession,
                                           int buffer,
                                           boolean autoflush)

obtains an instance of an implementation dependent javax.servlet.jsp.PageContext abstract class for the calling Servlet and currently pending request and response.

This method is typically called early in the processing of the _jspService() method of a JSP implementation class in order to obtain a PageContext object for the request being processed.

Invoking this method shall result in the PageContext.initialize() method being invoked. The PageContext returned is properly initialized.

All PageContext objects obtained via this method shall be released by invoking releasePageContext().

Parameters:
servlet - the requesting servlet
request - the current request pending on the servlet
response - the current response pending on the servlet
errorPageURL - the URL of the error page for the requesting JSP, or null
needsSession - true if the JSP participates in a session
buffer - size of buffer in bytes, PageContext.NO_BUFFER if no buffer, PageContext.DEFAULT_BUFFER if implementation default.
autoflush - should the buffer autoflush to the output stream on buffer overflow, or throw an IOException?
Returns:
the page context
See Also:
PageContext

abstract public void releasePageContext(PageContext pc)

调用该方法以释放以前分配的 PageContext 对象。导致调用 PageContext.release()。应该在从 JSP 实现类的 _jspService() 方法返回之前调用此方法。

pc 以前通过 getPageContext() 获得的 PageContext
英文文档:

releasePageContext

public abstract void releasePageContext(PageContext pc)

called to release a previously allocated PageContext object. Results in PageContext.release() being invoked. This method should be invoked prior to returning from the _jspService() method of a JSP implementation class.

Parameters:
pc - A PageContext previously obtained by getPageContext()

abstract public JspEngineInfo getEngineInfo()

调用该方法以获取关于当前 JSP 引擎的特定于实现的信息。

return 描述当前 JSP 引擎的 JspEngineInfo 对象
英文文档:

getEngineInfo

public abstract JspEngineInfo getEngineInfo()

called to get implementation-specific information on the current JSP engine.

Returns:
a JspEngineInfo object describing the current JSP engine

英文文档:

getJspApplicationContext

public abstract JspApplicationContext getJspApplicationContext(ServletContext context)
Obtains the JspApplicationContext instance associated with the web application for the given ServletContext.

Parameters:
context - The ServletContext for the web application the desired JspApplicationContext is associated with.
Returns:
The JspApplicationContext associated with the web application.
Since:
2.1


Submit a bug or feature

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

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

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