public class Https extends Servlets
Servlets.ClientIdentifier
APPEND_PARAM, IGNORE_PARAM, OVERWRITE_URI, PASS_THRU_ATTR
Constructor and Description |
---|
Https() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
encodeRedirectURL(javax.servlet.ServletContext ctx,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String uri,
java.util.Map params,
int mode)
Encodes an URL such that it can be used with HttpServletResponse.sendRedirect.
|
static java.lang.String |
getCompleteContext(javax.servlet.http.HttpServletRequest hreq)
Gets the complete context path, including protocol, server, ports, and
context.
|
static java.lang.String |
getCompleteServerName(javax.servlet.http.HttpServletRequest hreq)
Gets the complete server name, including protocol, server, and ports.
|
static java.lang.String |
getCookieValue(javax.servlet.http.HttpServletRequest request,
java.lang.String name)
Gets the value of the specified cookie, or null if not found.
|
static java.lang.String |
getOriginContextPath(javax.servlet.ServletRequest request)
Gets the original context path regardless of being forwarded or not.
|
static java.lang.String |
getOriginFullRequest(javax.servlet.ServletRequest request)
Returns the request uri + query string.
|
static java.lang.String |
getOriginFullServlet(javax.servlet.ServletRequest request)
Returns the servlet path + path info + query string.
|
static java.lang.String |
getOriginPathInfo(javax.servlet.ServletRequest request)
Gets the path info regardless of being forwarded or not.
|
static java.lang.String |
getOriginQueryString(javax.servlet.ServletRequest request)
Gets the query string regardless of being forwarded or not.
|
static java.lang.String |
getOriginRequestURI(javax.servlet.ServletRequest request)
Gets the request URI regardless of being forwarded or not.
|
static java.lang.String |
getOriginServletPath(javax.servlet.ServletRequest request)
Gets the original servlet path regardless of being forwarded or not.
|
static java.lang.String |
getServletURI(javax.servlet.http.HttpServletRequest request)
Returns the servlet uri of the request.
|
static java.lang.String |
getThisContextPath(javax.servlet.ServletRequest request)
Gets the context path of this page.
|
static java.lang.String |
getThisPathInfo(javax.servlet.ServletRequest request)
Gets the path info of this page.
|
static java.lang.String |
getThisQueryString(javax.servlet.ServletRequest request)
Gets the query string of this page.
|
static java.lang.String |
getThisRequestURI(javax.servlet.ServletRequest request)
Gets the request URI of this page.
|
static java.lang.String |
getThisServletPath(javax.servlet.ServletRequest request)
Gets the servlet path of this page.
|
static byte[] |
gzip(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.io.InputStream content1,
byte[] content2)
Compresses the content into an byte array, or null
if the browser doesn't support the compression (accept-encoding).
|
static void |
sendRedirect(javax.servlet.ServletContext ctx,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String uri,
java.util.Map params,
int mode)
Redirects to another URL by prefixing the context path and
encoding with encodeRedirectURL.
|
static java.util.Date |
toDate(java.lang.String sdate)
Converts a date string to a Date instance.
|
static java.lang.String |
toString(java.util.Date date)
Converts a data to a string complaint to HTTP protocol.
|
static void |
write(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Media media,
boolean download,
boolean repeatable)
Write the specified media to HTTP response.
|
addExtendletContext, forward, forward, generateURI, getBrowser, getBrowser, getBrowser, getBrowser, getClientIdentifier, getContextPaths, getDetail, getExtendletContext, getExtension, getExtension, getIECompatibilityInfo, getLimitTimeOffer, getNormalPath, getRequestDispatcher, getResource, getResourceAsStream, getUserAgent, include, include, isBrowser, isBrowser, isExplorer, isExplorer, isExplorer7, isExplorer7, isForwarded, isGecko, isGecko, isGecko3, isGecko3, isHilDevice, isHilDevice, isIncluded, isOfferExpired, isOpera, isOpera, isRobot, isRobot, isSafari, isSafari, isServlet23, isServlet24, isServlet3, isUniversalURL, locate, removeExtendletContext, setClientIdentifier
public static final byte[] gzip(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.io.InputStream content1, byte[] content2) throws java.io.IOException
content1
- the first part of the content to compress; null to ignore.
If you have multiple input streams, use java.io.SequenceInputStream
to concatenate themcontent2
- the second part of the content to compress; null to ignore.java.io.IOException
public static final java.lang.String getCompleteServerName(javax.servlet.http.HttpServletRequest hreq)
public static final java.lang.String getCompleteContext(javax.servlet.http.HttpServletRequest hreq)
public static final java.lang.String getCookieValue(javax.servlet.http.HttpServletRequest request, java.lang.String name)
name
- the cookie's namepublic static final java.lang.String getServletURI(javax.servlet.http.HttpServletRequest request)
However, HttpServletRequest.getRequestURI returns in encoded format, while this method returns in decode format (i.e., %nn is converted).
public static final java.lang.String getThisContextPath(javax.servlet.ServletRequest request)
public static final java.lang.String getThisServletPath(javax.servlet.ServletRequest request)
public static final java.lang.String getThisRequestURI(javax.servlet.ServletRequest request)
public static final java.lang.String getThisQueryString(javax.servlet.ServletRequest request)
public static final java.lang.String getThisPathInfo(javax.servlet.ServletRequest request)
public static final java.lang.String getOriginContextPath(javax.servlet.ServletRequest request)
public static final java.lang.String getOriginServletPath(javax.servlet.ServletRequest request)
public static final java.lang.String getOriginRequestURI(javax.servlet.ServletRequest request)
public static final java.lang.String getOriginPathInfo(javax.servlet.ServletRequest request)
public static final java.lang.String getOriginQueryString(javax.servlet.ServletRequest request)
public static final java.lang.String getOriginFullServlet(javax.servlet.ServletRequest request)
getOriginFullRequest(javax.servlet.ServletRequest)
is in
the encoded form.public static final java.lang.String getOriginFullRequest(javax.servlet.ServletRequest request)
getOriginFullServlet(javax.servlet.ServletRequest)
, this is in the encoded form
(e.g., %nn still exists, if any).
Note: request uri = context path + servlet path + path info.public static final void sendRedirect(javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String uri, java.util.Map params, int mode) throws java.io.IOException, javax.servlet.ServletException
It encodes the URI automatically (encodeRedirectURL).
Parameters are encoded by
Encodes.setToQueryString(StringBuffer,Map)
.
Like Encodes.encodeURL(javax.servlet.ServletContext, javax.servlet.ServletRequest, javax.servlet.ServletResponse, java.lang.String)
, the servlet context is
prefixed if uri starts with "/". In other words, to redirect other
application, the complete URL must be used, e.g., http://host/other.
Also, HttpServletResponse.encodeRedirectURL is called automatically.
request
- the request; used only if params is not nullresponse
- the responseuri
- the redirect uri (not encoded; not including context-path),
or null to denote getOriginFullServlet(javax.servlet.ServletRequest)
It is OK to relevant (without leading '/').
If starts with "/", the context path of request is assumed.
To reference to foreign context, use "~ctx/" where ctx is the
context path of the foreign context (without leading '/').
uri
could contain
'*' (to denote locale and browser). Refer to Servlets.locate(javax.servlet.ServletContext, javax.servlet.ServletRequest, java.lang.String, org.zkoss.util.resource.Locator)
.params
- the attributes that will be set when the redirection
is back; null to ignore; format: (String, Object)mode
- one of Servlets.OVERWRITE_URI
, Servlets.IGNORE_PARAM
,
and Servlets.APPEND_PARAM
. It defines how to handle if both uri
and params contains the same parameter.java.io.IOException
javax.servlet.ServletException
public static final java.lang.String encodeRedirectURL(javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String uri, java.util.Map params, int mode)
public static final java.util.Date toDate(java.lang.String sdate) throws java.text.ParseException
java.text.ParseException
- if the string is not validpublic static final java.lang.String toString(java.util.Date date)
public static void write(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Media media, boolean download, boolean repeatable) throws java.io.IOException
response
- the HTTP response to write tomedia
- the content to be writtendownload
- whether to cause the download to show at the client.
If true, it sets the Content-Disposition header.repeatable
- whether to use RepeatableInputStream
or RepeatableReader
to read the media.
It is better to specify true if the media might be read repeatedly.java.io.IOException
Copyright © 2005-2018 Potix Corporation. All Rights Reserved.