Debian Codegraph @

api/src/main/javadoc/jakarta/servlet/jsp/package.html

raw
1 <!--
2
3 Copyright (c) 1997, 2019 Oracle and/or its affiliates. All rights reserved.
4 Copyright 2004 The Apache Software Foundation
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17
18 -->
19
20 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
21 <html>
22 <head>
23 </head>
24 <body bgcolor="white">
25 Classes and interfaces for the Core JSP 3.0 API.
26
27 <p>
28 References in this document to JSP refer to the Jakarta Server Pages
29 unless otherwise noted.
30 </p>
31
32 <p>
33 The jakarta.servlet.jsp package contains a number of classes and
34 interfaces that describe and define the contracts between a JSP page
35 implementation class and the runtime environment provided for an
36 instance of such a class by a conforming JSP container.
37 </p>
38
39 <h2>JSP Page Implementation Object Contract</h2>
40 <p>
41 This section describes the basic contract between a JSP Page
42 implementation object and its container.
43 </p>
44 <p>
45 The main contract is defined by the classes
46 {@link jakarta.servlet.jsp.JspPage}
47 and {@link jakarta.servlet.jsp.HttpJspPage}.
48 The {@link jakarta.servlet.jsp.JspFactory} class describes the mechanism to
49 portably instantiate all needed runtime objects,
50 and {@link jakarta.servlet.jsp.JspEngineInfo} provides basic information on
51 the current JSP container. Class {@link jakarta.servlet.jsp.JspApplicationContext}
52 stores application-scoped information relevant to JSP containers.
53 It was added in JSP 2.1 to support the integration of the unified
54 Expression Language.
55 </p>
56 <p>
57 None of these classes are intended to be used
58 by JSP page authors; an example of how these classes may be
59 used is included below.
60 </p>
61
62 <h2>Implicit Objects</h2>
63
64 The {@link jakarta.servlet.jsp.PageContext} object and the
65 {@link jakarta.servlet.jsp.JspWriter}
66 are available by default as implicit objects.
67
68 <h2>Exceptions</h2>
69
70 <p>
71 The {@link jakarta.servlet.jsp.JspException} class is the base class for all JSP
72 exceptions. The {@link jakarta.servlet.jsp.JspTagException} and
73 {@link jakarta.servlet.jsp.SkipPageException} exceptions are used by the
74 tag extension mechanism.</p>
75 <p>
76 For JSP error pages, the {@link jakarta.servlet.jsp.ErrorData} class encapsulates information
77 about the error.
78 </p>
79
80 <h2>An Implementation Example</h2>
81
82 <p> An instance of an implementation dependent subclass of the
83 {@link jakarta.servlet.jsp.PageContext}
84 abstract base class can be created by a JSP implementation class at
85 the beginning of it's <code>_jspService()</code> method via an
86 implementation default {@link jakarta.servlet.jsp.JspFactory}.
87
88 <p>Here is one example of how to use these classes
89
90 <pre>
91 public class foo implements Servlet {
92
93 // ...
94
95 public void _jspService(HttpServletRequest request,
96 HttpServletResponse response)
97 throws IOException, ServletException {
98
99 JspFactory factory = JspFactory.getDefaultFactory();
100 PageContext pageContext = factory.getPageContext(
101 this,
102 request,
103 response,
104 null, // errorPageURL
105 false, // needsSession
106 JspWriter.DEFAULT_BUFFER,
107 true // autoFlush
108 );
109
110 // initialize implicit variables for scripting env ...
111
112 HttpSession session = pageContext.getSession();
113 JspWriter out = pageContext.getOut();
114 Object page = this;
115
116 try {
117 // body of translated JSP here ...
118 } catch (Exception e) {
119 out.clear();
120 pageContext.handlePageException(e);
121 } finally {
122 out.close();
123 factory.releasePageContext(pageContext);
124 }
125 }
126 </pre>
127
128 </body>
129 </html>