public final class ServletHelper extends Object
| Constructor and Description |
|---|
ServletHelper() |
| Modifier and Type | Method and Description |
|---|---|
static Map<String,String> |
getParameters(javax.servlet.http.HttpServletRequest request)
Helps retrieve the parameters and its values as a Map
|
static void |
respondAsHtmlUsingArgsAndTemplateWithHttpStatus(javax.servlet.http.HttpServletResponse resp,
String resourcePageTemplate,
int statusCode,
Object... args)
Sends a HTTP response as a text/html document and with a HTTP status code.
|
static void |
respondAsHtmlUsingJsonAndTemplateWithHttpStatus(javax.servlet.http.HttpServletResponse resp,
Object response,
String resourcePageTemplate,
int statusCode)
Sends a HTTP response as a text/html document and with a HTTP status code.
|
static void |
respondAsHtmlUsingTemplate(javax.servlet.http.HttpServletResponse resp,
String resourcePageTemplate)
Sends a HTTP response as a text/html document.
|
static void |
respondAsHtmlUsingTemplateWithHttpStatus(javax.servlet.http.HttpServletResponse resp,
String resourcePageTemplate,
int statusCode)
Sends a HTTP response as a text/html document and with a HTTP status code.
|
static void |
respondAsHtmlWithMessage(javax.servlet.http.HttpServletResponse resp,
String message)
Utility method used to display a message when re-direction happens in the UI flow.
|
static void |
respondAsJsonWithHttpStatus(javax.servlet.http.HttpServletResponse resp,
Object response,
int statusCode)
Sends a HTTP response as a application/json document and with a HTTP status code.
|
public static Map<String,String> getParameters(javax.servlet.http.HttpServletRequest request)
request - A HttpServletRequest that represents the request from which the parameters and their
corresponding values are to be extracted.Map that represents the parameters and their valuespublic static void respondAsJsonWithHttpStatus(javax.servlet.http.HttpServletResponse resp,
Object response,
int statusCode)
throws IOException
resp - A HttpServletResponse object that the servlet is responding on.response - The response object which will be serialized to a JSON documentstatusCode - The HTTP status code to send with the responseIOExceptionpublic static void respondAsHtmlUsingJsonAndTemplateWithHttpStatus(javax.servlet.http.HttpServletResponse resp,
Object response,
String resourcePageTemplate,
int statusCode)
throws IOException
resp - A HttpServletResponse object that the servlet is responding on.response - The response object which will be serialized to a JSON document.resourcePageTemplate - The HTML template to use which is loaded as a classpath resource.statusCode - The HTTP status code to send with the response.IOExceptionpublic static void respondAsHtmlUsingArgsAndTemplateWithHttpStatus(javax.servlet.http.HttpServletResponse resp,
String resourcePageTemplate,
int statusCode,
Object... args)
throws IOException
resp - A HttpServletResponse object that the servlet is responding on.resourcePageTemplate - The HTML template to use which is loaded as a classpath resource.statusCode - The HTTP status code to send with the response.args - Data which will be inserted in to the template. Data must be typed in accordance with template
expectations -- all args are passed to String.formatIOExceptionpublic static void respondAsHtmlUsingTemplateWithHttpStatus(javax.servlet.http.HttpServletResponse resp,
String resourcePageTemplate,
int statusCode)
throws IOException
resp - A HttpServletResponse object that the servlet is responding on.resourcePageTemplate - The HTML template to use which is loaded as a classpath resource.statusCode - The HTTP status code to send with the response.IOExceptionpublic static void respondAsHtmlUsingTemplate(javax.servlet.http.HttpServletResponse resp,
String resourcePageTemplate)
throws IOException
resp - A HttpServletResponse object that the servlet is responding on.resourcePageTemplate - The HTML template to use which is loaded as a classpath resource.IOExceptionpublic static void respondAsHtmlWithMessage(javax.servlet.http.HttpServletResponse resp,
String message)
throws IOException
MESSAGE_RESOURCE_PAGE_FILEresp - A HttpServletResponse object that the servlet is responding on.message - Message to display.IOExceptionCopyright © 2016 PayPal Open Source. All rights reserved.