Source Code Cross Referenced for HttpServletResponse.java in  » 6.0-JDK-Core » Servlet-API-by-tomcat » javax » servlet » http » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Servlet API by tomcat » javax.servlet.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2004 The Apache Software Foundation
003         *
004         * Licensed under the Apache License, Version 2.0 (the "License");
005         * you may not use this file except in compliance with the License.
006         * You may obtain a copy of the License at
007         *
008         *     http://www.apache.org/licenses/LICENSE-2.0
009         *
010         * Unless required by applicable law or agreed to in writing, software
011         * distributed under the License is distributed on an "AS IS" BASIS,
012         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013         * See the License for the specific language governing permissions and
014         * limitations under the License.
015         */
016        package javax.servlet.http;
017
018        import java.io.IOException;
019
020        import javax.servlet.ServletResponse;
021
022        /**
023         *
024         * Extends the {@link ServletResponse} interface to provide HTTP-specific
025         * functionality in sending a response.  For example, it has methods
026         * to access HTTP headers and cookies.
027         *
028         * <p>The servlet container creates an <code>HttpServletResponse</code> object
029         * and passes it as an argument to the servlet's service methods
030         * (<code>doGet</code>, <code>doPost</code>, etc).
031         *
032         * 
033         * @author	Various
034         * @version	$Version$
035         *
036         * @see		javax.servlet.ServletResponse
037         *
038         */
039
040        public interface HttpServletResponse extends ServletResponse {
041
042            /**
043             * Adds the specified cookie to the response.  This method can be called
044             * multiple times to set more than one cookie.
045             *
046             * @param cookie the Cookie to return to the client
047             *
048             */
049
050            public void addCookie(Cookie cookie);
051
052            /**
053             * Returns a boolean indicating whether the named response header 
054             * has already been set.
055             * 
056             * @param	name	the header name
057             * @return		<code>true</code> if the named response header 
058             *			has already been set; 
059             * 			<code>false</code> otherwise
060             */
061
062            public boolean containsHeader(String name);
063
064            /**
065             * Encodes the specified URL by including the session ID in it,
066             * or, if encoding is not needed, returns the URL unchanged.
067             * The implementation of this method includes the logic to
068             * determine whether the session ID needs to be encoded in the URL.
069             * For example, if the browser supports cookies, or session
070             * tracking is turned off, URL encoding is unnecessary.
071             * 
072             * <p>For robust session tracking, all URLs emitted by a servlet 
073             * should be run through this
074             * method.  Otherwise, URL rewriting cannot be used with browsers
075             * which do not support cookies.
076             *
077             * @param	url	the url to be encoded.
078             * @return		the encoded URL if encoding is needed;
079             * 			the unchanged URL otherwise.
080             */
081
082            public String encodeURL(String url);
083
084            /**
085             * Encodes the specified URL for use in the
086             * <code>sendRedirect</code> method or, if encoding is not needed,
087             * returns the URL unchanged.  The implementation of this method
088             * includes the logic to determine whether the session ID
089             * needs to be encoded in the URL.  Because the rules for making
090             * this determination can differ from those used to decide whether to
091             * encode a normal link, this method is separated from the
092             * <code>encodeURL</code> method.
093             * 
094             * <p>All URLs sent to the <code>HttpServletResponse.sendRedirect</code>
095             * method should be run through this method.  Otherwise, URL
096             * rewriting cannot be used with browsers which do not support
097             * cookies.
098             *
099             * @param	url	the url to be encoded.
100             * @return		the encoded URL if encoding is needed;
101             * 			the unchanged URL otherwise.
102             *
103             * @see #sendRedirect
104             * @see #encodeUrl
105             */
106
107            public String encodeRedirectURL(String url);
108
109            /**
110             * @deprecated	As of version 2.1, use encodeURL(String url) instead
111             *
112             * @param	url	the url to be encoded.
113             * @return		the encoded URL if encoding is needed; 
114             * 			the unchanged URL otherwise.
115             */
116
117            public String encodeUrl(String url);
118
119            /**
120             * @deprecated	As of version 2.1, use 
121             *			encodeRedirectURL(String url) instead
122             *
123             * @param	url	the url to be encoded.
124             * @return		the encoded URL if encoding is needed; 
125             * 			the unchanged URL otherwise.
126             */
127
128            public String encodeRedirectUrl(String url);
129
130            /**
131             * Sends an error response to the client using the specified
132             * status.  The server defaults to creating the
133             * response to look like an HTML-formatted server error page
134             * containing the specified message, setting the content type
135             * to "text/html", leaving cookies and other headers unmodified.
136             *
137             * If an error-page declaration has been made for the web application
138             * corresponding to the status code passed in, it will be served back in 
139             * preference to the suggested msg parameter. 
140             *
141             * <p>If the response has already been committed, this method throws 
142             * an IllegalStateException.
143             * After using this method, the response should be considered
144             * to be committed and should not be written to.
145             *
146             * @param	sc	the error status code
147             * @param	msg	the descriptive message
148             * @exception	IOException	If an input or output exception occurs
149             * @exception	IllegalStateException	If the response was committed
150             */
151
152            public void sendError(int sc, String msg) throws IOException;
153
154            /**
155             * Sends an error response to the client using the specified status
156             * code and clearing the buffer. 
157             * <p>If the response has already been committed, this method throws 
158             * an IllegalStateException.
159             * After using this method, the response should be considered
160             * to be committed and should not be written to.
161             *
162             * @param	sc	the error status code
163             * @exception	IOException	If an input or output exception occurs
164             * @exception	IllegalStateException	If the response was committed
165             *						before this method call
166             */
167
168            public void sendError(int sc) throws IOException;
169
170            /**
171             * Sends a temporary redirect response to the client using the
172             * specified redirect location URL.  This method can accept relative URLs;
173             * the servlet container must convert the relative URL to an absolute URL
174             * before sending the response to the client. If the location is relative 
175             * without a leading '/' the container interprets it as relative to
176             * the current request URI. If the location is relative with a leading
177             * '/' the container interprets it as relative to the servlet container root.
178             *
179             * <p>If the response has already been committed, this method throws 
180             * an IllegalStateException.
181             * After using this method, the response should be considered
182             * to be committed and should not be written to.
183             *
184             * @param		location	the redirect location URL
185             * @exception	IOException	If an input or output exception occurs
186             * @exception	IllegalStateException	If the response was committed or
187            if a partial URL is given and cannot be converted into a valid URL
188             */
189
190            public void sendRedirect(String location) throws IOException;
191
192            /**
193             * 
194             * Sets a response header with the given name and
195             * date-value.  The date is specified in terms of
196             * milliseconds since the epoch.  If the header had already
197             * been set, the new value overwrites the previous one.  The
198             * <code>containsHeader</code> method can be used to test for the
199             * presence of a header before setting its value.
200             * 
201             * @param	name	the name of the header to set
202             * @param	date	the assigned date value
203             * 
204             * @see #containsHeader
205             * @see #addDateHeader
206             */
207
208            public void setDateHeader(String name, long date);
209
210            /**
211             * 
212             * Adds a response header with the given name and
213             * date-value.  The date is specified in terms of
214             * milliseconds since the epoch.  This method allows response headers 
215             * to have multiple values.
216             * 
217             * @param	name	the name of the header to set
218             * @param	date	the additional date value
219             * 
220             * @see #setDateHeader
221             */
222
223            public void addDateHeader(String name, long date);
224
225            /**
226             *
227             * Sets a response header with the given name and value.
228             * If the header had already been set, the new value overwrites the
229             * previous one.  The <code>containsHeader</code> method can be
230             * used to test for the presence of a header before setting its
231             * value.
232             * 
233             * @param	name	the name of the header
234             * @param	value	the header value  If it contains octet string,
235             *		it should be encoded according to RFC 2047
236             *		(http://www.ietf.org/rfc/rfc2047.txt)
237             *
238             * @see #containsHeader
239             * @see #addHeader
240             */
241
242            public void setHeader(String name, String value);
243
244            /**
245             * Adds a response header with the given name and value.
246             * This method allows response headers to have multiple values.
247             * 
248             * @param	name	the name of the header
249             * @param	value	the additional header value   If it contains
250             *		octet string, it should be encoded
251             *		according to RFC 2047
252             *		(http://www.ietf.org/rfc/rfc2047.txt)
253             *
254             * @see #setHeader
255             */
256
257            public void addHeader(String name, String value);
258
259            /**
260             * Sets a response header with the given name and
261             * integer value.  If the header had already been set, the new value
262             * overwrites the previous one.  The <code>containsHeader</code>
263             * method can be used to test for the presence of a header before
264             * setting its value.
265             *
266             * @param	name	the name of the header
267             * @param	value	the assigned integer value
268             *
269             * @see #containsHeader
270             * @see #addIntHeader
271             */
272
273            public void setIntHeader(String name, int value);
274
275            /**
276             * Adds a response header with the given name and
277             * integer value.  This method allows response headers to have multiple
278             * values.
279             *
280             * @param	name	the name of the header
281             * @param	value	the assigned integer value
282             *
283             * @see #setIntHeader
284             */
285
286            public void addIntHeader(String name, int value);
287
288            /**
289             * Sets the status code for this response.  This method is used to
290             * set the return status code when there is no error (for example,
291             * for the status codes SC_OK or SC_MOVED_TEMPORARILY).  If there
292             * is an error, and the caller wishes to invoke an error-page defined
293             * in the web application, the <code>sendError</code> method should be used
294             * instead.
295             * <p> The container clears the buffer and sets the Location header, preserving
296             * cookies and other headers.
297             *
298             * @param	sc	the status code
299             *
300             * @see #sendError
301             */
302
303            public void setStatus(int sc);
304
305            /**
306             * @deprecated As of version 2.1, due to ambiguous meaning of the 
307             * message parameter. To set a status code 
308             * use <code>setStatus(int)</code>, to send an error with a description
309             * use <code>sendError(int, String)</code>.
310             *
311             * Sets the status code and message for this response.
312             * 
313             * @param	sc	the status code
314             * @param	sm	the status message
315             */
316
317            public void setStatus(int sc, String sm);
318
319            /*
320             * Server status codes; see RFC 2068.
321             */
322
323            /**
324             * Status code (100) indicating the client can continue.
325             */
326
327            public static final int SC_CONTINUE = 100;
328
329            /**
330             * Status code (101) indicating the server is switching protocols
331             * according to Upgrade header.
332             */
333
334            public static final int SC_SWITCHING_PROTOCOLS = 101;
335
336            /**
337             * Status code (200) indicating the request succeeded normally.
338             */
339
340            public static final int SC_OK = 200;
341
342            /**
343             * Status code (201) indicating the request succeeded and created
344             * a new resource on the server.
345             */
346
347            public static final int SC_CREATED = 201;
348
349            /**
350             * Status code (202) indicating that a request was accepted for
351             * processing, but was not completed.
352             */
353
354            public static final int SC_ACCEPTED = 202;
355
356            /**
357             * Status code (203) indicating that the meta information presented
358             * by the client did not originate from the server.
359             */
360
361            public static final int SC_NON_AUTHORITATIVE_INFORMATION = 203;
362
363            /**
364             * Status code (204) indicating that the request succeeded but that
365             * there was no new information to return.
366             */
367
368            public static final int SC_NO_CONTENT = 204;
369
370            /**
371             * Status code (205) indicating that the agent <em>SHOULD</em> reset
372             * the document view which caused the request to be sent.
373             */
374
375            public static final int SC_RESET_CONTENT = 205;
376
377            /**
378             * Status code (206) indicating that the server has fulfilled
379             * the partial GET request for the resource.
380             */
381
382            public static final int SC_PARTIAL_CONTENT = 206;
383
384            /**
385             * Status code (300) indicating that the requested resource
386             * corresponds to any one of a set of representations, each with
387             * its own specific location.
388             */
389
390            public static final int SC_MULTIPLE_CHOICES = 300;
391
392            /**
393             * Status code (301) indicating that the resource has permanently
394             * moved to a new location, and that future references should use a
395             * new URI with their requests.
396             */
397
398            public static final int SC_MOVED_PERMANENTLY = 301;
399
400            /**
401             * Status code (302) indicating that the resource has temporarily
402             * moved to another location, but that future references should
403             * still use the original URI to access the resource.
404             *
405             * This definition is being retained for backwards compatibility.
406             * SC_FOUND is now the preferred definition.
407             */
408
409            public static final int SC_MOVED_TEMPORARILY = 302;
410
411            /**
412             * Status code (302) indicating that the resource reside
413             * temporarily under a different URI. Since the redirection might
414             * be altered on occasion, the client should continue to use the
415             * Request-URI for future requests.(HTTP/1.1) To represent the
416             * status code (302), it is recommended to use this variable.
417             */
418
419            public static final int SC_FOUND = 302;
420
421            /**
422             * Status code (303) indicating that the response to the request
423             * can be found under a different URI.
424             */
425
426            public static final int SC_SEE_OTHER = 303;
427
428            /**
429             * Status code (304) indicating that a conditional GET operation
430             * found that the resource was available and not modified.
431             */
432
433            public static final int SC_NOT_MODIFIED = 304;
434
435            /**
436             * Status code (305) indicating that the requested resource
437             * <em>MUST</em> be accessed through the proxy given by the
438             * <code><em>Location</em></code> field.
439             */
440
441            public static final int SC_USE_PROXY = 305;
442
443            /**
444             * Status code (307) indicating that the requested resource 
445             * resides temporarily under a different URI. The temporary URI
446             * <em>SHOULD</em> be given by the <code><em>Location</em></code> 
447             * field in the response.
448             */
449
450            public static final int SC_TEMPORARY_REDIRECT = 307;
451
452            /**
453             * Status code (400) indicating the request sent by the client was
454             * syntactically incorrect.
455             */
456
457            public static final int SC_BAD_REQUEST = 400;
458
459            /**
460             * Status code (401) indicating that the request requires HTTP
461             * authentication.
462             */
463
464            public static final int SC_UNAUTHORIZED = 401;
465
466            /**
467             * Status code (402) reserved for future use.
468             */
469
470            public static final int SC_PAYMENT_REQUIRED = 402;
471
472            /**
473             * Status code (403) indicating the server understood the request
474             * but refused to fulfill it.
475             */
476
477            public static final int SC_FORBIDDEN = 403;
478
479            /**
480             * Status code (404) indicating that the requested resource is not
481             * available.
482             */
483
484            public static final int SC_NOT_FOUND = 404;
485
486            /**
487             * Status code (405) indicating that the method specified in the
488             * <code><em>Request-Line</em></code> is not allowed for the resource
489             * identified by the <code><em>Request-URI</em></code>.
490             */
491
492            public static final int SC_METHOD_NOT_ALLOWED = 405;
493
494            /**
495             * Status code (406) indicating that the resource identified by the
496             * request is only capable of generating response entities which have
497             * content characteristics not acceptable according to the accept
498             * headers sent in the request.
499             */
500
501            public static final int SC_NOT_ACCEPTABLE = 406;
502
503            /**
504             * Status code (407) indicating that the client <em>MUST</em> first
505             * authenticate itself with the proxy.
506             */
507
508            public static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
509
510            /**
511             * Status code (408) indicating that the client did not produce a
512             * request within the time that the server was prepared to wait.
513             */
514
515            public static final int SC_REQUEST_TIMEOUT = 408;
516
517            /**
518             * Status code (409) indicating that the request could not be
519             * completed due to a conflict with the current state of the
520             * resource.
521             */
522
523            public static final int SC_CONFLICT = 409;
524
525            /**
526             * Status code (410) indicating that the resource is no longer
527             * available at the server and no forwarding address is known.
528             * This condition <em>SHOULD</em> be considered permanent.
529             */
530
531            public static final int SC_GONE = 410;
532
533            /**
534             * Status code (411) indicating that the request cannot be handled
535             * without a defined <code><em>Content-Length</em></code>.
536             */
537
538            public static final int SC_LENGTH_REQUIRED = 411;
539
540            /**
541             * Status code (412) indicating that the precondition given in one
542             * or more of the request-header fields evaluated to false when it
543             * was tested on the server.
544             */
545
546            public static final int SC_PRECONDITION_FAILED = 412;
547
548            /**
549             * Status code (413) indicating that the server is refusing to process
550             * the request because the request entity is larger than the server is
551             * willing or able to process.
552             */
553
554            public static final int SC_REQUEST_ENTITY_TOO_LARGE = 413;
555
556            /**
557             * Status code (414) indicating that the server is refusing to service
558             * the request because the <code><em>Request-URI</em></code> is longer
559             * than the server is willing to interpret.
560             */
561
562            public static final int SC_REQUEST_URI_TOO_LONG = 414;
563
564            /**
565             * Status code (415) indicating that the server is refusing to service
566             * the request because the entity of the request is in a format not
567             * supported by the requested resource for the requested method.
568             */
569
570            public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415;
571
572            /**
573             * Status code (416) indicating that the server cannot serve the
574             * requested byte range.
575             */
576
577            public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
578
579            /**
580             * Status code (417) indicating that the server could not meet the
581             * expectation given in the Expect request header.
582             */
583
584            public static final int SC_EXPECTATION_FAILED = 417;
585
586            /**
587             * Status code (500) indicating an error inside the HTTP server
588             * which prevented it from fulfilling the request.
589             */
590
591            public static final int SC_INTERNAL_SERVER_ERROR = 500;
592
593            /**
594             * Status code (501) indicating the HTTP server does not support
595             * the functionality needed to fulfill the request.
596             */
597
598            public static final int SC_NOT_IMPLEMENTED = 501;
599
600            /**
601             * Status code (502) indicating that the HTTP server received an
602             * invalid response from a server it consulted when acting as a
603             * proxy or gateway.
604             */
605
606            public static final int SC_BAD_GATEWAY = 502;
607
608            /**
609             * Status code (503) indicating that the HTTP server is
610             * temporarily overloaded, and unable to handle the request.
611             */
612
613            public static final int SC_SERVICE_UNAVAILABLE = 503;
614
615            /**
616             * Status code (504) indicating that the server did not receive
617             * a timely response from the upstream server while acting as
618             * a gateway or proxy.
619             */
620
621            public static final int SC_GATEWAY_TIMEOUT = 504;
622
623            /**
624             * Status code (505) indicating that the server does not support
625             * or refuses to support the HTTP protocol version that was used
626             * in the request message.
627             */
628
629            public static final int SC_HTTP_VERSION_NOT_SUPPORTED = 505;
630        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.