1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. * Copyright (c) 1999 The Apache Software Foundation. All rights
  5. * reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. *
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. *
  19. * 3. The end-user documentation included with the redistribution, if
  20. * any, must include the following acknowlegement:
  21. * "This product includes software developed by the
  22. * Apache Software Foundation (http://www.apache.org/)."
  23. * Alternately, this acknowlegement may appear in the software itself,
  24. * if and wherever such third-party acknowlegements normally appear.
  25. *
  26. * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
  27. * Foundation" must not be used to endorse or promote products derived
  28. * from this software without prior written permission. For written
  29. * permission, please contact apache@apache.org.
  30. *
  31. * 5. Products derived from this software may not be called "Apache"
  32. * nor may "Apache" appear in their names without prior written
  33. * permission of the Apache Group.
  34. *
  35. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46. * SUCH DAMAGE.
  47. * ====================================================================
  48. *
  49. * This software consists of voluntary contributions made by many
  50. * individuals on behalf of the Apache Software Foundation. For more
  51. * information on the Apache Software Foundation, please see
  52. * <http://www.apache.org/>.
  53. *
  54. */
  55. package javax.servlet.jsp;
  56. import javax.servlet.Servlet;
  57. import javax.servlet.ServletRequest;
  58. import javax.servlet.ServletResponse;
  59. import javax.servlet.jsp.PageContext;
  60. /**
  61. * <p>
  62. * The JspFactory is an abstract class that defines a number of factory
  63. * methods available to a JSP page at runtime for the purposes of creating
  64. * instances of various interfaces and classes used to support the JSP
  65. * implementation.
  66. * <p>
  67. * A conformant JSP Engine implementation will, during it's initialization
  68. * instantiate an implementation dependent subclass of this class, and make
  69. * it globally available for use by JSP implementation classes by registering
  70. * the instance created with this class via the
  71. * static <code> setDefaultFactory() </code> method.
  72. * <p>
  73. * The PageContext and the JspEngineInfo classes are the only implementation-dependent
  74. * classes that can be created from the factory.
  75. * <p>
  76. * JspFactory objects should not be used by JSP page authors.
  77. */
  78. public abstract class JspFactory {
  79. private static JspFactory deflt = null;
  80. /**
  81. * <p>
  82. * set the default factory for this implementation. It is illegal for
  83. * any principal other than the JSP Engine runtime to call this method.
  84. * </p>
  85. *
  86. * @param default The default factory implementation
  87. */
  88. public static synchronized void setDefaultFactory(JspFactory deflt) {
  89. JspFactory.deflt = deflt;
  90. }
  91. /**
  92. * @return the default factory for this implementation
  93. */
  94. public static synchronized JspFactory getDefaultFactory() {
  95. return deflt;
  96. }
  97. /**
  98. * <p>
  99. * obtains an instance of an implementation dependent
  100. * javax.servlet.jsp.PageContext abstract class for the calling Servlet
  101. * and currently pending request and response.
  102. * </p>
  103. *
  104. * <p>
  105. * This method is typically called early in the processing of the
  106. * _jspService() method of a JSP implementation class in order to
  107. * obtain a PageContext object for the request being processed.
  108. * </p>
  109. * <p>
  110. * Invoking this method shall result in the PageContext.initialize()
  111. * method being invoked. The PageContext returned is properly initialized.
  112. * </p>
  113. * <p>
  114. * All PageContext objects obtained via this method shall be released
  115. * by invoking releasePageContext().
  116. * </p>
  117. *
  118. * @param servlet the requesting servlet
  119. * @param config the ServletConfig for the requesting Servlet
  120. * @param request the current request pending on the servlet
  121. * @param response the current response pending on the servlet
  122. * @param errorPageURL the URL of the error page for the requesting JSP, or null
  123. * @param needsSession true if the JSP participates in a session
  124. * @param buffer size of buffer in bytes, PageContext.NO_BUFFER if no buffer,
  125. * PageContext.DEFAULT_BUFFER if implementation default.
  126. * @param autoflush should the buffer autoflush to the output stream on buffer
  127. * overflow, or throw an IOException?
  128. *
  129. * @return the page context
  130. *
  131. * @see javax.servlet.jsp.PageContext
  132. */
  133. public abstract PageContext getPageContext(Servlet servlet,
  134. ServletRequest request,
  135. ServletResponse response,
  136. String errorPageURL,
  137. boolean needsSession,
  138. int buffer,
  139. boolean autoflush);
  140. /**
  141. * <p>
  142. * called to release a previously allocated PageContext object.
  143. * Results in PageContext.release() being invoked.
  144. * This method should be invoked prior to returning from the _jspService() method of a JSP implementation
  145. * class.
  146. * </p>
  147. *
  148. * @param pc A PageContext previously obtained by getPageContext()
  149. */
  150. public abstract void releasePageContext(PageContext pc);
  151. /**
  152. * <p>
  153. * called to get implementation-specific information on the current JSP engine
  154. * </p>
  155. *
  156. * @return a JspEngineInfo object describing the current JSP engine
  157. */
  158. public abstract JspEngineInfo getEngineInfo();
  159. }