| java.lang.Object org.apache.cactus.ServletURL
ServletURL | public class ServletURL (Code) | | Simulate an HTTP URL by breaking it into its different parts.
URL = "http://" + serverName (including port) + requestURI ? queryString
requestURI = contextPath + servletPath + pathInfo
From the Servlet 2.2 specification :
- Context Path: The path prefix associated with the
ServletContext that this servlet is a part of. If this context is the
default context rooted at the base of the web server's URL namespace, this
path will be an empty string. Otherwise, this path starts with a "/"
character but does not end with a "/" character.
- Servlet Path: The path section that directly corresponds to the
mapping which activated this request. This path starts with a "/"
character.
- PathInfo: The part of the request path that is not part of the
Context Path or the Servlet Path.
From the Servlet 2.3 specification :
- Context Path: The path prefix associated with the
ServletContext that this servlet is a part of. If this context is the
default context rooted at the base of the web server's URL namespace, this
path will be an empty string. Otherwise, this path starts with a "/"
character but does not end with a "/" character.
- Servlet Path: The path section that directly corresponds to the
mapping which activated this request. This path starts with a "/"
character except in the case where the request is matched with the
"/*" pattern, in which case it is the empty string.
- PathInfo: The part of the request path that is not part of the
Context Path or the Servlet Path. It is either null if there is no
extra path, or is a string with a leading "/".
version: $Id: ServletURL.java 238991 2004-05-22 11:34:50Z vmassol $ |
Field Summary | |
final public static String | PROTOCOL_HTTP Http protocol. | final public static String | PROTOCOL_HTTPS Https protocol. | final public static String | URL_CONTEXT_PATH_PARAM Name of the parameter in the HTTP request that represents the context
path in the URL to simulate. | final public static String | URL_PATH_INFO_PARAM Name of the parameter in the HTTP request that represents the Path Info
in the URL to simulate. | final public static String | URL_PROTOCOL_PARAM Name of the parameter in the HTTP request that represents the protocol
(HTTP, HTTPS, etc) in the URL to simulate. | final public static String | URL_QUERY_STRING_PARAM Name of the parameter in the HTTP request that represents the Query
String in the URL to simulate. | final public static String | URL_SERVER_NAME_PARAM Name of the parameter in the HTTP request that represents the Server
name (+ port) in the URL to simulate. | final public static String | URL_SERVLET_PATH_PARAM Name of the parameter in the HTTP request that represents the Servlet
Path in the URL to simulate. |
Constructor Summary | |
public | ServletURL() Default constructor. | public | ServletURL(String theProtocol, String theServerName, String theContextPath, String theServletPath, String thePathInfo, String theQueryString) Creates the URL to simulate.
Parameters: theProtocol - the protocol to simulate (eitherServletURL.PROTOCOL_HTTP orServletURL.PROTOCOL_HTTPS . Parameters: theServerName - the server name (and port) in the URL to simulate,i.e. | public | ServletURL(String theServerName, String theContextPath, String theServletPath, String thePathInfo, String theQueryString) Creates the URL to simulate, using the default HTTP protocol.
Parameters: theServerName - the server name (and port) in the URL to simulate,i.e. |
Method Summary | |
public String | getContextPath() | public String | getHost() Returns the host name.
The host name is extracted from the specified server name (as in
jakarta.apache.org:80 ). | public String | getPath() | public String | getPathInfo() | public int | getPort() Returns the port.
The port is extracted from the specified server name (as in
jakarta.apache.org:80 ). | public String | getProtocol() | public String | getQueryString() | public String | getServerName() | public String | getServletPath() | public static ServletURL | loadFromRequest(HttpServletRequest theRequest) Creates a ServletURL object by loading it's values from the
HTTP request.
Parameters: theRequest - the incoming HTTP request. | public void | saveToRequest(WebRequest theRequest) Saves the current URL to a WebRequest object. | public void | setContextPath(String theContextPath) Sets the webapp context path in the URL to simulate, ie this is the
name that will be returned by the
HttpServletRequest.getContextPath() . | public void | setPathInfo(String thePathInfo) Sets the path info in the URL to simulate, ie this is the name that will
be returned by the HttpServletRequest.getPathInfo() . | public void | setProtocol(String theProtocol) Sets the protocol to simulate (either
ServletURL.PROTOCOL_HTTP or
ServletURL.PROTOCOL_HTTPS . | public void | setQueryString(String theQueryString) Sets the Query string in the URL to simulate, ie this is the string that
will be returned by the
HttpServletResquest.getQueryString() . | public void | setServerName(String theServerName) Sets the server name (and port) in the URL to simulate, ie this is the
name that will be returned by the
HttpServletRequest.getServerName() and
HttpServletRequest.getServerPort() . | public void | setServletPath(String theServletPath) Sets the servlet path in the URL to simulate, ie this is the name that
will be returned by the HttpServletRequest.getServletPath() .
If null then the servlet path from the Servlet Redirector will be
returned. | public String | toString() |
PROTOCOL_HTTP | final public static String PROTOCOL_HTTP(Code) | | Http protocol.
|
PROTOCOL_HTTPS | final public static String PROTOCOL_HTTPS(Code) | | Https protocol.
|
URL_CONTEXT_PATH_PARAM | final public static String URL_CONTEXT_PATH_PARAM(Code) | | Name of the parameter in the HTTP request that represents the context
path in the URL to simulate. The name is voluntarily long so that it
will not clash with a user-defined parameter.
|
URL_PATH_INFO_PARAM | final public static String URL_PATH_INFO_PARAM(Code) | | Name of the parameter in the HTTP request that represents the Path Info
in the URL to simulate. The name is voluntarily long so that it will not
clash with a user-defined parameter.
|
URL_PROTOCOL_PARAM | final public static String URL_PROTOCOL_PARAM(Code) | | Name of the parameter in the HTTP request that represents the protocol
(HTTP, HTTPS, etc) in the URL to simulate. The name is voluntarily long
so that it will not clash with a user-defined parameter.
|
URL_QUERY_STRING_PARAM | final public static String URL_QUERY_STRING_PARAM(Code) | | Name of the parameter in the HTTP request that represents the Query
String in the URL to simulate. The name is voluntarily long so that it
will not clash with a user-defined parameter.
|
URL_SERVER_NAME_PARAM | final public static String URL_SERVER_NAME_PARAM(Code) | | Name of the parameter in the HTTP request that represents the Server
name (+ port) in the URL to simulate. The name is voluntarily long so
that it will not clash with a user-defined parameter.
|
URL_SERVLET_PATH_PARAM | final public static String URL_SERVLET_PATH_PARAM(Code) | | Name of the parameter in the HTTP request that represents the Servlet
Path in the URL to simulate. The name is voluntarily long so that it
will not clash with a user-defined parameter.
|
ServletURL | public ServletURL()(Code) | | Default constructor. Need to call the different setters to make this
a valid object.
|
ServletURL | public ServletURL(String theProtocol, String theServerName, String theContextPath, String theServletPath, String thePathInfo, String theQueryString)(Code) | | Creates the URL to simulate.
Parameters: theProtocol - the protocol to simulate (eitherServletURL.PROTOCOL_HTTP orServletURL.PROTOCOL_HTTPS . Parameters: theServerName - the server name (and port) in the URL to simulate,i.e. this is the name that will be returned by theHttpServletRequest.getServerName() andHttpServletRequest.getServerPort() . Canbe null. If null, then the server name and port fromthe Servlet Redirector will be returned. Parameters: theContextPath - the webapp context path in the URL to simulate,i.e. this is the name that will be returned by theHttpServletRequest.getContextPath() .Can be null. If null, then the context from theServlet Redirector will be used.Format: "/" + name or an empty string for the default context. Must not end with a "/" character. Parameters: theServletPath - the servlet path in the URL to simulate,i.e. this is the name that will be returned by theHttpServletRequest.getServletPath() .Can be null. If null, then the servlet path from the Servlet Redirector will be used.Format : "/" + name or an empty string. Parameters: thePathInfo - the path info in the URL to simulate, i.e. this isthe name that will be returned by theHttpServletRequest.getPathInfo() . Canbe null. Format : "/" + name. Parameters: theQueryString - the Query string in the URL to simulate, i.e. thisis the string that will be returned by theHttpServletResquest.getQueryString() .Can be null. |
ServletURL | public ServletURL(String theServerName, String theContextPath, String theServletPath, String thePathInfo, String theQueryString)(Code) | | Creates the URL to simulate, using the default HTTP protocol.
Parameters: theServerName - the server name (and port) in the URL to simulate,i.e. this is the name that will be returned by theHttpServletRequest.getServerName() andHttpServletRequest.getServerPort() . Canbe null. If null, then the server name and port fromthe Servlet Redirector will be returned. Parameters: theContextPath - the webapp context path in the URL to simulate,i.e. this is the name that will be returned by theHttpServletRequest.getContextPath() .Can be null. If null, then the context from theServlet Redirector will be used.Format: "/" + name or an empty string for the default context. Must not end with a "/" character. Parameters: theServletPath - the servlet path in the URL to simulate,i.e. this is the name that will be returned by theHttpServletRequest.getServletPath() .Can be null. If null, then the servlet path from the Servlet Redirector will be used.Format : "/" + name or an empty string. Parameters: thePathInfo - the path info in the URL to simulate, i.e. this isthe name that will be returned by theHttpServletRequest.getPathInfo() . Canbe null. Format : "/" + name. Parameters: theQueryString - the Query string in the URL to simulate, i.e. thisis the string that will be returned by theHttpServletResquest.getQueryString() .Can be null. |
getContextPath | public String getContextPath()(Code) | | the simulated URL context path |
getHost | public String getHost()(Code) | | Returns the host name.
The host name is extracted from the specified server name (as in
jakarta.apache.org:80 ). If the server
name has not been set, this method will return null .
the simulated URL server name (excluding the port number) |
getPath | public String getPath()(Code) | | the path (contextPath + servletPath + pathInfo) or null ifnot set |
getPathInfo | public String getPathInfo()(Code) | | the simulated URL path info |
getPort | public int getPort()(Code) | | Returns the port.
The port is extracted from the specified server name (as in
jakarta.apache.org:80 ). If the server
name doesn't contain a port number, the default port number is returned
(80 for HTTP, 443 for HTTP over SSL). If a port number is specified but
illegal, or the server name has not been set, this method will return
-1.
the simulated port number or -1 if an illegal port has beenspecified |
getProtocol | public String getProtocol()(Code) | | the protocol used to connect to the URL (HTTP, HTTPS, etc). |
getQueryString | public String getQueryString()(Code) | | the simulated Query String |
getServerName | public String getServerName()(Code) | | the simulated URL server name (including the port number) |
getServletPath | public String getServletPath()(Code) | | the simulated URL servlet path |
loadFromRequest | public static ServletURL loadFromRequest(HttpServletRequest theRequest)(Code) | | Creates a ServletURL object by loading it's values from the
HTTP request.
Parameters: theRequest - the incoming HTTP request. the ServletURL object unserialized from the HTTPrequest |
saveToRequest | public void saveToRequest(WebRequest theRequest)(Code) | | Saves the current URL to a WebRequest object.
Parameters: theRequest - the object to which the current URL should be saved to |
setContextPath | public void setContextPath(String theContextPath)(Code) | | Sets the webapp context path in the URL to simulate, ie this is the
name that will be returned by the
HttpServletRequest.getContextPath() . If not set, the
context from the Servlet Redirector will be returned. Format: "/" +
name or an empty string for the default context. If not an empty
string the last character must not be "/".
Parameters: theContextPath - the context path to simulate |
setPathInfo | public void setPathInfo(String thePathInfo)(Code) | | Sets the path info in the URL to simulate, ie this is the name that will
be returned by the HttpServletRequest.getPathInfo() .
If null then no path info will be set (and the Path Info from the
Servlet Redirector will not be used).
Format : "/" + name.
Parameters: thePathInfo - the path info to simulate |
setProtocol | public void setProtocol(String theProtocol)(Code) | | Sets the protocol to simulate (either
ServletURL.PROTOCOL_HTTP or
ServletURL.PROTOCOL_HTTPS . If parameter is null then
PROTOCOL_HTTP is assumed.
Parameters: theProtocol - the protocol to simulate |
setQueryString | public void setQueryString(String theQueryString)(Code) | | Sets the Query string in the URL to simulate, ie this is the string that
will be returned by the
HttpServletResquest.getQueryString() . If not set, the
query string from the Servlet Redirector will be returned.
Parameters: theQueryString - the query string to simulate |
setServerName | public void setServerName(String theServerName)(Code) | | Sets the server name (and port) in the URL to simulate, ie this is the
name that will be returned by the
HttpServletRequest.getServerName() and
HttpServletRequest.getServerPort() . Does not need to be
set. If not set or null, then the server name and port from the Servlet
Redirector will be returned.
Parameters: theServerName - the server name and port (ex:"jakarta.apache.org:80") |
setServletPath | public void setServletPath(String theServletPath)(Code) | | Sets the servlet path in the URL to simulate, ie this is the name that
will be returned by the HttpServletRequest.getServletPath() .
If null then the servlet path from the Servlet Redirector will be
returned. Format : "/" + name or an empty string.
Parameters: theServletPath - the servlet path to simulate |
toString | public String toString()(Code) | | a string representation |
|
|