KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > web > WebResponse


1 // Copyright 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.web;
16
17 import java.io.IOException JavaDoc;
18 import java.io.OutputStream JavaDoc;
19 import java.io.PrintWriter JavaDoc;
20
21 import org.apache.tapestry.util.ContentType;
22
23 /**
24  * Controls the response to the client, and specifically allows for creating the output stream (or
25  * print writer) to which content is sent.
26  *
27  * @author Howard M. Lewis Ship
28  * @since 4.0
29  */

30 public interface WebResponse
31 {
32     /**
33      * Returns a output stream to which output should be sent. This method should only be invoked
34      * once on a response.
35      *
36      * @return the output stream, configured for the given type.
37      */

38
39     public OutputStream JavaDoc getOutputStream(ContentType contentType) throws IOException JavaDoc;
40
41     /**
42      * Returns a {@link PrintWriter}to which output should be sent. This method should be invoked
43      * once on a response. A second call is expected to be so that an exception page can be
44      * rendered, and the underlying request data is reset.
45      */

46
47     public PrintWriter JavaDoc getPrintWriter(ContentType contentType) throws IOException JavaDoc;
48
49     /**
50      * Encodes a URL, which adds information to the URL needed to ensure that the request triggered
51      * by the URL will be associated with the current session (if any). In most cases, the string is
52      * returned unchanged.
53      */

54
55     public String JavaDoc encodeURL(String JavaDoc url);
56
57     /**
58      * Resets any buffered content. This may be used after an error to radically change what the
59      * output will be.
60      */

61
62     public void reset();
63
64     public void setContentLength(int contentLength);
65
66     /**
67      * Returns a value to be prefixed or suffixed with any client-side JavaScript elements
68      * (variables and function names) to ensure that they are unique with the context of the entire
69      * page. For servlets, this is the empty string.
70      */

71
72     public String JavaDoc getNamespace();
73
74     /**
75      * Sets a response header as a date.
76      *
77      * @param string
78      * the name of the header to set.
79      * @param date
80      * the date value to set, in milliseconds since the epoch.
81      */

82     public void setDateHeader(String JavaDoc string, long date);
83
84     /**
85      * Sets the status code for this response.
86      */

87     public void setStatus(int status);
88 }
Popular Tags