KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.List JavaDoc;
18 import java.util.Locale JavaDoc;
19
20 import org.apache.tapestry.describe.Describable;
21
22 /**
23  * Contains information about the current request, including URLs, schemes, parameters, properties
24  * and attributes.
25  *
26  * @author Howard M. Lewis Ship
27  * @since 4.0
28  */

29 public interface WebRequest extends AttributeHolder, Describable
30 {
31     /**
32      * Returns the names of all query parameters for this request. Note that this may return an
33      * empty list if an HTML form submission uploads files (with a request encoding of
34      * multipart/form-data). Accessing query parameters in such an event requires parsing of the
35      * request input stream.
36      *
37      * @returns List of Strings, in ascending alphabetical order
38      */

39
40     public List JavaDoc getParameterNames();
41
42     /**
43      * Returns a parameter value. If the parameter was submitted with multiple values, then the
44      * first submitted value is returned. May return null if no parameter was submitted with the
45      * given name.
46      *
47      * @param parameterName
48      * name of parameter to obtain
49      * @return the corresponding value, or null if a value for the parameter was not submitted in
50      * the request
51      * @see #getParameterValues(String)
52      */

53
54     public String JavaDoc getParameterValue(String JavaDoc parameterName);
55
56     /**
57      * Returns all parameter values for a particular parameter name. May return null.
58      * <p>
59      * The caller should <em>not modify</em> the returned value.
60      *
61      * @param parameterName
62      * name of parameter to obtain
63      * @return the corresponding values, or null if no values for the parameter were submitted in
64      * the request
65      * @see #getParameterValue(String)
66      */

67
68     public String JavaDoc[] getParameterValues(String JavaDoc parameterName);
69
70     /**
71      * Returns the portion of the request URI that indicates the context of the request. The context
72      * path always comes first in a request URI. The path starts with a "/" character but does not
73      * end with a "/" character.
74      */

75
76     public String JavaDoc getContextPath();
77
78     /**
79      * Returns the current {@link WebSession}associated with this request, possibly creating it if
80      * it does not already exist. If create is false and the request has no valid session, this
81      * method returns null. To make sure the session is properly maintained, you must call this
82      * method <em>before</em> the response is committed.
83      *
84      * @param create
85      * if true, the session will be created and returned if it does not already exist
86      * @returns The session, or null if it does not exist (and create is false)
87      */

88     public WebSession getSession(boolean create);
89
90     /**
91      * Returns the name of the scheme used to make this request. For example, http, https, or ftp.
92      * Different schemes have different rules for constructing URLs, as noted in RFC 1738.
93      */

94     public String JavaDoc getScheme();
95
96     /**
97      * Returns the host name of the server that received the request. Note that behind a firewall,
98      * this may be obscured (i.e., it may be the name of the firewall server, which is not
99      * necessarily visible to clients outside the firewall.
100      *
101      * @see org.apache.tapestry.request.IRequestDecoder
102      */

103
104     public String JavaDoc getServerName();
105
106     /**
107      * Returns the port number on which this request was received.
108      */

109
110     public int getServerPort();
111
112     /**
113      * Returns the path portion of the request which triggered this request. Query parameters,
114      * scheme, server and port are omitted.
115      * <p>
116      * Note: portlets do not know their request URI.
117      */

118
119     public String JavaDoc getRequestURI();
120
121     /**
122      * Redirects to the indicated URL. If the URL is local, then a forward occurs. Otherwise, a
123      * client side redirect is returned to the client browser.
124      */

125
126     public void forward(String JavaDoc URL);
127
128     /**
129      * Returns the path of the resource which activated this request (this is the servlet path, plus
130      * path info, for a servlet request).
131      *
132      * @returns the full servlet path (for servlet requests), or a blank string (for portlet
133      * requests).
134      */

135     public String JavaDoc getActivationPath();
136
137     /**
138      * Returns the preferred locale to which content should be localized, as specified by the client
139      * or by the container. May return null.
140      */

141     public Locale JavaDoc getLocale();
142
143     /**
144      * Returns the value of the specified request header.
145      *
146      * @param name
147      * the name of the header to retrieve
148      * @return the header value as a string, or null if the header is not in the request.
149      */

150
151     public String JavaDoc getHeader(String JavaDoc name);
152 }
Popular Tags