|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.cactus.ServletURL
Simulate an HTTP URL by breaking it into its different parts.
From the Servlet 2.2 specification :
URL = "http://" + serverName (including port) + requestURI ? queryString
requestURI = contextPath + servletPath + pathInfo
From the Servlet 2.3 specification :
| Field Summary | |
static java.lang.String |
PROTOCOL_HTTP
Http protocol. |
static java.lang.String |
PROTOCOL_HTTPS
Https protocol. |
static java.lang.String |
URL_CONTEXT_PATH_PARAM
Name of the parameter in the HTTP request that represents the context path in the URL to simulate. |
static java.lang.String |
URL_PATH_INFO_PARAM
Name of the parameter in the HTTP request that represents the Path Info in the URL to simulate. |
static java.lang.String |
URL_PROTOCOL_PARAM
Name of the parameter in the HTTP request that represents the protocol (HTTP, HTTPS, etc) in the URL to simulate. |
static java.lang.String |
URL_QUERY_STRING_PARAM
Name of the parameter in the HTTP request that represents the Query String in the URL to simulate. |
static java.lang.String |
URL_SERVER_NAME_PARAM
Name of the parameter in the HTTP request that represents the Server name (+ port) in the URL to simulate. |
static java.lang.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 | |
ServletURL()
Default constructor. |
|
ServletURL(java.lang.String theServerName,
java.lang.String theContextPath,
java.lang.String theServletPath,
java.lang.String thePathInfo,
java.lang.String theQueryString)
Creates the URL to simulate, using the default HTTP protocol. |
|
ServletURL(java.lang.String theProtocol,
java.lang.String theServerName,
java.lang.String theContextPath,
java.lang.String theServletPath,
java.lang.String thePathInfo,
java.lang.String theQueryString)
Creates the URL to simulate. |
|
| Method Summary | |
java.lang.String |
getContextPath()
|
java.lang.String |
getHost()
Returns the host name. |
java.lang.String |
getPath()
|
java.lang.String |
getPathInfo()
|
int |
getPort()
Returns the port. |
java.lang.String |
getProtocol()
|
java.lang.String |
getQueryString()
|
java.lang.String |
getServerName()
|
java.lang.String |
getServletPath()
|
static ServletURL |
loadFromRequest(javax.servlet.http.HttpServletRequest theRequest)
Creates a ServletURL object by loading it's values from the
HTTP request. |
void |
saveToRequest(WebRequest theRequest)
Saves the current URL to a WebRequest object. |
void |
setContextPath(java.lang.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(). |
void |
setPathInfo(java.lang.String thePathInfo)
Sets the path info in the URL to simulate, ie this is the name that will be returned by the HttpServletRequest.getPathInfo(). |
void |
setProtocol(java.lang.String theProtocol)
Sets the protocol to simulate (either ServletURL.PROTOCOL_HTTP or
ServletURL.PROTOCOL_HTTPS. |
void |
setQueryString(java.lang.String theQueryString)
Sets the Query string in the URL to simulate, ie this is the string that will be returned by the HttpServletResquest.getQueryString(). |
void |
setServerName(java.lang.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(). |
void |
setServletPath(java.lang.String theServletPath)
Sets the servlet path in the URL to simulate, ie this is the name that will be returned by the HttpServletRequest.getServletPath(). |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final java.lang.String URL_PROTOCOL_PARAM
public static final java.lang.String URL_SERVER_NAME_PARAM
public static final java.lang.String URL_CONTEXT_PATH_PARAM
public static final java.lang.String URL_SERVLET_PATH_PARAM
public static final java.lang.String URL_PATH_INFO_PARAM
public static final java.lang.String URL_QUERY_STRING_PARAM
public static final java.lang.String PROTOCOL_HTTP
public static final java.lang.String PROTOCOL_HTTPS
| Constructor Detail |
public ServletURL()
public ServletURL(java.lang.String theProtocol,
java.lang.String theServerName,
java.lang.String theContextPath,
java.lang.String theServletPath,
java.lang.String thePathInfo,
java.lang.String theQueryString)
theProtocol - the protocol to simulate (either
ServletURL.PROTOCOL_HTTP or
ServletURL.PROTOCOL_HTTPS.theServerName - the server name (and port) in the URL to simulate,
i.e. this is the name that will be returned by the
HttpServletRequest.getServerName() and
HttpServletRequest.getServerPort(). Can
be null. If null, then the server name and port from
the Servlet Redirector will be returned.theContextPath - the webapp context path in the URL to simulate,
i.e. this is the name that will be returned by the
HttpServletRequest.getContextPath().
Can be null. If null, then the context from the
Servlet Redirector will be used.
Format: "/" + name or an empty string for the
default context. Must not end with a "/" character.theServletPath - the servlet path in the URL to simulate,
i.e. this is the name that will be returned by the
HttpServletRequest.getServletPath().
Can be null. If null, then the servlet path from
the Servlet Redirector will be used.
Format : "/" + name or an empty string.thePathInfo - the path info in the URL to simulate, i.e. this is
the name that will be returned by the
HttpServletRequest.getPathInfo(). Can
be null. Format : "/" + name.theQueryString - the Query string in the URL to simulate, i.e. this
is the string that will be returned by the
HttpServletResquest.getQueryString().
Can be null.
public ServletURL(java.lang.String theServerName,
java.lang.String theContextPath,
java.lang.String theServletPath,
java.lang.String thePathInfo,
java.lang.String theQueryString)
theServerName - the server name (and port) in the URL to simulate,
i.e. this is the name that will be returned by the
HttpServletRequest.getServerName() and
HttpServletRequest.getServerPort(). Can
be null. If null, then the server name and port from
the Servlet Redirector will be returned.theContextPath - the webapp context path in the URL to simulate,
i.e. this is the name that will be returned by the
HttpServletRequest.getContextPath().
Can be null. If null, then the context from the
Servlet Redirector will be used.
Format: "/" + name or an empty string for the
default context. Must not end with a "/" character.theServletPath - the servlet path in the URL to simulate,
i.e. this is the name that will be returned by the
HttpServletRequest.getServletPath().
Can be null. If null, then the servlet path from
the Servlet Redirector will be used.
Format : "/" + name or an empty string.thePathInfo - the path info in the URL to simulate, i.e. this is
the name that will be returned by the
HttpServletRequest.getPathInfo(). Can
be null. Format : "/" + name.theQueryString - the Query string in the URL to simulate, i.e. this
is the string that will be returned by the
HttpServletResquest.getQueryString().
Can be null.| Method Detail |
public java.lang.String getProtocol()
public void setProtocol(java.lang.String theProtocol)
ServletURL.PROTOCOL_HTTP or
ServletURL.PROTOCOL_HTTPS. If parameter is null then
PROTOCOL_HTTP is assumed.
theProtocol - the protocol to simulatepublic java.lang.String getServerName()
public void setServerName(java.lang.String theServerName)
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.
theServerName - the server name and port (ex:
"jakarta.apache.org:80")public java.lang.String getHost()
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.
public int getPort()
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.
public java.lang.String getContextPath()
public void setContextPath(java.lang.String theContextPath)
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 "/".
theContextPath - the context path to simulatepublic java.lang.String getServletPath()
public void setServletPath(java.lang.String theServletPath)
HttpServletRequest.getServletPath().
If null then the servlet path from the Servlet Redirector will be
returned. Format : "/" + name or an empty string.
theServletPath - the servlet path to simulatepublic java.lang.String getPathInfo()
public void setPathInfo(java.lang.String thePathInfo)
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.
thePathInfo - the path info to simulatepublic java.lang.String getQueryString()
public void setQueryString(java.lang.String theQueryString)
HttpServletResquest.getQueryString(). If not set, the
query string from the Servlet Redirector will be returned.
theQueryString - the query string to simulatepublic java.lang.String getPath()
public void saveToRequest(WebRequest theRequest)
WebRequest object.
theRequest - the object to which the current URL should be saved topublic static ServletURL loadFromRequest(javax.servlet.http.HttpServletRequest theRequest)
ServletURL object by loading it's values from the
HTTP request.
theRequest - the incoming HTTP request.
ServletURL object unserialized from the HTTP
requestpublic java.lang.String toString()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||