KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openejb > webadmin > HttpRequest


1 /**
2  * Redistribution and use of this software and associated documentation
3  * ("Software"), with or without modification, are permitted provided
4  * that the following conditions are met:
5  *
6  * 1. Redistributions of source code must retain copyright
7  * statements and notices. Redistributions must also contain a
8  * copy of this document.
9  *
10  * 2. Redistributions in binary form must reproduce the
11  * above copyright notice, this list of conditions and the
12  * following disclaimer in the documentation and/or other
13  * materials provided with the distribution.
14  *
15  * 3. The name "OpenEJB" must not be used to endorse or promote
16  * products derived from this Software without prior written
17  * permission of The OpenEJB Group. For written permission,
18  * please contact dev@openejb.org.
19  *
20  * 4. Products derived from this Software may not be called "OpenEJB"
21  * nor may "OpenEJB" appear in their names without prior written
22  * permission of The OpenEJB Group. OpenEJB is a registered
23  * trademark of The OpenEJB Group.
24  *
25  * 5. Due credit should be given to the OpenEJB Project
26  * (http://www.openejb.org/).
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
29  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32  * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39  * OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Copyright 2001 (C) The OpenEJB Group. All Rights Reserved.
42  *
43  * $Id: HttpRequest.java 1912 2005-06-16 22:29:56Z jlaskowski $
44  */

45 package org.openejb.webadmin;
46
47
48 /** An interface to take care of HTTP Requests. It parses headers, content, form and url
49  * parameters.
50  *
51  * @author <a HREF="mailto:david.blevins@visi.com">David Blevins</a>
52  */

53 public interface HttpRequest extends java.io.Serializable JavaDoc{
54     
55     /** the HTTP OPTIONS type */
56     public static final int OPTIONS = 0; // Section 9.2
57
/** the HTTP GET type */
58     public static final int GET = 1; // Section 9.3
59
/** the HTTP HEAD type */
60     public static final int HEAD = 2; // Section 9.4
61
/** the HTTP POST type */
62     public static final int POST = 3; // Section 9.5
63
/** the HTTP PUT type */
64     public static final int PUT = 4; // Section 9.6
65
/** the HTTP DELETE type */
66     public static final int DELETE = 5; // Section 9.7
67
/** the HTTP TRACE type */
68     public static final int TRACE = 6; // Section 9.8
69
/** the HTTP CONNECT type */
70     public static final int CONNECT = 7; // Section 9.9
71
/** the HTTP UNSUPPORTED type */
72     public static final int UNSUPPORTED = 8;
73     
74     /*
75      * Header variables
76      */

77     /** the Accept header */
78     public static final String JavaDoc HEADER_ACCEPT = "Accept";
79     /** the Accept-Encoding header */
80     public static final String JavaDoc HEADER_ACCEPT_ENCODING = "Accept-Encoding";
81     /** the Accept-Language header */
82     public static final String JavaDoc HEADER_ACCEPT_LANGUAGE = "Accept-Language";
83     /** the Content-Type header */
84     public static final String JavaDoc HEADER_CONTENT_TYPE = "Content-Type";
85     /** the Content-Length header */
86     public static final String JavaDoc HEADER_CONTENT_LENGTH = "Content-Length";
87     /** the Connection header */
88     public static final String JavaDoc HEADER_CONNECTION = "Connection";
89     /** the Cache-Control header */
90     public static final String JavaDoc HEADER_CACHE_CONTROL = "Cache-Control";
91     /** the Host header */
92     public static final String JavaDoc HEADER_HOST = "Host";
93     /** the User-Agent header */
94     public static final String JavaDoc HEADER_USER_AGENT = "User-Agent";
95     /** the Set-Cookie header */
96     public static final String JavaDoc HEADER_SET_COOKIE = "Set-Cookie";
97     /** the Cookie header */
98     public static final String JavaDoc HEADER_COOKIE = "Cookie";
99     
100     /**
101      * Returns the current <code>HttpSession</code> associated with this
102      * request or, if there is no current session and <code>create</code> is
103      * true, returns a new session.
104      *
105      * <p>If <code>create</code> is <code>false</code> and the request has no
106      * valid <code>HttpSession</code>, this method returns <code>null</code>.
107      *
108      * @param create <code>true</code> to create a new session for this request
109      * if necessary; <code>false</code> to return <code>null</code> if there's
110      * no current session
111      *
112      * @return the <code>HttpSession</code> associated with this request or
113      * <code>null</code> if <code>create</code> is <code>false</code> and the
114      * request has no valid session
115      *
116      * @see #getSession()
117      */

118     public HttpSession getSession(boolean create);
119
120     /**
121      * Returns the current session associated with this request, or if the
122      * request does not have a session, creates one.
123      *
124      * @return the <code>HttpSession</code> associated with this request
125      *
126      * @see #getSession(boolean)
127      */

128     public HttpSession getSession();
129     
130     /** Gets a header based the header name passed in.
131      * @param name The name of the header to get
132      * @return The value of the header
133      */

134     public String JavaDoc getHeader(String JavaDoc name);
135
136     /** Gets a form parameter based on the name passed in.
137      * @param name The name of the form parameter to get
138      * @return The value of the parameter
139      */

140     public String JavaDoc getFormParameter(String JavaDoc name);
141     
142     /** Gets all the form parameters in the form of a two-dimentional array
143      * The second dimention has two indexes which contain the key and value
144      * for example:
145      * <code>
146      * for(int i=0; i<formParams.length; i++) {
147      * key = formParams[i][0];
148      * value = formParams[i][1];
149      * }
150      * </code>
151      *
152      * All values are strings
153      * @return All the form parameters
154      */

155     public String JavaDoc[][] getFormParameters();
156
157     /** Gets a URL (or query) parameter based on the name passed in.
158      * @param name The name of the URL (or query) parameter
159      * @return The value of the URL (or query) parameter
160      */

161     public String JavaDoc getQueryParameter(String JavaDoc name);
162
163     /** Gets an integer value of the request method. These values are:
164      *
165      * OPTIONS = 0
166      * GET = 1
167      * HEAD = 2
168      * POST = 3
169      * PUT = 4
170      * DELETE = 5
171      * TRACE = 6
172      * CONNECT = 7
173      * UNSUPPORTED = 8
174      * @return The integer value of the method
175      */

176     public int getMethod();
177
178     /** Gets the URI for the current URL page.
179      * @return The URI
180      */

181     public java.net.URL JavaDoc getURI();
182
183 }
184
Popular Tags