Java Doc for ServletUnitHttpRequest.java in  » Testing » HttpUnit » com » meterware » servletunit » 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 » Testing » HttpUnit » com.meterware.servletunit 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.meterware.servletunit.ServletUnitHttpRequest

ServletUnitHttpRequest
class ServletUnitHttpRequest implements HttpServletRequest(Code)
This class represents a servlet request created from a WebRequest.

Inner Class :static class PrioritizedLocale implements Comparable


Constructor Summary
 ServletUnitHttpRequest(ServletMetaData servletRequest, WebRequest request, ServletUnitContext context, Dictionary clientHeaders, byte[] messageBody)
     Constructs a ServletUnitHttpRequest from a WebRequest object.

Method Summary
public  ObjectgetAttribute(String name)
     Returns the value of the named attribute as an Object. This method allows the servlet engine to give the servlet custom information about a request.
public  EnumerationgetAttributeNames()
     Returns an Enumeration containing the names of the attributes available to this request.
public  StringgetAuthType()
     Returns the name of the authentication scheme used to protect the servlet, for example, "BASIC" or "SSL," or null if the servlet was not protected.
public  StringgetCharacterEncoding()
     Returns the name of the character encoding style used in this request.
public  intgetContentLength()
     Returns the length, in bytes, of the content contained in the request and sent by way of the input stream or -1 if the length is not known.
public  StringgetContentType()
     Returns the MIME type of the content of the request, or null if the type is not known.
public  StringgetContextPath()
     Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI.
public  Cookie[]getCookies()
     Returns an array containing all of the Cookie objects the client sent with this request.
public  longgetDateHeader(String name)
     Returns the value of the specified request header as a long value that represents a Date object. Use this method with headers that contain dates, such as If-Modified-Since.
The date is returned as the number of milliseconds since January 1, 1970 GMT.
public  StringgetHeader(String name)
     Returns the value of the specified request header as a String.
public  EnumerationgetHeaderNames()
     Returns an enumeration of all the header names this request contains.
public  java.util.EnumerationgetHeaders(String name)
     Returns all the values of the specified request header as an Enumeration of String objects.
public  ServletInputStreamgetInputStream()
     Retrieves binary data from the body of the request as a ServletInputStream , which gives you the ability to read one line at a time.
public  intgetIntHeader(String name)
     Returns the value of the specified request header as an int.
public  StringgetLocalAddr()
    
public  StringgetLocalName()
    
public  intgetLocalPort()
    
public  LocalegetLocale()
     Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.
public  java.util.EnumerationgetLocales()
     Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.
public  StringgetMethod()
     Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
public  StringgetParameter(String name)
     Returns the value of a request parameter as a String, or null if the parameter does not exist.
public  MapgetParameterMap()
     Returns a java.util.Map of the parameters of this request. Request parameters are extra information sent with the request.
public  EnumerationgetParameterNames()
     Returns an Enumeration of String objects containing the names of the parameters contained in this request.
public  String[]getParameterValues(String name)
     Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
public  StringgetPathInfo()
     Returns any extra path information associated with the URL the client sent when it made this request.
public  StringgetPathTranslated()
     Returns any extra path information after the servlet name but before the query string, and translates it to a real path.
public  StringgetProtocol()
     Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.
public  StringgetQueryString()
     Returns the query string that is contained in the request URL after the path.
public  BufferedReadergetReader()
     Returns the body of the request as a BufferedReader that translates character set encodings.
public  StringgetRealPath(String path)
    
public  StringgetRemoteAddr()
     Returns the Internet Protocol (IP) address of the client that sent the request.
public  StringgetRemoteHost()
     Returns the fully qualified name of the client that sent the request.
public  intgetRemotePort()
    
public  StringgetRemoteUser()
     Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.
public  RequestDispatchergetRequestDispatcher(String path)
     Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response.
public  StringgetRequestURI()
     Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
public  StringBuffergetRequestURL()
     Reconstructs the URL the client used to make the request.
public  StringgetRequestedSessionId()
     Returns the session ID specified by the client.
public  StringgetScheme()
     Returns the name of the scheme used to make 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()
     Returns the part of this request's URL that calls the servlet.
public  HttpSessiongetSession(boolean create)
     Returns the current HttpSession associated with this request or, if there is no current session and create is true, returns a new session.
public  HttpSessiongetSession()
     Returns the current session associated with this request, or if the request does not have a session, creates one.
public  java.security.PrincipalgetUserPrincipal()
     Returns a java.security.Principal object containing the name of the current authenticated user.
public  booleanisRequestedSessionIdFromCookie()
     Checks whether the requested session ID came in as a cookie.
public  booleanisRequestedSessionIdFromURL()
     Checks whether the requested session ID came in as part of the request URL.
public  booleanisRequestedSessionIdFromUrl()
    
public  booleanisRequestedSessionIdValid()
     Checks whether the requested session ID is still valid.
public  booleanisSecure()
     Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
public  booleanisUserInRole(String role)
     Returns a boolean indicating whether the authenticated user is included in the specified logical "role".
 voidreadBasicAuthentication()
    
 voidreadFormAuthentication()
    
 voidrecordAuthenticationInfo(String userName, String[] roles)
    
public  voidremoveAttribute(String name)
     Removes an attribute from this request.
public  voidsetAttribute(String key, Object o)
     Stores an attribute in the context of this request.
public  voidsetCharacterEncoding(String charset)
     Overrides the name of the character encoding used in the body of this request.
static  String[]toArray(String roleList)
    


Constructor Detail
ServletUnitHttpRequest
ServletUnitHttpRequest(ServletMetaData servletRequest, WebRequest request, ServletUnitContext context, Dictionary clientHeaders, byte[] messageBody) throws MalformedURLException(Code)
Constructs a ServletUnitHttpRequest from a WebRequest object.




Method Detail
getAttribute
public Object getAttribute(String name)(Code)
Returns the value of the named attribute as an Object. This method allows the servlet engine to give the servlet custom information about a request. This method returns null if no attribute of the given name exists.



getAttributeNames
public Enumeration getAttributeNames()(Code)
Returns an Enumeration containing the names of the attributes available to this request. This method returns an empty Enumeration if the request has no attributes available to it.



getAuthType
public String getAuthType()(Code)
Returns the name of the authentication scheme used to protect the servlet, for example, "BASIC" or "SSL," or null if the servlet was not protected.



getCharacterEncoding
public String getCharacterEncoding()(Code)
Returns the name of the character encoding style used in this request. This method returns null if the request does not use character encoding.



getContentLength
public int getContentLength()(Code)
Returns the length, in bytes, of the content contained in the request and sent by way of the input stream or -1 if the length is not known.



getContentType
public String getContentType()(Code)
Returns the MIME type of the content of the request, or null if the type is not known. Same as the value of the CGI variable CONTENT_TYPE.



getContextPath
public String getContextPath()(Code)
Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "".



getCookies
public Cookie[] getCookies()(Code)
Returns an array containing all of the Cookie objects the client sent with this request. This method returns null if no cookies were sent.



getDateHeader
public long getDateHeader(String name)(Code)
Returns the value of the specified request header as a long value that represents a Date object. Use this method with headers that contain dates, such as If-Modified-Since.
The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive. If the request did not have a header of the specified name, this method returns -1. If the header can't be converted to a date, the method throws an IllegalArgumentException.



getHeader
public String getHeader(String name)(Code)
Returns the value of the specified request header as a String. If the request did not include a header of the specified name, this method returns null. The header name is case insensitive. You can use this method with any request header.



getHeaderNames
public Enumeration getHeaderNames()(Code)
Returns an enumeration of all the header names this request contains. If the request has no headers, this method returns an empty enumeration. Some servlet containers do not allow do not allow servlets to access headers using this method, in which case this method returns null.



getHeaders
public java.util.Enumeration getHeaders(String name)(Code)
Returns all the values of the specified request header as an Enumeration of String objects.



getInputStream
public ServletInputStream getInputStream() throws IOException(Code)
Retrieves binary data from the body of the request as a ServletInputStream , which gives you the ability to read one line at a time. a ServletInputStream object containingthe body of the request
exception:
  IllegalStateException - if the ServletUnitHttpRequest.getReader methodhas already been called for this request
exception:
  IOException - if an input or output exception occurred



getIntHeader
public int getIntHeader(String name)(Code)
Returns the value of the specified request header as an int. If the request does not have a header of the specified name, this method returns -1. If the header cannot be converted to an integer, this method throws a NumberFormatException.



getLocalAddr
public String getLocalAddr()(Code)



getLocalName
public String getLocalName()(Code)



getLocalPort
public int getLocalPort()(Code)



getLocale
public Locale getLocale()(Code)
Returns the preferred Locale that the client will accept content in, based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns the default locale for the server.



getLocales
public java.util.Enumeration getLocales()(Code)
Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns an Enumeration containing one Locale, the default locale for the server.



getMethod
public String getMethod()(Code)
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.



getParameter
public String getParameter(String name)(Code)
Returns the value of a request parameter as a String, or null if the parameter does not exist. Request parameters are extra information sent with the request.



getParameterMap
public Map getParameterMap()(Code)
Returns a java.util.Map of the parameters of this request. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.
since:
   1.3



getParameterNames
public Enumeration getParameterNames()(Code)
Returns an Enumeration of String objects containing the names of the parameters contained in this request. If the request has no parameters or if the input stream is empty, returns an empty Enumeration. The input stream is empty when all the data returned by ServletUnitHttpRequest.getInputStream has been read.



getParameterValues
public String[] getParameterValues(String name)(Code)
Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist. For example, in an HTTP servlet, this method returns an array of String objects containing the values of a query string or posted form.



getPathInfo
public String getPathInfo()(Code)
Returns any extra path information associated with the URL the client sent when it made this request. The extra path information follows the servlet path but precedes the query string. This method returns null if there was no extra path information.



getPathTranslated
public String getPathTranslated()(Code)
Returns any extra path information after the servlet name but before the query string, and translates it to a real path. If the URL does not have any extra path information, this method returns null.



getProtocol
public String getProtocol()(Code)
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.



getQueryString
public String getQueryString()(Code)
Returns the query string that is contained in the request URL after the path.



getReader
public BufferedReader getReader() throws IOException(Code)
Returns the body of the request as a BufferedReader that translates character set encodings.



getRealPath
public String getRealPath(String path)(Code)
javax.servlet.ServletContext.getRealPath



getRemoteAddr
public String getRemoteAddr()(Code)
Returns the Internet Protocol (IP) address of the client that sent the request.



getRemoteHost
public String getRemoteHost()(Code)
Returns the fully qualified name of the client that sent the request.



getRemotePort
public int getRemotePort()(Code)



getRemoteUser
public String getRemoteUser()(Code)
Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication.



getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String path)(Code)
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response. The resource can be dynamic or static. The pathname specified may be relative, although it cannot extend outside the current servlet context. If the path begins with a "/" it is interpreted as relative to the current context root. This method returns null if the servlet container cannot return a RequestDispatcher. The difference between this method and ServletContext.getRequestDispatcher(java.lang.String) is that this method can take a relative path.



getRequestURI
public String getRequestURI()(Code)
Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.



getRequestURL
public StringBuffer getRequestURL()(Code)
Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters. Because this method returns a StringBuffer, not a string, you can modify the URL easily, for example, to append query parameters. This method is useful for creating redirect messages and for reporting errors.
since:
   1.3



getRequestedSessionId
public String getRequestedSessionId()(Code)
Returns the session ID specified by the client. This may not be the same as the ID of the actual session in use. For example, if the request specified an old (expired) session ID and the server has started a new session, this method gets a new session with a new ID. If the request did not specify a session ID, this method returns null.



getScheme
public String getScheme()(Code)
Returns the name of the scheme used to make this request, for example, http, https, or ftp. Different schemes have different rules for constructing URLs, as noted in RFC 1738.



getServerName
public String getServerName()(Code)
Returns the host name of the server that received the request.



getServerPort
public int getServerPort()(Code)
Returns the port number on which this request was received.



getServletPath
public String getServletPath()(Code)
Returns the part of this request's URL that calls the servlet. This includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string.



getSession
public HttpSession getSession(boolean create)(Code)
Returns the current HttpSession associated with this request or, if there is no current session and create is true, returns a new session.
If create is false and the request has no valid HttpSession, this method returns null.



getSession
public HttpSession getSession()(Code)
Returns the current session associated with this request, or if the request does not have a session, creates one.



getUserPrincipal
public java.security.Principal getUserPrincipal()(Code)
Returns a java.security.Principal object containing the name of the current authenticated user. If the user has not been authenticated, the method returns null.



isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()(Code)
Checks whether the requested session ID came in as a cookie.



isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()(Code)
Checks whether the requested session ID came in as part of the request URL.



isRequestedSessionIdFromUrl
public boolean isRequestedSessionIdFromUrl()(Code)



isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()(Code)
Checks whether the requested session ID is still valid.



isSecure
public boolean isSecure()(Code)
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.



isUserInRole
public boolean isUserInRole(String role)(Code)
Returns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returns false.



readBasicAuthentication
void readBasicAuthentication()(Code)



readFormAuthentication
void readFormAuthentication()(Code)



recordAuthenticationInfo
void recordAuthenticationInfo(String userName, String[] roles)(Code)



removeAttribute
public void removeAttribute(String name)(Code)
Removes an attribute from this request. This method is not generally needed as attributes only persist as long as the request is being handled.



setAttribute
public void setAttribute(String key, Object o)(Code)
Stores an attribute in the context of this request. Attributes are reset between requests.



setCharacterEncoding
public void setCharacterEncoding(String charset) throws UnsupportedEncodingException(Code)
Overrides the name of the character encoding used in the body of this request. This method must be called prior to reading request parameters or reading input using getReader().
since:
   1.3



toArray
static String[] toArray(String roleList)(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.