Source Code Cross Referenced for ServletRequest.java in  » 6.0-JDK-Core » Servlet-API-by-tomcat » javax » servlet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Servlet API by tomcat » javax.servlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2004 The Apache Software Foundation
003         *
004         * Licensed under the Apache License, Version 2.0 (the "License");
005         * you may not use this file except in compliance with the License.
006         * You may obtain a copy of the License at
007         *
008         *     http://www.apache.org/licenses/LICENSE-2.0
009         *
010         * Unless required by applicable law or agreed to in writing, software
011         * distributed under the License is distributed on an "AS IS" BASIS,
012         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013         * See the License for the specific language governing permissions and
014         * limitations under the License.
015         */
016        package javax.servlet;
017
018        import java.io.BufferedReader;
019        import java.io.IOException;
020        import java.util.Enumeration;
021        import java.util.Locale;
022        import java.util.Map;
023
024        /**
025         * Defines an object to provide client request information to a servlet.  The
026         * servlet container creates a <code>ServletRequest</code> object and passes
027         * it as an argument to the servlet's <code>service</code> method.
028         *
029         * <p>A <code>ServletRequest</code> object provides data including
030         * parameter name and values, attributes, and an input stream.
031         * Interfaces that extend <code>ServletRequest</code> can provide
032         * additional protocol-specific data (for example, HTTP data is
033         * provided by {@link javax.servlet.http.HttpServletRequest}.
034         * 
035         * @author 	Various
036         * @version 	$Version$
037         *
038         * @see 	javax.servlet.http.HttpServletRequest
039         *
040         */
041
042        public interface ServletRequest {
043
044            /**
045             *
046             * Returns the value of the named attribute as an <code>Object</code>,
047             * or <code>null</code> if no attribute of the given name exists. 
048             *
049             * <p> Attributes can be set two ways.  The servlet container may set
050             * attributes to make available custom information about a request.
051             * For example, for requests made using HTTPS, the attribute
052             * <code>javax.servlet.request.X509Certificate</code> can be used to
053             * retrieve information on the certificate of the client.  Attributes
054             * can also be set programatically using 
055             * {@link ServletRequest#setAttribute}.  This allows information to be
056             * embedded into a request before a {@link RequestDispatcher} call.
057             *
058             * <p>Attribute names should follow the same conventions as package
059             * names. This specification reserves names matching <code>java.*</code>,
060             * <code>javax.*</code>, and <code>sun.*</code>. 
061             *
062             * @param name	a <code>String</code> specifying the name of 
063             *			the attribute
064             *
065             * @return		an <code>Object</code> containing the value 
066             *			of the attribute, or <code>null</code> if
067             *			the attribute does not exist
068             *
069             */
070
071            public Object getAttribute(String name);
072
073            /**
074             * Returns an <code>Enumeration</code> containing the
075             * names of the attributes available to this request. 
076             * This method returns an empty <code>Enumeration</code>
077             * if the request has no attributes available to it.
078             * 
079             *
080             * @return		an <code>Enumeration</code> of strings 
081             *			containing the names 
082             * 			of the request's attributes
083             *
084             */
085
086            public Enumeration getAttributeNames();
087
088            /**
089             * Returns the name of the character encoding used in the body of this
090             * request. This method returns <code>null</code> if the request
091             * does not specify a character encoding
092             * 
093             *
094             * @return		a <code>String</code> containing the name of 
095             *			the character encoding, or <code>null</code>
096             *			if the request does not specify a character encoding
097             *
098             */
099
100            public String getCharacterEncoding();
101
102            /**
103             * Overrides the name of the character encoding used in the body of this
104             * request. This method must be called prior to reading request parameters
105             * or reading input using getReader().
106             * 
107             *
108             * @param env	a <code>String</code> containing the name of 
109             *			the character encoding.
110             * @throws		java.io.UnsupportedEncodingException if this is not a valid encoding
111             */
112
113            public void setCharacterEncoding(String env)
114                    throws java.io.UnsupportedEncodingException;
115
116            /**
117             * Returns the length, in bytes, of the request body 
118             * and made available by the input stream, or -1 if the
119             * length is not known. For HTTP servlets, same as the value
120             * of the CGI variable CONTENT_LENGTH.
121             *
122             * @return		an integer containing the length of the 
123             * 			request body or -1 if the length is not known
124             *
125             */
126
127            public int getContentLength();
128
129            /**
130             * Returns the MIME type of the body of the request, or 
131             * <code>null</code> if the type is not known. For HTTP servlets, 
132             * same as the value of the CGI variable CONTENT_TYPE.
133             *
134             * @return		a <code>String</code> containing the name 
135             *			of the MIME type of 
136             * 			the request, or null if the type is not known
137             *
138             */
139
140            public String getContentType();
141
142            /**
143             * Retrieves the body of the request as binary data using
144             * a {@link ServletInputStream}.  Either this method or 
145             * {@link #getReader} may be called to read the body, not both.
146             *
147             * @return			a {@link ServletInputStream} object containing
148             * 				the body of the request
149             *
150             * @exception IllegalStateException  if the {@link #getReader} method
151             * 					 has already been called for this request
152             *
153             * @exception IOException    	if an input or output exception occurred
154             *
155             */
156
157            public ServletInputStream getInputStream() throws IOException;
158
159            /**
160             * Returns the value of a request parameter as a <code>String</code>,
161             * or <code>null</code> if the parameter does not exist. Request parameters
162             * are extra information sent with the request.  For HTTP servlets,
163             * parameters are contained in the query string or posted form data.
164             *
165             * <p>You should only use this method when you are sure the
166             * parameter has only one value. If the parameter might have
167             * more than one value, use {@link #getParameterValues}.
168             *
169             * <p>If you use this method with a multivalued
170             * parameter, the value returned is equal to the first value
171             * in the array returned by <code>getParameterValues</code>.
172             *
173             * <p>If the parameter data was sent in the request body, such as occurs
174             * with an HTTP POST request, then reading the body directly via {@link
175             * #getInputStream} or {@link #getReader} can interfere
176             * with the execution of this method.
177             *
178             * @param name 	a <code>String</code> specifying the 
179             *			name of the parameter
180             *
181             * @return		a <code>String</code> representing the 
182             *			single value of the parameter
183             *
184             * @see 		#getParameterValues
185             *
186             */
187
188            public String getParameter(String name);
189
190            /**
191             *
192             * Returns an <code>Enumeration</code> of <code>String</code>
193             * objects containing the names of the parameters contained
194             * in this request. If the request has 
195             * no parameters, the method returns an 
196             * empty <code>Enumeration</code>. 
197             *
198             * @return		an <code>Enumeration</code> of <code>String</code>
199             *			objects, each <code>String</code> containing
200             * 			the name of a request parameter; or an 
201             *			empty <code>Enumeration</code> if the
202             *			request has no parameters
203             *
204             */
205
206            public Enumeration getParameterNames();
207
208            /**
209             * Returns an array of <code>String</code> objects containing 
210             * all of the values the given request parameter has, or 
211             * <code>null</code> if the parameter does not exist.
212             *
213             * <p>If the parameter has a single value, the array has a length
214             * of 1.
215             *
216             * @param name	a <code>String</code> containing the name of 
217             *			the parameter whose value is requested
218             *
219             * @return		an array of <code>String</code> objects 
220             *			containing the parameter's values
221             *
222             * @see		#getParameter
223             *
224             */
225
226            public String[] getParameterValues(String name);
227
228            /** Returns a java.util.Map of the parameters of this request.
229             * Request parameters
230             * are extra information sent with the request.  For HTTP servlets,
231             * parameters are contained in the query string or posted form data.
232             *
233             * @return an immutable java.util.Map containing parameter names as 
234             * keys and parameter values as map values. The keys in the parameter
235             * map are of type String. The values in the parameter map are of type
236             * String array.
237             *
238             */
239
240            public Map getParameterMap();
241
242            /**
243             * Returns the name and version of the protocol the request uses
244             * in the form <i>protocol/majorVersion.minorVersion</i>, for 
245             * example, HTTP/1.1. For HTTP servlets, the value
246             * returned is the same as the value of the CGI variable 
247             * <code>SERVER_PROTOCOL</code>.
248             *
249             * @return		a <code>String</code> containing the protocol 
250             *			name and version number
251             *
252             */
253
254            public String getProtocol();
255
256            /**
257             * Returns the name of the scheme used to make this request, 
258             * for example,
259             * <code>http</code>, <code>https</code>, or <code>ftp</code>.
260             * Different schemes have different rules for constructing URLs,
261             * as noted in RFC 1738.
262             *
263             * @return		a <code>String</code> containing the name 
264             *			of the scheme used to make this request
265             *
266             */
267
268            public String getScheme();
269
270            /**
271             * Returns the host name of the server to which the request was sent.
272             * It is the value of the part before ":" in the <code>Host</code>
273             * header value, if any, or the resolved server name, or the server IP address.
274             *
275             * @return		a <code>String</code> containing the name 
276             *			of the server
277             */
278
279            public String getServerName();
280
281            /**
282             * Returns the port number to which the request was sent.
283             * It is the value of the part after ":" in the <code>Host</code>
284             * header value, if any, or the server port where the client connection
285             * was accepted on.
286             *
287             * @return		an integer specifying the port number
288             *
289             */
290
291            public int getServerPort();
292
293            /**
294             * Retrieves the body of the request as character data using
295             * a <code>BufferedReader</code>.  The reader translates the character
296             * data according to the character encoding used on the body.
297             * Either this method or {@link #getInputStream} may be called to read the
298             * body, not both.
299             * 
300             *
301             * @return					a <code>BufferedReader</code>
302             *						containing the body of the request	
303             *
304             * @exception UnsupportedEncodingException 	if the character set encoding
305             * 						used is not supported and the 
306             *						text cannot be decoded
307             *
308             * @exception IllegalStateException   	if {@link #getInputStream} method
309             * 						has been called on this request
310             *
311             * @exception IOException  			if an input or output exception occurred
312             *
313             * @see 					#getInputStream
314             *
315             */
316
317            public BufferedReader getReader() throws IOException;
318
319            /**
320             * Returns the Internet Protocol (IP) address of the client 
321             * or last proxy that sent the request.
322             * For HTTP servlets, same as the value of the 
323             * CGI variable <code>REMOTE_ADDR</code>.
324             *
325             * @return		a <code>String</code> containing the 
326             *			IP address of the client that sent the request
327             *
328             */
329
330            public String getRemoteAddr();
331
332            /**
333             * Returns the fully qualified name of the client
334             * or the last proxy that sent the request.
335             * If the engine cannot or chooses not to resolve the hostname 
336             * (to improve performance), this method returns the dotted-string form of 
337             * the IP address. For HTTP servlets, same as the value of the CGI variable 
338             * <code>REMOTE_HOST</code>.
339             *
340             * @return		a <code>String</code> containing the fully 
341             *			qualified name of the client
342             *
343             */
344
345            public String getRemoteHost();
346
347            /**
348             *
349             * Stores an attribute in this request.
350             * Attributes are reset between requests.  This method is most
351             * often used in conjunction with {@link RequestDispatcher}.
352             *
353             * <p>Attribute names should follow the same conventions as
354             * package names. Names beginning with <code>java.*</code>,
355             * <code>javax.*</code>, and <code>com.sun.*</code>, are
356             * reserved for use by Sun Microsystems.
357             *<br> If the object passed in is null, the effect is the same as
358             * calling {@link #removeAttribute}.
359             * <br> It is warned that when the request is dispatched from the
360             * servlet resides in a different web application by
361             * <code>RequestDispatcher</code>, the object set by this method
362             * may not be correctly retrieved in the caller servlet.
363             *
364             *
365             * @param name			a <code>String</code> specifying 
366             *					the name of the attribute
367             *
368             * @param o				the <code>Object</code> to be stored
369             *
370             */
371
372            public void setAttribute(String name, Object o);
373
374            /**
375             *
376             * Removes an attribute from this request.  This method is not
377             * generally needed as attributes only persist as long as the request
378             * is being handled.
379             *
380             * <p>Attribute names should follow the same conventions as
381             * package names. Names beginning with <code>java.*</code>,
382             * <code>javax.*</code>, and <code>com.sun.*</code>, are
383             * reserved for use by Sun Microsystems.
384             *
385             *
386             * @param name			a <code>String</code> specifying 
387             *					the name of the attribute to remove
388             *
389             */
390
391            public void removeAttribute(String name);
392
393            /**
394             *
395             * Returns the preferred <code>Locale</code> that the client will 
396             * accept content in, based on the Accept-Language header.
397             * If the client request doesn't provide an Accept-Language header,
398             * this method returns the default locale for the server.
399             *
400             *
401             * @return		the preferred <code>Locale</code> for the client
402             *
403             */
404
405            public Locale getLocale();
406
407            /**
408             *
409             * Returns an <code>Enumeration</code> of <code>Locale</code> objects
410             * indicating, in decreasing order starting with the preferred locale, the
411             * locales that are acceptable to the client based on the Accept-Language
412             * header.
413             * If the client request doesn't provide an Accept-Language header,
414             * this method returns an <code>Enumeration</code> containing one 
415             * <code>Locale</code>, the default locale for the server.
416             *
417             *
418             * @return		an <code>Enumeration</code> of preferred 
419             *                  <code>Locale</code> objects for the client
420             *
421             */
422
423            public Enumeration getLocales();
424
425            /**
426             *
427             * Returns a boolean indicating whether this request was made using a
428             * secure channel, such as HTTPS.
429             *
430             *
431             * @return		a boolean indicating if the request was made using a
432             *                  secure channel
433             *
434             */
435
436            public boolean isSecure();
437
438            /**
439             *
440             * Returns a {@link RequestDispatcher} object that acts as a wrapper for
441             * the resource located at the given path.  
442             * A <code>RequestDispatcher</code> object can be used to forward
443             * a request to the resource or to include the resource in a response.
444             * The resource can be dynamic or static.
445             *
446             * <p>The pathname specified may be relative, although it cannot extend
447             * outside the current servlet context.  If the path begins with 
448             * a "/" it is interpreted as relative to the current context root.  
449             * This method returns <code>null</code> if the servlet container
450             * cannot return a <code>RequestDispatcher</code>.
451             *
452             * <p>The difference between this method and {@link
453             * ServletContext#getRequestDispatcher} is that this method can take a
454             * relative path.
455             *
456             * @param path      a <code>String</code> specifying the pathname
457             *                  to the resource. If it is relative, it must be
458             *                  relative against the current servlet.
459             *
460             * @return          a <code>RequestDispatcher</code> object
461             *                  that acts as a wrapper for the resource
462             *                  at the specified path, or <code>null</code>
463             *                  if the servlet container cannot return a
464             *                  <code>RequestDispatcher</code>
465             *
466             * @see             RequestDispatcher
467             * @see             ServletContext#getRequestDispatcher
468             *
469             */
470
471            public RequestDispatcher getRequestDispatcher(String path);
472
473            /**
474             * 
475             * @deprecated 	As of Version 2.1 of the Java Servlet API,
476             * 			use {@link ServletContext#getRealPath} instead.
477             *
478             */
479
480            public String getRealPath(String path);
481
482            /**
483             * Returns the Internet Protocol (IP) source port of the client
484             * or last proxy that sent the request.
485             *
486             * @return	an integer specifying the port number
487             *
488             * @since 2.4
489             */
490            public int getRemotePort();
491
492            /**
493             * Returns the host name of the Internet Protocol (IP) interface on
494             * which the request was received.
495             *
496             * @return	a <code>String</code> containing the host
497             *		name of the IP on which the request was received.
498             *
499             * @since 2.4
500             */
501            public String getLocalName();
502
503            /**
504             * Returns the Internet Protocol (IP) address of the interface on
505             * which the request  was received.
506             *
507             * @return	a <code>String</code> containing the
508             *		IP address on which the request was received. 
509             *
510             * @since 2.4
511             *
512             */
513            public String getLocalAddr();
514
515            /**
516             * Returns the Internet Protocol (IP) port number of the interface
517             * on which the request was received.
518             *
519             * @return an integer specifying the port number
520             *
521             * @since 2.4
522             */
523            public int getLocalPort();
524
525        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.