public class ServletUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static org.slf4j.Logger |
logServerStartup |
| Constructor and Description |
|---|
ServletUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
formFilename(String dirPath,
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 String |
getParameterIgnoreCase(javax.servlet.http.HttpServletRequest req,
String paramName)
Return the value of the given parameter for the given request.
|
static String |
getReletiveURL(javax.servlet.http.HttpServletRequest req)
Return the request URL relative to the server (i.e., starting with the context path).
|
static String |
getRequest(javax.servlet.http.HttpServletRequest req)
The entire request including query string
|
static String |
getRequestBase(javax.servlet.http.HttpServletRequest req)
This is everything except the query string
|
static String |
getRequestPath(javax.servlet.http.HttpServletRequest req)
servletPath + pathInfo
|
static String |
getRequestServer(javax.servlet.http.HttpServletRequest req)
This is the server part, eg http://motherlode:8080
|
static URI |
getRequestURI(javax.servlet.http.HttpServletRequest req)
The request base as a URI
|
static void |
returnFile(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
File file,
String contentType)
Write a file to the response stream.
|
static void |
returnString(String contents,
javax.servlet.http.HttpServletResponse res)
Send given content string as the HTTP response.
|
static int |
setResponseContentLength(javax.servlet.http.HttpServletResponse response,
String s)
Set the proper content length for the string
|
static String |
showRequestDetail(javax.servlet.http.HttpServletRequest req)
Show details about the request
|
static String |
showRequestHeaders(javax.servlet.http.HttpServletRequest req) |
static void |
showSystemProperties(PrintStream out) |
public static String formFilename(String dirPath, String filePath)
dirPath - the directory path.filePath - the file path.public static void returnFile(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
File file,
String contentType)
throws IOException
req - requestres - responsefile - must exist and not be a directorycontentType - must not be nullIOException - or errorpublic static void returnString(String contents, javax.servlet.http.HttpServletResponse res) throws IOException
contents - the string to return as the HTTP response.res - the HttpServletResponseIOException - if an I/O error occurs while writing the response.public static int setResponseContentLength(javax.servlet.http.HttpServletResponse response,
String s)
throws UnsupportedEncodingException
response - the HttpServletResponse to act upons - the string that will be returnedUnsupportedEncodingException - on bad character encodingpublic static String getReletiveURL(javax.servlet.http.HttpServletRequest req)
req - requestpublic static void forwardToCatalogServices(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws IOException,
javax.servlet.ServletException
req - requestres - responseIOException - on IO errorjavax.servlet.ServletException - other errorpublic static void showSystemProperties(PrintStream out)
public static String getRequestServer(javax.servlet.http.HttpServletRequest req)
req - the HttpServletRequestpublic static String getRequestBase(javax.servlet.http.HttpServletRequest req)
req - the HttpServletRequestpublic static URI getRequestURI(javax.servlet.http.HttpServletRequest req)
req - the HttpServletRequestpublic static String getRequestPath(javax.servlet.http.HttpServletRequest req)
req - the HttpServletRequestpublic static String getRequest(javax.servlet.http.HttpServletRequest req)
req - the HttpServletRequestpublic static String getParameterIgnoreCase(javax.servlet.http.HttpServletRequest req, String paramName)
req - the HttpServletRequestparamName - the name of the parameter to find.public static String showRequestDetail(javax.servlet.http.HttpServletRequest req)
req - the requestpublic static String showRequestHeaders(javax.servlet.http.HttpServletRequest req)