|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensubsystems.core.www.WebUtils
public final class WebUtils
Collection of useful methods for Web environment.
| Field Summary | |
|---|---|
protected static int |
s_iConfiguredWebPort
HTTP server port the web application was originally configred to run on. |
protected static int |
s_iConfiguredWebPortSecure
HTTP server port the web application was originally configred to accept SSL requests. |
protected static int |
s_iWebFileBufferSize
Size of the buffer used to send files. |
protected static int |
s_iWebPort
HTTP server port the web application is running on. |
protected static int |
s_iWebPortSecure
HTTPS server port the web application is running on (SSL port). |
static int |
WEBFILE_BUFFER_DEFAULT_SIZE
Default value for the WEBUTILS_WEBFILE_BUFFER_SIZE. |
static java.lang.String |
WEBSERVER_PORT
Name of the property specifying what port the embedded web server should start on. |
static java.lang.String |
WEBSERVER_PORT_SECURE
Name of the property specifying what port sthe embedded web server should accepts SSL requests. |
static java.lang.String |
WEBUTILS_WEBFILE_BUFFER_SIZE
Name of the property for size of the buffer used to serve files. |
| Method Summary | |
|---|---|
static void |
adjust(javax.servlet.http.HttpServletRequest hsrqRequest)
Adjust non secure server port number the web application is currently running on. |
static java.lang.String |
debug(javax.servlet.http.HttpServletRequest hsrqRequest)
Create debug string containing all parameter names and their values from the request. |
static java.lang.String |
debug(javax.servlet.ServletConfig scConfig)
Create debug string containing all parameter names and their values from the config. |
static java.lang.String |
debug(javax.servlet.ServletContext scContext)
Create debug string containing all parameter names and their values from the context. |
static java.lang.String |
encode(java.lang.String strInput)
Encode URL string by method URLEncoder.encode() - after this encoding all spaces will be encoded as + character. |
static void |
forwardToOrigin(javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
Forward request back to the same page where it came from. |
static int |
getActualPort()
Get value of port, which actually accepts non SSL requests on. |
static int |
getActualSSLPort()
Get value of port, which was configured to accepts SSL requests on. |
static int |
getConfiguredPort()
Get value of port, which was configured to accepts non SSL requests on. |
static int |
getConfiguredSSLPort()
Get value of port, which was configured to accepts SSL requests on. |
static java.lang.String |
getFullRequestPath(javax.servlet.http.HttpServletRequest hsrqRequest)
Get full path from HTTP request consisting of the servlet path and the path info |
static java.lang.String |
getFullRequestURL(javax.servlet.http.HttpServletRequest hsrqRequest)
Reconstruct full URL from HTTP request with protocol, full path and query strings. |
static java.lang.String |
getRequestURLWithoutQuery(javax.servlet.http.HttpServletRequest hsrqRequest)
Reconstruct full URL from HTTP request with protocol, full path but without query strings. |
static boolean |
isIndexPage(javax.servlet.http.HttpServletRequest hsrqRequest)
Test if the requested path is path for the index page. |
static boolean |
isMainIndexPage(javax.servlet.http.HttpServletRequest hsrqRequest)
Test if the real path is path for the main index page. |
static boolean |
isStaticWebPage(javax.servlet.http.HttpServletRequest hsrqRequest)
Test if the requested path is path for the regular (.html) page. |
static java.lang.String |
readProperty(javax.servlet.ServletConfig scConfig,
java.lang.String strPropertyName,
java.lang.String strDefaultValue,
boolean bEmptyAllowed)
Read property from from different configuration locations. |
static java.lang.String |
readProperty(javax.servlet.ServletContext scContext,
java.lang.String strPropertyName,
java.lang.String strDefaultValue,
boolean bEmptyAllowed)
Read property from from different configuration locations. |
static void |
serveFile(javax.servlet.http.HttpServletResponse hsrpResponse,
java.lang.String strRealPath)
Serve files to the Internet. |
static java.lang.String |
toggleSecure(javax.servlet.http.HttpServletRequest hsrqRequest,
java.lang.String strURL,
boolean bIsSecure)
Switch URL to HTTP or HTTPS and also particular ports. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String WEBSERVER_PORT
s_iConfiguredWebPort,
Constant Field Valuespublic static final java.lang.String WEBSERVER_PORT_SECURE
s_iConfiguredWebPortSecure,
Constant Field Valuespublic static final java.lang.String WEBUTILS_WEBFILE_BUFFER_SIZE
s_iWebFileBufferSize,
WEBFILE_BUFFER_DEFAULT_SIZE,
Constant Field Valuespublic static final int WEBFILE_BUFFER_DEFAULT_SIZE
s_iWebFileBufferSize,
WEBUTILS_WEBFILE_BUFFER_SIZE,
Constant Field Valuesprotected static int s_iWebFileBufferSize
WEBUTILS_WEBFILE_BUFFER_SIZE,
WEBFILE_BUFFER_DEFAULT_SIZEprotected static int s_iConfiguredWebPort
protected static int s_iWebPort
protected static int s_iConfiguredWebPortSecure
protected static int s_iWebPortSecure
| Method Detail |
|---|
public static int getConfiguredPort()
public static int getActualPort()
public static int getConfiguredSSLPort()
public static int getActualSSLPort()
public static void serveFile(javax.servlet.http.HttpServletResponse hsrpResponse,
java.lang.String strRealPath)
throws java.io.IOException
hsrpResponse - - the servlet response.strRealPath - - real path to the file to server
java.io.IOException - - an error has occured while accessing the file or writing responsepublic static java.lang.String getFullRequestURL(javax.servlet.http.HttpServletRequest hsrqRequest)
hsrqRequest - - the servlet request.
public static java.lang.String getRequestURLWithoutQuery(javax.servlet.http.HttpServletRequest hsrqRequest)
hsrqRequest - - the servlet request.
public static java.lang.String getFullRequestPath(javax.servlet.http.HttpServletRequest hsrqRequest)
hsrqRequest - - the servlet request
public static void adjust(javax.servlet.http.HttpServletRequest hsrqRequest)
hsrqRequest - - the servlet request.
public static java.lang.String toggleSecure(javax.servlet.http.HttpServletRequest hsrqRequest,
java.lang.String strURL,
boolean bIsSecure)
hsrqRequest - - the servlet requeststrURL - - relative URLbIsSecure - - flag signaling if url should be switched to secure
- true = switch to secure (use HTTPS)
- false = switch to unsecure (use HTTP)
public static java.lang.String debug(javax.servlet.http.HttpServletRequest hsrqRequest)
hsrqRequest - - the servlet request.
public static java.lang.String debug(javax.servlet.ServletConfig scConfig)
scConfig - - config to print out
public static java.lang.String debug(javax.servlet.ServletContext scContext)
scContext - - context to print out
public static void forwardToOrigin(javax.servlet.http.HttpServletRequest hsrqRequest,
javax.servlet.http.HttpServletResponse hsrpResponse)
throws java.io.IOException,
javax.servlet.ServletException
hsrqRequest - - the servlet request.hsrpResponse - - the servlet response.
java.io.IOException - - an error while writing response
javax.servlet.ServletException - - an error while serving the requestpublic static boolean isMainIndexPage(javax.servlet.http.HttpServletRequest hsrqRequest)
hsrqRequest - - the servlet request.
public static boolean isIndexPage(javax.servlet.http.HttpServletRequest hsrqRequest)
hsrqRequest - - the servlet request.
public static boolean isStaticWebPage(javax.servlet.http.HttpServletRequest hsrqRequest)
hsrqRequest - - the servlet request.
public static java.lang.String readProperty(javax.servlet.ServletConfig scConfig,
java.lang.String strPropertyName,
java.lang.String strDefaultValue,
boolean bEmptyAllowed)
scConfig - - servlet config to search (application configuration file
is known by other mean)strPropertyName - - name of the property to readstrDefaultValue - - default value of the property returned in case
the value is not found, null is allowsbEmptyAllowed - - is empty string valid value of the property
public static java.lang.String readProperty(javax.servlet.ServletContext scContext,
java.lang.String strPropertyName,
java.lang.String strDefaultValue,
boolean bEmptyAllowed)
scContext - - servlet context to search (application configuration file
is known by other mean)strPropertyName - - name of the property to readstrDefaultValue - - default value of the property returned in case
the value is not found, null is allowsbEmptyAllowed - - is empty string valid value of the property
public static java.lang.String encode(java.lang.String strInput)
throws java.io.UnsupportedEncodingException
strInput - - input string that has to be encoded
java.io.UnsupportedEncodingException - - error while encode process
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||