Source Code Cross Referenced for HttpServletResponse.java in  » Sevlet-Container » apache-tomcat-6.0.14 » javax » servlet » http » Java Source Code / Java DocumentationJava Source Code and Java Documentation

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 geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Sevlet Container » apache tomcat 6.0.14 » javax.servlet.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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