1
1
/*
2
- * Copyright (c) 1997, 2022 Oracle and/or its affiliates and others.
2
+ * Copyright (c) 1997, 2023 Oracle and/or its affiliates and others.
3
3
* All rights reserved.
4
4
* Copyright 2004 The Apache Software Foundation
5
5
*
@@ -145,9 +145,57 @@ public interface HttpServletResponse extends ServletResponse {
145
145
public void sendError (int sc ) throws IOException ;
146
146
147
147
/**
148
- * Sends a temporary redirect response to the client using the specified redirect location URL and clears the buffer.
149
- * The buffer will be replaced with the data set by this method. Calling this method sets the status code to
148
+ * Sends a temporary redirect response to the client using the specified redirect location URL using the status code
149
+ * {@link #SC_FOUND} 302 (Found) and clears the buffer. The buffer will be replaced with the data set by this method.
150
+ *
151
+ * @param location the redirect location URL
152
+ *
153
+ * @exception IOException If an input or output exception occurs
154
+ * @exception IllegalStateException If the response was committed or if a partial URL is given and cannot be converted
155
+ * into a valid URL
156
+ *
157
+ * @see #sendRedirect(String, int, boolean)
158
+ */
159
+ public default void sendRedirect (String location ) throws IOException {
160
+ sendRedirect (location , SC_FOUND , true );
161
+ }
162
+
163
+ /**
164
+ * Sends a temporary redirect response to the client using the specified redirect location URL using the status code
150
165
* {@link #SC_FOUND} 302 (Found).
166
+ *
167
+ * @param location the redirect location URL
168
+ * @param clearBuffer if {@code true}, clear the buffer and replace it with the data set by this method otherwise retain
169
+ * the existing buffer
170
+ *
171
+ * @exception IOException If an input or output exception occurs
172
+ * @exception IllegalStateException If the response was committed or if a partial URL is given and cannot be converted
173
+ * into a valid URL
174
+ *
175
+ * @see #sendRedirect(String, int, boolean)
176
+ */
177
+ public default void sendRedirect (String location , boolean clearBuffer ) throws IOException {
178
+ sendRedirect (location , SC_FOUND , clearBuffer );
179
+ }
180
+
181
+ /**
182
+ * Sends a temporary redirect response to the client using the specified redirect location URL using the given status
183
+ * code and clears the buffer. The buffer will be replaced with the data set by this method.
184
+ *
185
+ * @param location the redirect location URL
186
+ * @param sc the status code to use for the redirect
187
+ *
188
+ * @exception IOException If an input or output exception occurs
189
+ * @exception IllegalStateException If the response was committed or if a partial URL is given and cannot be converted
190
+ * into a valid URL
191
+ *
192
+ * @see #sendRedirect(String, int, boolean)
193
+ */
194
+ public default void sendRedirect (String location , int sc ) throws IOException {
195
+ sendRedirect (location , sc , true );
196
+ }
197
+
198
+ /**
151
199
* <p>
152
200
* This method accepts both relative and absolute URLs. Absolute URLs passed to this method are used as provided as the
153
201
* redirect location URL. Relative URLs are converted to absolute URLs unless a container specific feature/option is
@@ -162,17 +210,21 @@ public interface HttpServletResponse extends ServletResponse {
162
210
* <a href="http://www.ietf.org/rfc/rfc3986.txt"> RFC 3986: Uniform Resource Identifier (URI): Generic Syntax</a>,
163
211
* section 4.2 "Relative Reference").</li>
164
212
* </ul>
165
- *
213
+ *
166
214
* <p>
167
215
* If the response has already been committed, this method throws an IllegalStateException. After using this method, the
168
216
* response should be considered to be committed and should not be written to.
169
- *
217
+ *
170
218
* @param location the redirect location URL
219
+ * @param sc the status code to use for the redirect
220
+ * @param clearBuffer if {@code true}, clear the buffer and replace it with the data set by this method otherwise retain
221
+ * the existing buffer
222
+ *
171
223
* @exception IOException If an input or output exception occurs
172
224
* @exception IllegalStateException If the response was committed or if a partial URL is given and cannot be converted
173
225
* into a valid URL
174
226
*/
175
- public void sendRedirect (String location ) throws IOException ;
227
+ public void sendRedirect (String location , int sc , boolean clearBuffer ) throws IOException ;
176
228
177
229
/**
178
230
* Sets a response header with the given name and date-value. The date is specified in terms of milliseconds since the
0 commit comments