Java Doc for HttpRequest.java in  » Web-Server » Quadcap-Web-Server » com » quadcap » http » server22 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

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 geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Quadcap Web Server » com.quadcap.http.server22 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.quadcap.http.server22.HttpRequest

HttpRequest
public class HttpRequest implements HttpServletRequest(Code)
This class encapsulates the information that makes up a single HTTP request, including the method, URI, and the headers.
author:
   Stan Bailes


Field Summary
final static  intCR
    
 Hashtableattributes
    
 booleanbadRequest
    
 Cookie[]cookies
    
static  DateFormatdateFormat
    
 booleangetInputStreamCalled
    
 booleangetReaderCalled
    
 int[]hOffsets
    
 byte[]headers
    
 HttpInputStreamhis
    
static  OctetMapmapE
    
static  OctetMapmapM
    
static  OctetMapmapQuote
    
 Stringmethod
    
final static  StringmethodGET
    
final static  StringmethodHEAD
    
final static  StringmethodPOST
    
 Hashtableparameters
    
 StringpathInfo
    
final static  Stringproto_09
    
final static  Stringproto_10
    
final static  Stringproto_11
    
 Stringprotocol
    
 StringqueryString
    
 intqueryStringLen
    
 intqueryStringStart
    
 HttpDispatcherrd
    
 BufferedReaderreader
    
 HttpResponseres
    
 Scannerscanner
    
 HSessionsession
    
 Stringuri
    
static  OctetMapversionMap
    
 WebWorkerw
    

Constructor Summary
public  HttpRequest(WebWorker w)
     Using the specified worker's input stream, read an HTTP request, and construct a new HttpRequest object to represent it.

Method Summary
 booleanbadRequest()
    
final  intcompareAccept(String a, String b)
    
public  ObjectgetAttribute(String name)
     Returns the value of the named attribute of the request, or null if the attribute does not exist.
public  EnumerationgetAttributeNames()
    
public  StringgetAuthType()
     Gets the authentication scheme of this request.
public  StringgetCharacterEncoding()
     Returns the character set encoding for the input of this request.
public  intgetContentLength()
     Returns the size of the request entity data, or -1 if not known.
public  StringgetContentType()
     Returns the Internet Media Type of the request entity data, or null if not known.
public  StringgetContextPath()
    
public  Cookie[]getCookies()
     Gets the array of cookies found in this request.
public  longgetDateHeader(String name)
     Gets the value of the requested date header field of this request.
public  StringgetHeader(String name)
     Gets the value of the requested header field of this request.
public  EnumerationgetHeaderNames()
    
public  EnumerationgetHeaders()
     Gets the header names for this request. an enumeration of strings representing the header namesfor this request.
public  EnumerationgetHeaders(String name)
    
public  ServletInputStreamgetInputStream()
     Returns an input stream for reading binary data in the request body.
public  intgetIntHeader(String name)
     Gets the value of the specified integer header field of this request.
final  floatgetLangQual(String s)
    
public  LocalegetLocale()
    
public  EnumerationgetLocales()
    
public  StringgetMethod()
     Gets the HTTP method (for example, GET, POST, PUT) with which this request was made.
public  StringgetParameter(String name)
     Returns a string containing the lone value of the specified parameter, or null if the parameter does not exist.
public  EnumerationgetParameterNames()
     Returns the parameter names for this request as an enumeration of strings, or an empty enumeration if there are no parameters or the input stream is empty.
public  String[]getParameterValues(String name)
     Returns the values of the specified parameter for the request as an array of strings, or null if the named parameter does not exist.
public  StringgetPathInfo()
     Gets any optional extra path information following the servlet path of this request's URI, but immediately preceding its query string.
public  StringgetPathTranslated()
     Gets any optional extra path information following the servlet path of this request's URI, but immediately preceding its query string, and translates it to a real path.
public  StringgetProtocol()
     Returns the protocol and version of the request as a string of the form <protocol>/<major version>.<minor version>.
public  StringgetQueryString()
     Gets any query string that is part of the HTTP request URI.
public  BufferedReadergetReader()
     Returns a buffered reader for reading text in the request body. This translates character set encodings as appropriate.
public  StringgetRealPath(String path)
     Applies alias rules to the specified virtual path and returns the corresponding real path, or null if the translation can not be performed for any reason.
public  StringgetRemoteAddr()
     Returns the IP address of the agent that sent the request.
public  StringgetRemoteHost()
     Returns the fully qualified host name of the agent that sent the request.
public  StringgetRemoteUser()
     Gets the name of the user making this request.
public  RequestDispatchergetRequestDispatcher(String path)
    
public  StringgetRequestURI()
     Gets, from the first line of the HTTP request, the part of this request's URI that is to the left of any query string.
public  StringgetRequestedSessionId()
     Gets the session id specified with this request.
public  StringgetScheme()
     Returns the scheme of the URL used in this request, for example "http", "https", or "ftp".
public  StringgetServerName()
     Returns the host name of the server that received the request.
public  intgetServerPort()
     Returns the port number on which this request was received.
public  StringgetServletPath()
     Gets the part of this request's URI that refers to the servlet being invoked.
public  HttpSessiongetSession(boolean create)
     Gets the current valid session associated with this request, if create is false or, if necessary, creates a new session for the request, if create is true.
public  HttpSessiongetSession()
     Gets the current valid session associated with this request, and if necessary, creates a new session for the request.
 StringgetToken(OctetMap map)
    
public  PrincipalgetUserPrincipal()
     Return a Principal object indicating the identity of the user associated with this request.
public  booleanisRequestedSessionIdFromCookie()
     Checks whether the session id specified by this request came in as a cookie.
public  booleanisRequestedSessionIdFromURL()
     Checks whether the session id specified by this request came in as part of the URL.
public  booleanisRequestedSessionIdFromUrl()
    
public  booleanisRequestedSessionIdValid()
     Checks whether this request is associated with a session that is valid in the current session context.
public  booleanisSecure()
    
public  booleanisUserInRole(String role)
     Returns a boolean indicating whether the authenticated user is included in the indicated 'role'.
final  LocalemakeLocale(String s)
    
final  voidmaybeParsePostData()
    
 StringparseHttpVersion()
    
public static  voidparseParameters(Hashtable params, InputStream is)
     Parse a set of parameters from the specified input stream.
public static  voidparseParameters(Hashtable params, Scanner s)
    
public  voidremoveAttribute(String name)
    
public  voidreset(HttpInputStream is)
     Reset the request object and bind it to the input stream.
public  voidsetAttribute(String name, Object obj)
    
final  voidsetRequestDispatcher(HttpDispatcher rd)
    
 voidsetResponse(HttpResponse res)
     Associate this request with its matching response.
public  voidsetURI(String s)
    
final static  StringurlDecode(String s)
    

Field Detail
CR
final static int CR(Code)



attributes
Hashtable attributes(Code)



badRequest
boolean badRequest(Code)



cookies
Cookie[] cookies(Code)



dateFormat
static DateFormat dateFormat(Code)



getInputStreamCalled
boolean getInputStreamCalled(Code)



getReaderCalled
boolean getReaderCalled(Code)



hOffsets
int[] hOffsets(Code)



headers
byte[] headers(Code)



his
HttpInputStream his(Code)



mapE
static OctetMap mapE(Code)



mapM
static OctetMap mapM(Code)



mapQuote
static OctetMap mapQuote(Code)



method
String method(Code)



methodGET
final static String methodGET(Code)



methodHEAD
final static String methodHEAD(Code)



methodPOST
final static String methodPOST(Code)



parameters
Hashtable parameters(Code)



pathInfo
String pathInfo(Code)



proto_09
final static String proto_09(Code)



proto_10
final static String proto_10(Code)



proto_11
final static String proto_11(Code)



protocol
String protocol(Code)



queryString
String queryString(Code)



queryStringLen
int queryStringLen(Code)



queryStringStart
int queryStringStart(Code)



rd
HttpDispatcher rd(Code)



reader
BufferedReader reader(Code)



res
HttpResponse res(Code)



scanner
Scanner scanner(Code)



session
HSession session(Code)



uri
String uri(Code)



versionMap
static OctetMap versionMap(Code)



w
WebWorker w(Code)




Constructor Detail
HttpRequest
public HttpRequest(WebWorker w)(Code)
Using the specified worker's input stream, read an HTTP request, and construct a new HttpRequest object to represent it.
Parameters:
  w - the worker




Method Detail
badRequest
boolean badRequest()(Code)



compareAccept
final int compareAccept(String a, String b)(Code)



getAttribute
public Object getAttribute(String name)(Code)
Returns the value of the named attribute of the request, or null if the attribute does not exist.
Parameters:
  name - the name of the attribute whose value is required



getAttributeNames
public Enumeration getAttributeNames()(Code)
Return an enumeration of all attribute names of this service



getAuthType
public String getAuthType()(Code)
Gets the authentication scheme of this request. Same as the CGI variable AUTH_TYPE. this request's authentication scheme, or null if none.



getCharacterEncoding
public String getCharacterEncoding()(Code)
Returns the character set encoding for the input of this request.



getContentLength
public int getContentLength()(Code)
Returns the size of the request entity data, or -1 if not known. Same as the CGI variable CONTENT_LENGTH.



getContentType
public String getContentType()(Code)
Returns the Internet Media Type of the request entity data, or null if not known. Same as the CGI variable CONTENT_TYPE.



getContextPath
public String getContextPath()(Code)
Return the portion of the request URI that specifies the context for this request



getCookies
public Cookie[] getCookies()(Code)
Gets the array of cookies found in this request. the array of cookies found in this request



getDateHeader
public long getDateHeader(String name)(Code)
Gets the value of the requested date header field of this request. If the header can't be converted to a date, the method throws an IllegalArgumentException. The case of the header field name is ignored.
Parameters:
  name - the String containing the name of the requestedheader field the value the requested date header field, or -1 if notfound.



getHeader
public String getHeader(String name)(Code)
Gets the value of the requested header field of this request. The case of the header field name is ignored.
Parameters:
  name - the String containing the name of the requestedheader field the value of the requested header field, or null if notknown.



getHeaderNames
public Enumeration getHeaderNames()(Code)



getHeaders
public Enumeration getHeaders()(Code)
Gets the header names for this request. an enumeration of strings representing the header namesfor this request. Some server implementations do not allowheaders to be accessed in this way, in which case this methodwill return null.



getHeaders
public Enumeration getHeaders(String name)(Code)



getInputStream
public ServletInputStream getInputStream() throws IOException(Code)
Returns an input stream for reading binary data in the request body.
exception:
  IllegalStateException - if getReader has beencalled on this same request.
exception:
  IOException - on other I/O related errors.



getIntHeader
public int getIntHeader(String name)(Code)
Gets the value of the specified integer header field of this request. The case of the header field name is ignored. If the header can't be converted to an integer, the method throws a NumberFormatException.
Parameters:
  name - the String containing the name of the requestedheader field the value of the requested header field, or -1 if notfound.



getLangQual
final float getLangQual(String s)(Code)



getLocale
public Locale getLocale()(Code)
Return the preferred Locale that the client will accept content from based on the Accept-Language header, or the server default Locale



getLocales
public Enumeration getLocales()(Code)



getMethod
public String getMethod()(Code)
Gets the HTTP method (for example, GET, POST, PUT) with which this request was made. Same as the CGI variable REQUEST_METHOD. the HTTP method with which this request was made



getParameter
public String getParameter(String name)(Code)
Returns a string containing the lone value of the specified parameter, or null if the parameter does not exist. For example, in an HTTP servlet this method would return the value of the specified query string parameter. Servlet writers should use this method only when they are sure that there is only one value for the parameter. If the parameter has (or could have) multiple values, servlet writers should use getParameterValues. If a multiple valued parameter name is passed as an argument, the return value is implementation dependent.
Parameters:
  name - the name of the parameter whose value is required.



getParameterNames
public Enumeration getParameterNames()(Code)
Returns the parameter names for this request as an enumeration of strings, or an empty enumeration if there are no parameters or the input stream is empty. The input stream would be empty if all the data had been read from the stream returned by the method getInputStream.



getParameterValues
public String[] getParameterValues(String name)(Code)
Returns the values of the specified parameter for the request as an array of strings, or null if the named parameter does not exist. For example, in an HTTP servlet this method would return the values of the specified query string or posted form as an array of strings.
Parameters:
  name - the name of the parameter whose value is required.



getPathInfo
public String getPathInfo()(Code)
Gets any optional extra path information following the servlet path of this request's URI, but immediately preceding its query string. Same as the CGI variable PATH_INFO. the optional path information following the servletpath, but before the query string, in this request's URI; nullif this request's URI contains no extra path information



getPathTranslated
public String getPathTranslated()(Code)
Gets any optional extra path information following the servlet path of this request's URI, but immediately preceding its query string, and translates it to a real path. Similar to the CGI variable PATH_TRANSLATED extra path information translated to a real path or nullif no extra path information is in the request's URI



getProtocol
public String getProtocol()(Code)
Returns the protocol and version of the request as a string of the form <protocol>/<major version>.<minor version>. Same as the CGI variable SERVER_PROTOCOL.



getQueryString
public String getQueryString()(Code)
Gets any query string that is part of the HTTP request URI. Same as the CGI variable QUERY_STRING. query string that is part of this request's URI, or nullif it contains no query string



getReader
public BufferedReader getReader() throws IOException(Code)
Returns a buffered reader for reading text in the request body. This translates character set encodings as appropriate.
exception:
  UnsupportedEncodingException - if the character set encodingis unsupported, so the text can't be correctly decoded.
exception:
  IllegalStateException - if getInputStream has beencalled on this same request.
exception:
  IOException - on other I/O related errors.



getRealPath
public String getRealPath(String path)(Code)
Applies alias rules to the specified virtual path and returns the corresponding real path, or null if the translation can not be performed for any reason. For example, an HTTP servlet would resolve the path using the virtual docroot, if virtual hosting is enabled, and with the default docroot otherwise. Calling this method with the string "/" as an argument returns the document root.
Parameters:
  path - the virtual path to be translated to a real path



getRemoteAddr
public String getRemoteAddr()(Code)
Returns the IP address of the agent that sent the request. Same as the CGI variable REMOTE_ADDR.



getRemoteHost
public String getRemoteHost()(Code)
Returns the fully qualified host name of the agent that sent the request. Same as the CGI variable REMOTE_HOST.



getRemoteUser
public String getRemoteUser()(Code)
Gets the name of the user making this request. The user name is set with HTTP authentication. Whether the user name will continue to be sent with each subsequent communication is browser-dependent. Same as the CGI variable REMOTE_USER. the name of the user making this request, or null if notknown.



getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String path)(Code)



getRequestURI
public String getRequestURI()(Code)
Gets, from the first line of the HTTP request, the part of this request's URI that is to the left of any query string. For example,
First line of HTTP request Return from getRequestURI
POST /some/path.html HTTP/1.1/some/path.html
GET http://foo.bar/a.html HTTP/1.0 http://foo.bar/a.html
HEAD /xyz?a=b HTTP/1.1/xyz

To reconstruct a URL with a URL scheme and host, use the method javax.servlet.http.HttpUtils.getRequestURL, which returns a StringBuffer. this request's URI




getRequestedSessionId
public String getRequestedSessionId()(Code)
Gets the session id specified with this request. This may differ from the actual session id. For example, if the request specified an id for an invalid session, then this will get a new session with a new id. the session id specified by this request, or null if therequest did not specify a session id



getScheme
public String getScheme()(Code)
Returns the scheme of the URL used in this request, for example "http", "https", or "ftp". Different schemes have different rules for constructing URLs, as noted in RFC 1738. The URL used to create a request may be reconstructed using this scheme, the server name and port, and additional information such as URIs.



getServerName
public String getServerName()(Code)
Returns the host name of the server that received the request. Same as the CGI variable SERVER_NAME.



getServerPort
public int getServerPort()(Code)
Returns the port number on which this request was received. Same as the CGI variable SERVER_PORT.



getServletPath
public String getServletPath()(Code)
Gets the part of this request's URI that refers to the servlet being invoked. Analogous to the CGI variable SCRIPT_NAME. the servlet being invoked, as contained in thisrequest's URI



getSession
public HttpSession getSession(boolean create)(Code)
Gets the current valid session associated with this request, if create is false or, if necessary, creates a new session for the request, if create is true.

Note: to ensure the session is properly maintained, the servlet developer must call this method (at least once) before any output is written to the response.

Additionally, application-writers need to be aware that newly created sessions (that is, sessions for which HttpSession.isNew returns true) do not have any application-specific state. the session associated with this request or null ifcreate was false and no valid session is associatedwith this request.




getSession
public HttpSession getSession()(Code)
Gets the current valid session associated with this request, and if necessary, creates a new session for the request. the session associated with this request.



getToken
String getToken(OctetMap map) throws IOException(Code)
Parsing helper: Get the next bytes all of which are in the specified map
Parameters:
  map - the octet map specifying the bytes we want



getUserPrincipal
public Principal getUserPrincipal()(Code)
Return a Principal object indicating the identity of the user associated with this request.



isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()(Code)
Checks whether the session id specified by this request came in as a cookie. (The requested session may not be one returned by the getSession method.) true if the session id specified by this request came inas a cookie; false otherwise



isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()(Code)
Checks whether the session id specified by this request came in as part of the URL. (The requested session may not be the one returned by the getSession method.) true if the session id specified by the request for thissession came in as part of the URL; false otherwise



isRequestedSessionIdFromUrl
public boolean isRequestedSessionIdFromUrl()(Code)



isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()(Code)
Checks whether this request is associated with a session that is valid in the current session context. If it is not valid, the requested session will never be returned from the getSession method. true if this request is assocated with a session that isvalid in the current session context.



isSecure
public boolean isSecure()(Code)



isUserInRole
public boolean isUserInRole(String role)(Code)
Returns a boolean indicating whether the authenticated user is included in the indicated 'role'.



makeLocale
final Locale makeLocale(String s)(Code)



maybeParsePostData
final void maybeParsePostData()(Code)



parseHttpVersion
String parseHttpVersion() throws IOException(Code)
Parse the http version field from the request line the http protocol and version
exception:
  IOException - if the version field is incorrect



parseParameters
public static void parseParameters(Hashtable params, InputStream is)(Code)
Parse a set of parameters from the specified input stream.
Parameters:
  is - the input stream a table containing the parameters as String -> String[]entries.



parseParameters
public static void parseParameters(Hashtable params, Scanner s)(Code)



removeAttribute
public void removeAttribute(String name)(Code)
Remove an attribute from the request



reset
public void reset(HttpInputStream is) throws IOException(Code)
Reset the request object and bind it to the input stream.



setAttribute
public void setAttribute(String name, Object obj)(Code)
Set the value of the named attribute
Parameters:
  name - the name of the attribute
Parameters:
  obj - the value



setRequestDispatcher
final void setRequestDispatcher(HttpDispatcher rd)(Code)



setResponse
void setResponse(HttpResponse res)(Code)
Associate this request with its matching response. We need this to facilitate session management via cookies
Parameters:
  res - the HttpResponse that goes with this request



setURI
public void setURI(String s)(Code)



urlDecode
final static String urlDecode(String s)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.