public class HttpSupport extends Object
Modifier and Type | Class and Description |
---|---|
class |
HttpSupport.HttpBuilder |
class |
HttpSupport.RenderBuilder |
Constructor and Description |
---|
HttpSupport() |
Modifier and Type | Method and Description |
---|---|
protected AppContext |
appContext()
Returns instance of
AppContext . |
protected void |
assign(String name,
Object value)
Assigns a value for a view.
|
protected boolean |
blank(String... names)
Returns true if any named request parameter is blank.
|
protected String |
context()
Provides a context of the request - usually an app name (as seen on URL of request).
|
Cookie |
cookie(String name)
Returns a cookie by name, null if not found.
|
List<Cookie> |
cookies()
Returns collection of all cookies browser sent.
|
protected String |
cookieValue(String name)
Convenience method, returns cookie value.
|
protected void |
encoding(String encoding)
Synonym for
setEncoding(String) |
protected boolean |
exists(String name)
Tests if a request parameter exists.
|
protected void |
flash(Map values)
Flash method to display multiple flash messages.
|
protected void |
flash(Object... values)
Flash method to display multiple flash messages.
|
protected void |
flash(String name)
Sets a flash name for a flash with a body.
|
protected void |
flash(String name,
Object value)
Sends value to flash.
|
protected String |
format()
Returns a format part of the URI, or null if URI does not have a format part.
|
protected String |
getEncoding()
Controllers can override this method to return encoding they require.
|
protected FileItem |
getFile(String fieldName,
List<FormItem> formItems)
Convenience method to get file content from
multipart/form-data request. |
protected javax.servlet.http.HttpServletRequest |
getHttpServletRequest()
Direct access to current
HttpServletRequest for low level operations. |
protected javax.servlet.http.HttpServletResponse |
getHttpServletResponse()
Direct access to current
HttpServletResponse for low level operations. |
protected String |
getId()
Returns value of ID if one is present on a URL.
|
protected Locale |
getLocale()
Same as
locale() . |
Map<String,String> |
getMap(String hashName)
Returns a map parsed from a request if parameter names have a "hash" syntax:
|
Map<String,String> |
getMap(String hashName,
List<FormItem> formItems)
Convenience method to get parameter map in case
multipart/form-data request was used. |
protected String |
getRealPath(String path)
Returns a String containing the real path for a given virtual path.
|
protected byte[] |
getRequestBytes()
Reads entire request data as byte array.
|
protected String |
getRequestHost()
This method returns a host name of a web server if this container is fronted by one, such that
it sets a header
X-Forwarded-Host on the request and forwards it to the Java container. |
protected InputStream |
getRequestInputStream()
Returns InputStream of the request.
|
protected int |
getRequestPort()
This method returns a port of a web server if this Java container is fronted by one, such that
it sets a header
X-Forwarded-Port on the request and forwards it to the Java container. |
protected String |
getRequestProtocol()
This method returns a protocol of a request to web server if this container is fronted by one, such that
it sets a header
X-Forwarded-Proto on the request and forwards it to the Java container. |
protected InputStream |
getRequestStream()
Alias to
getRequestInputStream() . |
protected String |
getRequestString()
Reads entire request data as String.
|
Map<String,String> |
getResponseHeaders()
Returns response headers
|
protected Route |
getRoute()
Returns instance of
Route to be used for potential conditional logic inside controller filters. |
protected String |
header(String name)
Returns a request header by name.
|
protected void |
header(String name,
Object value)
Adds a header to response.
|
protected void |
header(String name,
String value)
Adds a header to response.
|
protected Map<String,String> |
headers()
Returns all headers from a request keyed by header name.
|
protected String |
host()
Returns local host name on which request was received.
|
protected String |
ipAddress()
Returns local IP address on which request was received.
|
protected String |
ipForwardedFor()
Returns IP address that the web server forwarded request for.
|
protected boolean |
isDelete()
True if this request uses HTTP DELETE method, false otherwise.
|
protected boolean |
isGet()
True if this request uses HTTP GET method, false otherwise.
|
protected boolean |
isHead()
True if this request uses HTTP HEAD method, false otherwise.
|
protected boolean |
isPost()
True if this request uses HTTP POST method, false otherwise.
|
protected boolean |
isPut()
True if this request uses HTTP PUT method, false otherwise.
|
protected boolean |
isXhr()
Returns true if this request is Ajax.
|
protected List |
jsonList()
Converts posted JSON array to a Java List.
|
protected Map |
jsonMap()
Converts posted JSON map to a Java Map.
|
protected Map[] |
jsonMaps()
Converts posted JSON maps to a Java Maps array.
|
protected Locale |
locale()
Returns locale of request.
|
protected void |
locale(Locale locale)
Same as
setLocale(java.util.Locale) |
protected void |
logDebug(String info) |
protected void |
logError(String info) |
protected void |
logError(String info,
Throwable e) |
protected void |
logError(Throwable e) |
protected void |
logInfo(String info) |
protected void |
logWarning(String info) |
protected void |
logWarning(String info,
Throwable e) |
protected String |
merge(String template,
Map values)
Will merge a template and return resulting string.
|
protected String |
method()
Returns an HTTP method from the request.
|
protected List<FormItem> |
multipartFormItems()
Convenience method, calls
multipartFormItems(String) . |
protected List<FormItem> |
multipartFormItems(String encoding)
Returns a collection of uploaded files and form fields from a multi-part request.
|
protected List<FormItem> |
multipartFormItems(String encoding,
long maxUploadSize)
Returns a collection of uploaded files and form fields from a multi-part request.
|
protected OutputStream |
outputStream()
Use to send raw data to HTTP client.
|
protected OutputStream |
outputStream(String contentType)
Use to send raw data to HTTP client.
|
protected OutputStream |
outputStream(String contentType,
Map headers,
int status)
Use to send raw data to HTTP client.
|
protected String |
param(String name)
Returns value of one named parameter from request.
|
protected String |
param(String name,
List<FormItem> formItems)
Convenience method to get a parameter in case
multipart/form-data request was used. |
protected Map<String,String[]> |
params()
Returns an instance of
java.util.Map containing parameter names as keys and parameter values as map values. |
protected List<String> |
params(String name)
Returns multiple request values for a name.
|
protected List<String> |
params(String name,
List<FormItem> formItems)
Convenience method to get parameters in case
multipart/form-data request was used. |
protected Map<String,String> |
params1st()
Returns a map where keys are names of all parameters, while values are first value for each parameter, even
if such parameter has more than one value submitted.
|
protected Map<String,String> |
params1st(List<FormItem> formItems)
Convenience method to get first parameter values in case
multipart/form-data request was used. |
protected String |
path()
Returns a path of the request.
|
protected int |
port()
Returns port on which the of the server received current request.
|
protected String |
protocol()
Returns protocol of request, for example: HTTP/1.1.
|
protected String |
queryString()
Returns query string of the request.
|
protected HttpSupport.HttpBuilder |
redirect()
Redirects to the same controller, and action "index".
|
protected <T extends AppController> |
redirect(Class<T> controllerClass)
Redirects to given controller, action "index" without any parameters.
|
protected <T extends AppController> |
redirect(Class<T> controllerClass,
Map params)
Redirects to a controller, generates appropriate redirect path.
|
protected <T extends AppController> |
redirect(Class<T> controllerClass,
Object id)
Convenience method for
redirect(Class, java.util.Map) . |
protected <T extends AppController> |
redirect(Class<T> controllerClass,
String action)
Convenience method for
redirect(Class, java.util.Map) . |
protected <T extends AppController> |
redirect(Class<T> controllerClass,
String action,
Object id)
Convenience method for
redirect(Class, java.util.Map) . |
protected HttpSupport.HttpBuilder |
redirect(String path)
Redirects to a an action of this controller, or an action of a different controller.
|
protected HttpSupport.HttpBuilder |
redirect(URL url)
Redirects to another URL (usually another site).
|
protected HttpSupport.HttpBuilder |
redirectToReferrer()
Redirects to referrer if one exists.
|
protected HttpSupport.HttpBuilder |
redirectToReferrer(String defaultReference)
Redirects to referrer if one exists.
|
protected String |
remoteAddress()
IP address of the requesting client.
|
protected String |
remoteHost()
Host name of the requesting client.
|
protected HttpSupport.RenderBuilder |
render(String template,
Map values)
Renders results with a template.
|
protected boolean |
requestHas(String name)
Synonym of
exists(String) . |
protected HttpSupport.HttpBuilder |
respond(String text)
This method will send the text to a client verbatim.
|
protected String |
sanitize(String unsafeContent)
Cleans HTML from harmful tags, making XSS impossible.
|
void |
sendCookie(Cookie cookie)
Sends cookie to browse with response.
|
void |
sendCookie(String name,
String value)
Sends cookie to browse with response.
|
protected HttpSupport.HttpBuilder |
sendFile(File file)
Convenience method for downloading files.
|
protected HttpSupport.HttpBuilder |
sendFile(File file,
boolean delete)
Convenience method for downloading files.
|
void |
sendPermanentCookie(String name,
String value)
Sends long to live cookie to browse with response.
|
protected SessionFacade |
session()
Returns reference to a current session.
|
protected Object |
session(String name)
Synonym of
sessionObject(String) . |
protected void |
session(String name,
Serializable value)
Convenience method, sets an object on a session.
|
protected Boolean |
sessionBoolean(String name)
Convenience method, returns object from session, equivalent of:
|
protected Double |
sessionDouble(String name)
Convenience method, returns object from session, equivalent of:
|
protected Float |
sessionFloat(String name)
Convenience method, returns object from session, equivalent of:
|
protected boolean |
sessionHas(String name)
Returns true if session has named object, false if not.
|
protected Integer |
sessionInteger(String name)
Convenience method, returns object from session, equivalent of:
|
protected Long |
sessionLong(String name)
Convenience method, returns object from session, equivalent of:
|
protected Object |
sessionObject(String name)
Convenience method, returns object from session, equivalent of:
|
protected String |
sessionString(String name)
Convenience method, returns object from session, equivalent of:
|
protected void |
setContentLength(int length)
Sets content length of response.
|
protected void |
setEncoding(String encoding)
Sets character encoding on the response.
|
protected void |
setLocale(Locale locale)
Sets locale on response.
|
protected void |
setRequestEncoding(String encoding)
Sets character encoding for request.
|
protected void |
setResponseEncoding(String encoding)
Sets character encoding for response.
|
protected int |
status()
Returns status code from current response.
|
protected HttpSupport.HttpBuilder |
streamOut(InputStream in)
Streams content of the
reader to the HTTP client. |
protected Iterator<FormItem> |
uploadedFiles()
Returns a collection of uploaded files from a multi-part port request.
|
protected Iterator<FormItem> |
uploadedFiles(String encoding)
Returns a collection of uploaded files from a multi-part port request.
|
protected Iterator<FormItem> |
uploadedFiles(String encoding,
long maxFileSize)
Returns a collection of uploaded files from a multi-part port request.
|
protected String |
uri()
Returns URI, or a full path of request.
|
protected String |
url()
Returns a full URL of the request, all except a query string.
|
protected String |
userAgent()
Helper method, returns user-agent header of the request.
|
protected Map |
values()
Returns a mutable Map with all the values from the current request context.
|
protected void |
view(Map values)
Convenience method, calls
assign(String, Object) internally. |
protected void |
view(Object... values)
Convenience method to pass multiple names and corresponding values to a view.
|
protected void |
view(String name,
Object value)
Alias to
assign(String, Object) . |
protected PrintWriter |
writer()
Produces a writer for sending raw data to HTTP clients.
|
protected PrintWriter |
writer(String contentType,
Map headers,
int status)
Produces a writer for sending raw data to HTTP clients.
|
protected boolean |
xhr()
Synonym for
isXhr() . |
protected void logInfo(String info)
protected void logDebug(String info)
protected void logWarning(String info)
protected void logError(String info)
protected void logError(Throwable e)
protected void assign(String name, Object value)
name
- name of valuevalue
- value.protected void view(String name, Object value)
assign(String, Object)
.name
- name of object to be passed to viewvalue
- object to be passed to viewprotected int status()
protected void view(Map values)
assign(String, Object)
internally.
The keys in teh map are converted to String values.values
- map with values to pass to view.protected void view(Object... values)
values
- - pairs of names and values. such as: name1, value1, name2, value2, etc. Number of arguments must be even.protected void flash(Map values)
values
- values to flash.flash(String, Object)
protected void flash(Object... values)
values
- values to flash.flash(String, Object)
protected void flash(String name)
<@flash name="warning"> <div class="warning">${message}</div> </@flash>If body refers to variables (as in this example), then such variables need to be passed in to the template as usual using the
view(String, Object)
method.name
- name of a flashprotected void flash(String name, Object value)
name
- name of value to flashvalue
- value to live for one more request in current session.protected HttpSupport.RenderBuilder render(String template, Map values)
template
- - template name, must be "absolute", starting with slash,
such as: "/controller_dir/action_template".values
- map with values to pass to view.HttpSupport.RenderBuilder
, which is used to provide additional parameters.protected HttpSupport.HttpBuilder redirect(String path)
path
- - expected to be a path within the application.HttpSupport.HttpBuilder
to accept additional information.protected HttpSupport.HttpBuilder redirect(URL url)
url
- absolute URL: http://domain/path...
.HttpSupport.HttpBuilder
, to accept additional information.protected HttpSupport.HttpBuilder redirectToReferrer(String defaultReference)
defaultReference
.defaultReference
- where to redirect - can be absolute or relative; this will be used in case
the request does not provide a "Referrer" header.HttpSupport.HttpBuilder
, to accept additional information.protected HttpSupport.HttpBuilder redirectToReferrer()
HttpSupport.HttpBuilder
, to accept additional information.protected <T extends AppController> HttpSupport.HttpBuilder redirect(Class<T> controllerClass, String action, Object id)
redirect(Class, java.util.Map)
.controllerClass
- controller class where to send redirect.action
- action to redirect to.id
- id to redirect to.HttpSupport.HttpBuilder
, to accept additional information.protected <T extends AppController> HttpSupport.HttpBuilder redirect(Class<T> controllerClass, Object id)
redirect(Class, java.util.Map)
.controllerClass
- controller class where to send redirect.id
- id to redirect to.HttpSupport.HttpBuilder
, to accept additional information.protected <T extends AppController> HttpSupport.HttpBuilder redirect(Class<T> controllerClass, String action)
redirect(Class, java.util.Map)
.controllerClass
- controller class where to send redirect.action
- action to redirect to.HttpSupport.HttpBuilder
, to accept additional information.protected HttpSupport.HttpBuilder redirect()
redirect(BooksController.class);given that the current controller is
BooksController
.HttpSupport.HttpBuilder
, to accept additional information.protected <T extends AppController> HttpSupport.HttpBuilder redirect(Class<T> controllerClass)
controllerClass
- controller class where to send redirect.HttpSupport.HttpBuilder
, to accept additional information.protected <T extends AppController> HttpSupport.HttpBuilder redirect(Class<T> controllerClass, Map params)
/controller/action/id
for regular controllers, and:
/controller/id/action
for RESTful controllers. For RESTful controllers, the action names are limited to those described in
RESTful
and allowed on a GET URLs, which are: "edit_form" and "new_form".
The map may contain any number of other key/value pairs, which will be converted to a query string for
the redirect URI. Example:
Method:
redirect(app.controllers.PersonController.class, org.javalite.common.Collections.map("action", "show", "id", 123, "format", "json", "restrict", "true"));
will generate the following URI:
/person/show/123?format=json&restrict=true
This method will also perform URL - encoding of special characters if necessary.controllerClass
- controller classparams
- map with request parameters.HttpSupport.HttpBuilder
, to accept additional information.protected HttpSupport.HttpBuilder respond(String text)
text
- text of response.HttpSupport.HttpBuilder
, to accept additional information.protected HttpSupport.HttpBuilder sendFile(File file, boolean delete) throws FileNotFoundException
file
- file to download.delete
- true to delete the file after processingFileNotFoundException
- thrown if file not found.protected HttpSupport.HttpBuilder sendFile(File file) throws FileNotFoundException
file
- file to download.FileNotFoundException
- thrown if file not found.protected FileItem getFile(String fieldName, List<FormItem> formItems)
multipart/form-data
request. If more than one files with the same
name are submitted, only one is returned.fieldName
- name of form field from the multipart/form-data
request corresponding to the uploaded file.formItems
- form items retrieved from multipart/form-data
request.InputStream
from which to read content of uploaded file or null if FileItem with this name is not found.protected String param(String name)
IllegalArgumentException
.name
- name of parameter.RequestUtils.param(String)
protected String param(String name, List<FormItem> formItems)
multipart/form-data
request was used.
Returns value of one named parameter from request. If this name represents multiple values, this
call will result in IllegalArgumentException
.name
- name of parameter.formItems
- form items retrieved from multipart/form-data
request.RequestUtils.param(String)
protected boolean exists(String name)
name
- name of request parameter to test.protected boolean requestHas(String name)
exists(String)
.name
- name of request parameter to test.protected String host()
protected String ipAddress()
protected String getRequestProtocol()
X-Forwarded-Proto
on the request and forwards it to the Java container.
If such header is not present, than the protocol()
method is used.X-Forwarded-Proto
header is found, otherwise current
protocol.protected int getRequestPort()
X-Forwarded-Port
on the request and forwards it to the Java container.
If such header is not present, than the port()
method is used.X-Forwarded-Port
header is found, otherwise port of the Java container.protected javax.servlet.http.HttpServletRequest getHttpServletRequest()
HttpServletRequest
for low level operations.HttpServletRequest
.protected javax.servlet.http.HttpServletResponse getHttpServletResponse()
HttpServletResponse
for low level operations.HttpServletResponse
.protected int port()
protected String protocol()
protected String getRequestHost()
X-Forwarded-Host
on the request and forwards it to the Java container.
If such header is not present, than the host()
method is used.X-Forwarded-Host
header is found, otherwise local host name.protected String ipForwardedFor()
protected String getId()
/controller/action/id
.
This depends on a type of a URI, and whether controller is RESTful or not.protected Iterator<FormItem> uploadedFiles()
protected Iterator<FormItem> uploadedFiles(String encoding)
encoding
- specifies the character encoding to be used when reading the headers of individual part.
When not specified, or null, the request encoding is used. If that is also not specified, or null,
the platform default encoding is used.protected Iterator<FormItem> uploadedFiles(String encoding, long maxFileSize)
encoding
- specifies the character encoding to be used when reading the headers of individual part.
When not specified, or null, the request encoding is used. If that is also not specified, or null,
the platform default encoding is used.maxFileSize
- maximum file size in the upload in bytes. -1 indicates no limit.protected List<FormItem> multipartFormItems()
multipartFormItems(String)
. Does not set encoding before reading request.multipartFormItems(String)
protected List<FormItem> multipartFormItems(String encoding)
<listener> <listener-class> org.apache.commons.fileupload.servlet.FileCleanerCleanup </listener-class> </listener>For more information, see: Using FileUpload The size of upload defaults to max of 20mb. Files greater than that will be rejected. If you want to accept larger files, create a file called
activeweb.properties
,
add it to your classpath and place this property to the file:
#max upload size maxUploadSize = 20000000Alternatively, just call this method and pass a per-request parameter for the size:
multipartFormItems(String, long)
.encoding
- specifies the character encoding to be used when reading the headers of individual part.
When not specified, or null, the request encoding is used. If that is also not specified, or null,
the platform default encoding is used.protected List<FormItem> multipartFormItems(String encoding, long maxUploadSize)
<listener> <listener-class> org.apache.commons.fileupload.servlet.FileCleanerCleanup </listener-class> </listener>For more information, see: Using FileUpload
encoding
- specifies the character encoding to be used when reading the headers of individual part.
When not specified, or null, the request encoding is used. If that is also not specified, or null,
the platform default encoding is used.maxUploadSize
- maximum size of the upload in bytes. A value of -1 indicates no maximum.protected List<String> params(String name)
name
- name of multiple values from request.protected Map<String,String[]> params()
java.util.Map
containing parameter names as keys and parameter values as map values.
The keys in the parameter map are of type String. The values in the parameter map are of type String array.java.util.Map
containing parameter names as keys and parameter values as map values.
The keys in the parameter map are of type String. The values in the parameter map are of type String array.protected List<String> params(String name, List<FormItem> formItems)
multipart/form-data
request was used.
Returns multiple request values for a name.name
- name of multiple values from request.formItems
- form items retrieved from multipart/form-data
request.public Map<String,String> getMap(String hashName)
<input type="text" name="account[name]" /> <input type="text" name="account[number]" />will result in a map where keys are names of hash elements, and values are values of these elements from request. For the example above, the map will have these values:
{ "name":"John", "number": "123" }
hashName
- - name of a hash. In the example above, it will be "account".public Map<String,String> getMap(String hashName, List<FormItem> formItems)
multipart/form-data
request was used.
This method will skip files, and will only return form fields that are not files.
Returns a map parsed from a request if parameter names have a "hash" syntax:
<input type="text" name="account[name]" /> <input type="text" name="account[number]" />will result in a map where keys are names of hash elements, and values are values of these elements from request. For the example above, the map will have these values:
{ "name":"John", "number": "123" }
hashName
- - name of a hash. In the example above, it will be "account".formItems
- form items retrieved from multipart/form-data
request.protected void setRequestEncoding(String encoding) throws UnsupportedEncodingException
encoding
- encoding to be set.UnsupportedEncodingException
protected void setResponseEncoding(String encoding)
encoding
- encoding to be set.protected void setEncoding(String encoding)
encoding
- character encoding for response.protected void encoding(String encoding)
setEncoding(String)
encoding
- encoding of response to clientprotected String getEncoding()
setEncoding(String)
trumps this setting.protected void setContentLength(int length)
length
- content length of response.protected void setLocale(Locale locale)
locale
- locale for response.protected void locale(Locale locale)
setLocale(java.util.Locale)
locale
- locale for responseprotected Locale locale()
protected Map<String,String> params1st()
protected Map<String,String> params1st(List<FormItem> formItems)
multipart/form-data
request was used.
Returns a map where keys are names of all parameters, while values are first value for each parameter, even
if such parameter has more than one value submitted.formItems
- form items retrieved from multipart/form-data
request.protected SessionFacade session()
protected void session(String name, Serializable value)
session().put(name, value)
name
- name of objectvalue
- object itself.protected Object sessionObject(String name)
session().get(name)
name
- name of object,protected Object session(String name)
sessionObject(String)
.name
- name of session attributeprotected String sessionString(String name)
String val = (String)session().get(name)
name
- name of objectprotected Integer sessionInteger(String name)
Integer val = (Integer)session().get(name)
name
- name of objectprotected Boolean sessionBoolean(String name)
Boolean val = (Boolean)session().get(name)
name
- name of objectprotected Double sessionDouble(String name)
Double val = (Double)session().get(name)
name
- name of objectprotected Float sessionFloat(String name)
Float val = (Float)session().get(name)
name
- name of objectprotected Long sessionLong(String name)
Long val = (Long)session().get(name)
name
- name of objectprotected boolean sessionHas(String name)
name
- name of object.public List<Cookie> cookies()
public Cookie cookie(String name)
name
- name of a cookie.protected String cookieValue(String name)
name
- name of cookie.public void sendCookie(Cookie cookie)
cookie
- cookie to send.public void sendCookie(String name, String value)
name
- name of cookievalue
- value of cookie.public void sendPermanentCookie(String name, String value)
name
- name of cookievalue
- value of cookie.protected String path()
/controller/action/id
protected String url()
protected String queryString()
protected String method()
protected boolean isGet()
protected boolean isPost()
protected boolean isPut()
protected boolean isDelete()
protected boolean isHead()
protected String context()
/mywebapp
protected String uri()
/mywebapp/controller/action/id
protected String remoteHost()
protected String remoteAddress()
protected String header(String name)
name
- name of headerprotected Map<String,String> headers()
protected void header(String name, String value)
name
- name of header.value
- value of header.protected void header(String name, Object value)
name
- name of header.value
- value of header.protected HttpSupport.HttpBuilder streamOut(InputStream in)
reader
to the HTTP client.in
- input stream to read bytes from.HttpSupport.HttpBuilder
, to accept additional information.protected String getRealPath(String path)
path
- a String specifying a virtual pathprotected OutputStream outputStream()
protected OutputStream outputStream(String contentType)
contentType
- content typeprotected OutputStream outputStream(String contentType, Map headers, int status)
contentType
- content typeheaders
- set of headers.status
- status.protected PrintWriter writer()
protected PrintWriter writer(String contentType, Map headers, int status)
contentType
- content type. If null - will not be set on the responseheaders
- headers. If null - will not be set on the responsestatus
- will be sent to browser.protected boolean blank(String... names)
names
- names of request parameters.protected boolean isXhr()
protected String userAgent()
protected boolean xhr()
isXhr()
.protected AppContext appContext()
AppContext
.AppContext
.protected String format()
/books.xml
, here "xml" is a format.protected Route getRoute()
Route
to be used for potential conditional logic inside controller filters.Route
protected String merge(String template, Map values)
template
- name of template - same as in regular templates. Example: "/email-templates/welcome"
.values
- values to be merged into template.public Map<String,String> getResponseHeaders()
protected String sanitize(String unsafeContent)
For example, input like this:
<html><script> alert('hello');</script><div>this is a clean part</div></html>Will produce output like this:
this is a clean part
unsafeContent
- unsafe content. Something that an end user typed into a text area, or input that may include
a script tag or other garbage.protected InputStream getRequestInputStream() throws IOException
IOException
protected InputStream getRequestStream() throws IOException
getRequestInputStream()
.IOException
protected String getRequestString() throws IOException
getRequestInputStream()
.IOException
protected byte[] getRequestBytes() throws IOException
IOException
protected List jsonList()
[1, 2, 3]
.protected Map jsonMap()
{"name":"John", "age":21}
.protected Map[] jsonMaps()
[{"name":"John", "age":21}, {"name":"Jane", "age":20}]
.protected Map values()
Map
with all values from/for current request context.Copyright © 2019 JavaLite. All rights reserved.