public class ServletUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static org.slf4j.Logger |
logServerStartup |
| Constructor and Description |
|---|
ServletUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
formFilename(java.lang.String dirPath,
java.lang.String filePath)
Return the file path dealing with leading and trailing path
seperators (which must be a slash ("/")) for the given directory
and file paths.
|
static void |
forwardToCatalogServices(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Forward this request to the CatalogServices servlet ("/catalog.html").
|
static java.lang.String |
getParameterIgnoreCase(javax.servlet.http.HttpServletRequest req,
java.lang.String paramName)
Return the value of the given parameter for the given request.
|
static java.lang.String |
getReletiveURL(javax.servlet.http.HttpServletRequest req)
Return the request URL relative to the server (i.e., starting with the context path).
|
static java.lang.String |
getRequest(javax.servlet.http.HttpServletRequest req)
The entire request including query string
|
static java.lang.String |
getRequestBase(javax.servlet.http.HttpServletRequest req)
This is everything except the query string
|
static java.lang.String |
getRequestPath(javax.servlet.http.HttpServletRequest req)
servletPath + pathInfo
|
static java.lang.String |
getRequestServer(javax.servlet.http.HttpServletRequest req)
This is the server part, eg http://motherlode:8080
|
static java.net.URI |
getRequestURI(javax.servlet.http.HttpServletRequest req)
The request base as a URI
|
static void |
returnFile(javax.servlet.http.HttpServlet servlet,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.io.File file,
java.lang.String contentType)
Write a file to the response stream.
|
static void |
returnFile(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.io.File file,
java.lang.String contentType)
Write a file to the response stream.
|
static void |
returnFile(javax.servlet.http.HttpServlet servlet,
java.lang.String contentPath,
java.lang.String path,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String contentType)
Write a file to the response stream.
|
static void |
returnString(java.lang.String contents,
javax.servlet.http.HttpServletResponse res)
Send given content string as the HTTP response.
|
static int |
setResponseContentLength(javax.servlet.http.HttpServletResponse response,
java.lang.String s)
Set the proper content length for the string
|
static java.lang.String |
showRequestDetail(javax.servlet.http.HttpServletRequest req)
Show details about the request
|
static java.lang.String |
showRequestHeaders(javax.servlet.http.HttpServletRequest req) |
static java.lang.String |
showSecurity(javax.servlet.http.HttpServletRequest req,
java.lang.String role) |
static void |
showSession(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.io.PrintStream out) |
static void |
showSystemProperties(java.io.PrintStream out) |
static void |
showThreads(java.io.PrintStream pw) |
public static java.lang.String formFilename(java.lang.String dirPath,
java.lang.String filePath)
dirPath - the directory path.filePath - the file path.public static void returnFile(javax.servlet.http.HttpServlet servlet,
java.lang.String contentPath,
java.lang.String path,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String contentType)
throws java.io.IOException
servlet - called from this servlet, may be nullcontentPath - file root pathpath - file path reletive to the rootreq - the requestres - the responsecontentType - content type, or nulljava.io.IOException - on write errorpublic static void returnFile(javax.servlet.http.HttpServlet servlet,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.io.File file,
java.lang.String contentType)
throws java.io.IOException
servlet - called from this servlet, may be nullreq - the requestres - the responsefile - to servecontentType - content type, if null, will try to guessjava.io.IOException - on write errorpublic static void returnFile(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.io.File file,
java.lang.String contentType)
throws java.io.IOException
req - requestres - responsefile - must exist and not be a directorycontentType - must not be nulljava.io.IOException - or errorpublic static void returnString(java.lang.String contents,
javax.servlet.http.HttpServletResponse res)
throws java.io.IOException
contents - the string to return as the HTTP response.res - the HttpServletResponsejava.io.IOException - if an I/O error occurs while writing the response.public static int setResponseContentLength(javax.servlet.http.HttpServletResponse response,
java.lang.String s)
throws java.io.UnsupportedEncodingException
response - the HttpServletResponse to act upons - the string that will be returnedjava.io.UnsupportedEncodingException - on bad character encodingpublic static java.lang.String getReletiveURL(javax.servlet.http.HttpServletRequest req)
req - requestpublic static void forwardToCatalogServices(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws java.io.IOException,
javax.servlet.ServletException
req - requestres - responsejava.io.IOException - on IO errorjavax.servlet.ServletException - other errorpublic static void showSystemProperties(java.io.PrintStream out)
public static java.lang.String getRequestServer(javax.servlet.http.HttpServletRequest req)
req - the HttpServletRequestpublic static java.lang.String getRequestBase(javax.servlet.http.HttpServletRequest req)
req - the HttpServletRequestpublic static java.net.URI getRequestURI(javax.servlet.http.HttpServletRequest req)
req - the HttpServletRequestpublic static java.lang.String getRequestPath(javax.servlet.http.HttpServletRequest req)
req - the HttpServletRequestpublic static java.lang.String getRequest(javax.servlet.http.HttpServletRequest req)
req - the HttpServletRequestpublic static java.lang.String getParameterIgnoreCase(javax.servlet.http.HttpServletRequest req,
java.lang.String paramName)
req - the HttpServletRequestparamName - the name of the parameter to find.public static java.lang.String showRequestDetail(javax.servlet.http.HttpServletRequest req)
req - the requestpublic static java.lang.String showRequestHeaders(javax.servlet.http.HttpServletRequest req)
public static void showSession(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.io.PrintStream out)
public static java.lang.String showSecurity(javax.servlet.http.HttpServletRequest req,
java.lang.String role)
public static void showThreads(java.io.PrintStream pw)