Interface ServletRequest
- All Known Subinterfaces:
HttpServletRequest
public interface ServletRequest
Whenever the server receives a request it creates a ServletRequest object,
puts all the request information in it and passes this along with
a ServletResponse object to the approriate servlet.
- Since:
- Servlet API 1.0
- Version:
- Servlet API 2.2
-
Method Summary
Modifier and TypeMethodDescriptiongetAttribute(String name) Gets a named attribute's value.Gets an Enumeration of all the attribute names.Gets the character encoding of the request data.intGets the size in bytes of the requestGets the mime type of the requestCreates an inputstream for servlets to read client request data from.XXXXXXgetParameter(String name) Gets the value of a named requestparameter.Gets all parameter names.String[]getParameterValues(String name) Gets an array of Strings containing all the request parameter's values whose name matchesname.Gets the protocol of the request as Proto/Major.Minor ("HTTP/1.1").Creates an BufferedReader for servlets to read client request data from.getRealPath(String path) Deprecated.Should use getRealPath from the current ServletContext.Gets the ip address of the client that sent the requestGets the hostname of the client that sent the request.getRequestDispatcher(String path) XXXGets the scheme of the request as defined by RFC 1783 ("ftp", "http", "gopher", "news").Get the name of the server receiving the requestintGets the portnumber the server reveiving the request is running on.booleanisSecure()XXXvoidremoveAttribute(String name) XXXvoidsetAttribute(String name, Object o) Puts a named object into theServletRequest.
-
Method Details
-
getContentLength
int getContentLength()Gets the size in bytes of the request- Returns:
- the number of bytes in the request or -1 if not known
- Since:
- Servlet API 1.0
-
getContentType
String getContentType()Gets the mime type of the request- Returns:
- a String containing the mime type of the request or null if not known
- Since:
- Servlet API 1.0
-
getProtocol
String getProtocol()Gets the protocol of the request as Proto/Major.Minor ("HTTP/1.1").- Returns:
- A string containing the protocol name
- Since:
- Servlet API 1.0
-
getScheme
String getScheme()Gets the scheme of the request as defined by RFC 1783 ("ftp", "http", "gopher", "news").- Returns:
- A String containing the scheme
- Since:
- Servlet API 1.0
-
getServerName
String getServerName()Get the name of the server receiving the request- Returns:
- The name of the server.
- Since:
- Servlet API 1.0
-
getServerPort
int getServerPort()Gets the portnumber the server reveiving the request is running on.- Returns:
- the portnumber
- Since:
- Servlet API 1.0
-
getRemoteAddr
String getRemoteAddr()Gets the ip address of the client that sent the request- Returns:
- the client's ip address
- Since:
- Servlet API 1.0
-
getRemoteHost
String getRemoteHost()Gets the hostname of the client that sent the request. This is either a fully qualified host name or a string representing the remote IP address.- Returns:
- the client's hostname
- Since:
- Servlet API 1.0
-
getRealPath
Deprecated.Should use getRealPath from the current ServletContext.Translates the given path to the real path on the servers filesystem, using the servers documentroot.- Parameters:
path- the path which requires translating- Returns:
- the translated path
- Since:
- Servlet API 1.0
- See Also:
-
getInputStream
Creates an inputstream for servlets to read client request data from.- Returns:
- The created InputStreams
- Throws:
IOException- if an i/o related error occuredIllegalStateException- ifgetReaderwas already called on this request.- Since:
- Servlet API 1.0
- See Also:
-
getParameter
Gets the value of a named requestparameter. If the parameter can have more than one valuegetParameterValuesshould be used. If there are more than one values associated with the parameter this method will only return the first value as return bygetParameterValuesis returned. see javax.servlet.ServletRequest.getParameterValues()- Parameters:
name- the name of the parameter whose value we want- Returns:
- the (first) value of the parameter or null if not present
- Since:
- Servlet API 1.0
-
getParameterValues
-
getParameterNames
Enumeration getParameterNames()Gets all parameter names.Note that the Servlet API 2.1 documentation says that this returns an empty Enumeration if the input stream is empty, but this is not mandated by the Servlet Spec.
- Returns:
- an enumeration containing all parameter names
- Since:
- Servlet API 1.0
-
getAttribute
Gets a named attribute's value. This gives one of the initialization attribute values.Note that the Servlet 2.1 API Documentation mentions some predefined attribute names, but the Servlet Spec does not mention them. I (MJW) am not sure if they are platform specific (JWS) or not.
- Returns:
- The value of the attribute, null if not found.
- Since:
- Servlet API 1.0
-
setAttribute
Puts a named object into theServletRequest. Can be used to communicate with other servlets if thisServletRequestis passed to another servlet through aRequestDispatcher. The names used must follow the conventions used for naming java packages.- Parameters:
name- - which is used to refer to this objectobject- - which should be returned when somebody callsgetAttribute(name)- Since:
- Servlet API 2.1
- See Also:
-
getAttributeNames
Enumeration getAttributeNames()Gets an Enumeration of all the attribute names.- Returns:
- The Enumeration of all attribute names set in this request.
- Since:
- Servlet API 2.1
-
removeAttribute
XXX -
getLocale
Locale getLocale()XXX -
getLocales
Enumeration getLocales()XXX -
getReader
Creates an BufferedReader for servlets to read client request data from.- Returns:
- The created BufferedReader
- Throws:
IOException- if an i/o related error occuredIllegalStateException- ifgetInputStreamwas already called on this request.- Since:
- Servlet API 2.0
- See Also:
-
getCharacterEncoding
String getCharacterEncoding()Gets the character encoding of the request data.- Returns:
- Character encoding or null if the encoding is unavailable
- Since:
- Servlet API 2.0
-
isSecure
boolean isSecure()XXX -
getRequestDispatcher
XXX
-