-
Notifications
You must be signed in to change notification settings - Fork 78
/
HttpServletMapping.java
164 lines (157 loc) · 4.72 KB
/
HttpServletMapping.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
* Copyright (c) 2017, 2023 Oracle and/or its affiliates and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package jakarta.servlet.http;
/**
* <p>
* Allows runtime discovery of the manner in which the {@link HttpServlet} for the current {@link HttpServletRequest}
* was invoked. Invoking any of the methods must not block the caller. The implementation must be thread safe. Instances
* are immutable and are returned from {@link HttpServletRequest#getHttpServletMapping}.
* </p>
*
* <p>
* Following are some illustrative examples for various combinations of mappings. Consider the following Servlet
* declaration:
* </p>
*
* <pre>
* <code>
* <servlet>
* <servlet-name>MyServlet</servlet-name>
* <servlet-class>MyServlet</servlet-class>
* </servlet>
* <servlet-mapping>
* <servlet-name>MyServlet</servlet-name>
* <url-pattern>/MyServlet</url-pattern>
* <url-pattern>""</url-pattern>
* <url-pattern>*.extension</url-pattern>
* <url-pattern>/path/*</url-pattern>
* </servlet-mapping>
* </code>
* </pre>
*
* <p>
* The expected values of the properties for various incoming URI path values are as shown in this table. The
* {@code servletName} column is omitted as its value is always {@code MyServlet}.
* </p>
*
* <table border="1">
* <caption>Expected values of properties for various URI paths</caption>
* <tr>
* <th>URI Path (in quotes)</th>
* <th>matchValue</th>
* <th>pattern</th>
* <th>mappingMatch</th>
* </tr>
* <tr>
* <td>""</td>
* <td>""</td>
* <td>""</td>
* <td>CONTEXT_ROOT</td>
* </tr>
* <tr>
* <td>"/index.html"</td>
* <td>""</td>
* <td>/</td>
* <td>DEFAULT</td>
* </tr>
* <tr>
* <td>"MyServlet/index.html"</td>
* <td>""</td>
* <td>/</td>
* <td>DEFAULT</td>
* </tr>
* <tr>
* <td>"/MyServlet"</td>
* <td>MyServlet</td>
* <td>/MyServlet</td>
* <td>EXACT</td>
* </tr>
* <tr>
* <td>"MyServlet/foo"</td>
* <td>""</td>
* <td>/</td>
* <td>DEFAULT</td>
* </tr>
* <tr>
* <td>"/foo.extension"</td>
* <td>foo</td>
* <td>*.extension</td>
* <td>EXTENSION</td>
* </tr>
* <tr>
* <td>"/bar/foo.extension"</td>
* <td>bar/foo</td>
* <td>*.extension</td>
* <td>EXTENSION</td>
* </tr>
* <tr>
* <td>"/path/foo"</td>
* <td>foo</td>
* <td>/path/*</td>
* <td>PATH</td>
* </tr>
* <tr>
* <td>"/path/foo/bar"</td>
* <td>foo/bar</td>
* <td>/path/*</td>
* <td>PATH</td>
* </tr>
*
* </table>
*
* @since Servlet 4.0
*/
public interface HttpServletMapping {
/**
* <p>
* Return the portion of the URI path that caused this request to be matched. If the {@link #getMappingMatch} value is
* {@code CONTEXT_ROOT} or {@code DEFAULT}, this method must return the empty string. If the {@link #getMappingMatch}
* value is {@code EXACT}, this method must return the portion of the path that matched the servlet, omitting any
* leading slash. If the {@link #getMappingMatch} value is {@code EXTENSION} or {@code PATH}, this method must return
* the value that matched the '*' excluding any leading '/'. See the class javadoc for examples.
* </p>
*
* @return the match.
*/
String getMatchValue();
/**
* <p>
* Return the String representation for the {@code url-pattern} for this mapping. This method returns the pattern
* exactly as specified in the descriptor or Java configuration.
* </p>
*
* @return the String representation for the {@code url-pattern} for this mapping.
*/
String getPattern();
/**
* <p>
* Return the String representation for the {@code servlet-name} for this mapping. If the Servlet providing the response
* is the default servlet, the return from this method is the name of the default servlet, which is container specific.
* </p>
*
* @return the String representation for the {@code servlet-name} for this mapping.
*/
String getServletName();
/**
* <p>
* Return the {@link MappingMatch} for this instance.
* </p>
*
* @return the {@code MappingMatch} for this instance.
*/
MappingMatch getMappingMatch();
}