KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > boot > RequestHandlerResponse


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.boot;
21
22 import java.io.IOException JavaDoc;
23 import java.io.OutputStream JavaDoc;
24
25 import javax.servlet.http.Cookie JavaDoc;
26
27 /**
28  * Encapsulates a response to send to back the client.
29  *
30  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
31  * @see com.sslexplorer.boot.RequestHandler
32  */

33 public interface RequestHandlerResponse {
34
35     /**
36      * Set the value of a named HTTP header field to send back to the client with the response.
37      * If a header field with the provided name already exists its current
38      * value will be replaced. The header will only be set if the response
39      * has not yet started being sent. If this is not the case, and the
40      * protocol is HTTP 1.1 then the field will be sent as a trailer, otherwise
41      * it will be ignored.
42      *
43      * @param header header field name
44      * @param value header value
45      * @see #addField(String, String)
46      */

47     public void setField(String JavaDoc header, String JavaDoc value);
48     
49     /**
50      * Add a named HTTP header field to send back to the client with the response.
51      * If a header value with the provided name already exists it will be left
52      * alone and a new field will be added. The header will only be set if the response
53      * has not yet started being sent. If this is not the case, and the
54      * protocol is HTTP 1.1 then the field will be sent as a trailer, otherwise
55      * it will be ignored.
56      *
57      * @param header header field name
58      * @param value header value
59      * @see #setField(String, String)
60      */

61     public void addField(String JavaDoc header, String JavaDoc value);
62
63     /**
64      * Remove a named HTTP header field from the response. If the response
65      * is already being sent then this method will have no effect. If there
66      * are multiple headers with the specfied name then all headers with that
67      * name should be removed.
68      *
69      * @param header header field to remove
70      */

71     public void removeField(String JavaDoc header);
72     
73     /**
74      * Send a HTTP response
75      *
76      * @param status status code
77      * @param message message
78      * @throws IOException on any error
79      * @see HttpConstants
80      */

81     public void sendError(int status, String JavaDoc message) throws IOException JavaDoc;
82     
83     /**
84      * Set the HTTP status code.
85      *
86      * @param status status code
87      * @see HttpConstants
88      */

89     public void setStatus(int status);
90     
91     /**
92      * Set the content length header.
93      *
94      * @param length content length
95      */

96     public void setContentLength(int length);
97     
98     /**
99      * Set the response code reason
100      *
101      * @param reason response code reason
102      */

103     public void setReason(String JavaDoc reason);
104     
105     /**
106      * Get the output stream on which this response will be written.
107      *
108      * @return output stream
109      * @throws IOException
110      */

111     public OutputStream JavaDoc getOutputStream() throws IOException JavaDoc;
112     
113     /**
114      * Send an HTTP redirect
115      *
116      * @param url url to redirect client to
117      * @throws IOException on any error
118      */

119     public void sendRedirect(String JavaDoc url) throws IOException JavaDoc;
120     
121     
122     /**
123      * Add a cookie to the response.
124      * @param cookie
125      */

126     public void addCookie(Cookie JavaDoc cookie);
127     
128     
129     
130     public void setCharacterEncoding(String JavaDoc charset);
131
132 }
133
Popular Tags