Class Context
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final doublestatic final floatstatic final intstatic final longstatic final intStatus code (500) indicating an error inside the HTTP server which prevented it from fulfilling the request.static final intStatus code (304) indicating that a conditional GET operation found that the resource was available and not modified. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCookie(CookieBuilder builder) Adds theCookiecreated by aCookieBuilderto the response.voidaddDateHeader(String name, long date) Adds a response header with the given name and date-value.voidAdds a response header with the given name and integer value.voidAdds a response header with the given name and value.Returns the value of the named attribute.Returns a list of attribute names available to this request.body()Retrieves the body of this context's request as a string.byte[]Retrieves the body of this context's request as a byte array.Returns the name of the character encoding used in the body of this request.voidClears the text buffer is it's enabled.Returns the MIME type of the body of the request, or null if the type is not known.Returns the portion of the request URI that indicates the context of the request.Returns the unique identifier of the current continuation.booleancookieBoolean(String name) Retrieves the value of a named cookie and converts it to a boolean.booleancookieBoolean(String name, boolean defaultValue) Retrieves the value of a named cookie and converts it to a boolean, using a default value if no input value is present.doublecookieDouble(String name) Retrieves the value of a named cookie and converts it to a double.doublecookieDouble(String name, double defaultValue) Retrieves the value of a named cookie and converts it to a double, using a default value if no input value is present.floatcookieFloat(String name) Retrieves the value of a named cookie and converts it to a float.floatcookieFloat(String name, float defaultValue) Retrieves the value of a named cookie and converts it to a float, using a default value if no input value is present.intRetrieves the value of a named cookie and converts it to an integer.intRetrieves the value of a named cookie and converts it to an integer, using a default value if no input value is present.longcookieLong(String name) Retrieves the value of a named cookie and converts it to a long.longcookieLong(String name, long defaultValue) Retrieves the value of a named cookie and converts it to a long, using a default value if no input value is present.Retrieves the names of the cookies.cookieValue(String name) Retrieves the value of a cookie.cookieValue(String name, String defaultValue) Retrieves the value of a named cookie, using a default value as fallback.Retrieves all current cookies names with their values.voiddefer()Interrupts the execution in RIFE2 completely and defers it to the servlet container.voidenableTextBuffer(boolean enabled) Enables or disables the response text buffer.Retrieves the exception that was triggered during the RIFE2 web engine execution.Retrieves an uploaded file.Retrieves the list of uploaded file names.files()Retrieves the files that were uploaded in this context.Retrieves all files that have been uploaded for a particular name.voidflush()Forces all the streamed content to be output to the client.static ContextfromTemplate(Template template) Retrieves the context that was stored in a template attribute.gateUrl()Retrieves the URL portion that corresponds to the entrance gate of the RIFE2 web engine, this is usually equivalent with the HTTP request context path.voidgenerateEmptyForm(Template template, Class beanClass) Generates a form that corresponds to an empty instance of a bean class.voidgenerateEmptyForm(Template template, Class beanClass, String prefix) Generates a form that corresponds to an empty instance of a bean class.voidgenerateForm(Template template, Object beanInstance) Generates a form that corresponds to a bean instance.voidgenerateForm(Template template, Object beanInstance, String prefix) Generates a form that corresponds to a bean instance.booleanhasAttribute(String name) Checks if a request attribute exists.booleanIndicates whether a continuation identifier is availablebooleanChecks whether a cookie is present.booleanChecks if a particular file has been uploaded in this context.booleanhasParameterValue(String name) Checks whether a value has been provided to a parameter.booleanhasProperty(String name) Checks for the existence of a property in this context'sHierarchicalProperties.Returns the value of the specified request header as a String.longheaderDate(String name) Returns the value of the specified request header as a long value that represents a date.intReturns the value of the specified request header as an int.Returns a list of all the header names in the request.Returns all the values of the specified request header as a list ofStringobjects.booleanisFileEmpty(String name) Checks if an uploaded file wasn't sent or if it is empty.booleanisParameterEmpty(String name) Checks whether a parameter is empty.locale()Returns the preferredLocalethat the client will accept content in, based on theAccept-Languageheader.locales()Returns a list ofLocaleobjects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on theAccept-Language} header.method()Returns the HTTPRequestMethodwith which this context's request was made.voidnext()Interrupts the execution in this element, moving processing on to the next element in the before/route/after chainReturns an output stream suitable for writing binary data in the response.Retrieves the value of a parameter.Retrieves the value of a parameter and returns a default value if no parameter value is presentbooleanparameterBoolean(String name) Retrieves the value of a parameter and converts it to a boolean.booleanparameterBoolean(String name, boolean defaultValue) Retrieves the value of a parameter and converts it to a boolean, using a default value if no parameter value is present.doubleparameterDouble(String name) Retrieves the value of a parameter and converts it to a double.doubleparameterDouble(String name, double defaultValue) Retrieves the value of a parameter and converts it to a double, using a default value if no parameter value is present.double[]parameterDoubles(String name) Retrieves the values of a parameter as an array of doubles.floatparameterFloat(String name) Retrieves the value of a parameter and converts it to a float.floatparameterFloat(String name, float defaultValue) Retrieves the value of a parameter and converts it to a float, using a default value if no parameter value is present.float[]parameterFloats(String name) Retrieves the values of a parameter as an array of floats.intparameterInt(String name) Retrieves the value of a parameter and converts it to an integer.intparameterInt(String name, int defaultValue) Retrieves the value of a parameter and converts it to an integer, using a default value if no parameter value is present.int[]parameterInts(String name) Retrieves the values of a parameter as an array of integers.longparameterLong(String name) Retrieves the value of a parameter and converts it to a long.longparameterLong(String name, long defaultValue) Retrieves the value of a parameter and converts it to a long, using a default value if no parameter value is present.long[]parameterLongs(String name) Retrieves the values of a parameter as an array of longs.Retrieves the names of all the parameters that are present.Retrieves the parameters that were sent to this context.<BeanType> BeanTypeparametersBean(Class<BeanType> beanClass) Creates an instance of a bean and populates the properties with the parameter values.<BeanType> BeanTypeparametersBean(Class<BeanType> beanClass, String prefix) Creates an instance of a bean and populates the properties with the parameter values, taking the provided prefix into account.voidparametersBean(Object bean) Fills the properties of an existing bean with the parameter values.voidparametersBean(Object bean, String prefix) Fills the properties of an existing bean with the parameter values that were sent, taking the provided prefix into account.String[]parameterValues(String name) Retrieves the values of a parameter.pathInfo()The pathinfo that was captured or matched.final voidpause()Pauses the execution of the element and creates a new continuation.voidSets up the current response to prevent all caching of the response by the client.voidPrints the string representation of an object to the request text output.voidPrints a template to the response.The hierarchical properties accessible to this context.Retrieve a property from this context'sHierarchicalProperties.Returns a collection of the names in this context'sHierarchicalProperties.protocol()Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.voidInterrupts the execution in this element and redirects the client to another URL.voidInterrupts the execution in this element and redirects the client to another URL.Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.Returns the fully qualified name of the client or the last proxy that sent the request.Returns the login of the user making this request.voidremoveAttribute(String name) Removes an attribute from this request.voidremoveCookie(String name) Removes a cookie with path"/".voidremoveCookie(String path, String name) Removes a cookie with given path and name.voidremoveForm(Template template, Class beanClass) Removes a generated form, leaving the builder value tags empty again as if this form had never been generated.voidremoveForm(Template template, Class beanClass, String prefix) Removes a generated form, leaving the builder value tags empty again as if this form had never been generated.voidremoveParameter(String name) Removes a name parameter that was previously set.request()The request of this context.voidrespond()Interrupts the execution in this element, stops processing any other element, and sends the current response directly to the client.response()The response of this context.route()The route of this context.router()The router in which this context's route was defined.scheme()Returns the name of the scheme used to make this request.booleansecure()Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.selectParameter(Template template, String name, String[] values) Sets a select box option, a radio button or a checkbox to selected or checked.Returns the host name of the server to which the request was sent.intReturns the port number to which the request was sent.serverRootUrl(int port) Returns the root URL of the server that is running this web applications.session()Returns the current session associated with this request, or if the request does not have a session, creates one.session(boolean create) Returns the currentSessionassociated with this request or, if there is no current session andcreateis true, returns a new session.voidsetAttribute(String name, Object object) Stores an attribute in this request.voidsetContentLength(int length) Sets the length of the content body in the response.voidsetContentType(String contentType) Sets the content type of the response being sent to the client.voidsetDateHeader(String name, long date) Adds a response header with the given name and date-value.voidAdds a response header with the given name and integer value.voidSets a response header with the given name and value.voidSets the locale of the response.voidsetParameter(String name, Object value) Sets a named parameter value for URL generation withurlFor(rife.engine.Route)or the `route:` filtered template value tags.voidsetParametersBean(Object bean) Sets named parameters values from bean properties for URL generation withurlFor(rife.engine.Route)or the `route:` filtered template value tags.voidsetParametersBean(Object bean, String prefix) Sets named parameters values from bean properties for URL generation withurlFor(rife.engine.Route)or the `route:` filtered template value tags.voidsetStatus(int statusCode) Sets the status code for the response.site()The active site this context is executing in.template()Instantiates an HTML template with the name corresponding to the identifier of this route's element.Instantiates an HTML template with a given name.Instantiates an HTML template with a given name and encoding.Instantiates an JSON template with the name corresponding to the identifier of this route's element.templateJson(String name) Instantiates an JSON template with a given name.templateJson(String name, String encoding) Instantiates an JSON template with a given name and encoding.Instantiates an SVG template with the name corresponding to the identifier of this route's element.templateSvg(String name) Instantiates an SVG template with a given name.templateSvg(String name, String encoding) Instantiates an SVG template with a given name and encoding.Instantiates a TXT template with the name corresponding to the identifier of this route's element.templateTxt(String name) Instantiates a TXT template with a given name.templateTxt(String name, String encoding) Instantiates a TXT template with a given name and encoding.Instantiates an XML template with the name corresponding to the identifier of this route's element.templateXml(String name) Instantiates an XML template with a given name.templateXml(String name, String encoding) Instantiates an XML template with a given name and encoding.booleanIndicates whether the response text buffer is enabled or disabled.Start building a URL towards a particular route.Returns the root URL of this web application.webappRootUrl(int port) Returns the root URL of this web application.
-
Field Details
-
DEFAULT_BOOLEAN
public static final boolean DEFAULT_BOOLEAN- See Also:
-
DEFAULT_INTEGER
public static final int DEFAULT_INTEGER- See Also:
-
DEFAULT_LONG
public static final long DEFAULT_LONG- See Also:
-
DEFAULT_DOUBLE
public static final double DEFAULT_DOUBLE- See Also:
-
DEFAULT_FLOAT
public static final float DEFAULT_FLOAT- See Also:
-
SC_NOT_MODIFIED
public static final int SC_NOT_MODIFIEDStatus code (304) indicating that a conditional GET operation found that the resource was available and not modified.- See Also:
-
SC_INTERNAL_SERVER_ERROR
public static final int SC_INTERNAL_SERVER_ERRORStatus code (500) indicating an error inside the HTTP server which prevented it from fulfilling the request.- See Also:
-
-
Method Details
-
site
The active site this context is executing in.- Returns:
- the currently active site
- Since:
- 1.0
-
request
The request of this context.Most request methods have direct counterparts in the context for easier and more convenient usage.
- Returns:
- this context's request
- Since:
- 1.0
-
response
The response of this context.Most response methods have direct counterparts in the context for easier and more convenient usage.
- Returns:
- this context's response
- Since:
- 1.0
-
pathInfo
The pathinfo that was captured or matched.The slash separated between the route path in the pathinfo will have been stripped already.
- Returns:
- the captured or matching pathinfo; or
nullif no pathinfo was captured or matched - Since:
- 1.0
-
route
The route of this context.- Returns:
- this context's route; or
nullif the context doesn't belong to a specific route - Since:
- 1.0
-
router
The router in which this context's route was defined.- Returns:
- this context's route's router; or
nullif the context doesn't belong to a specific route - Since:
- 1.0
-
properties
The hierarchical properties accessible to this context.- Returns:
- this context's hierarchical properties; or
nullif those properties can't be found - Since:
- 1.0
-
property
Retrieve a property from this context'sHierarchicalProperties.- Returns:
- the requested property; or
nullif it doesn't exist - Since:
- 1.0
-
hasProperty
Checks for the existence of a property in this context'sHierarchicalProperties.- Returns:
trueif the property exists; orfalseotherwise- Since:
- 1.0
-
propertyNames
Returns a collection of the names in this context'sHierarchicalProperties.- Returns:
- the requested collection of names
- Since:
- 1.0
-
pause
public final void pause()Pauses the execution of the element and creates a new continuation.The next request will resume exactly at the same location with a completely restored call stack and variable stack.
- Since:
- 1.0
-
hasContinuationId
public boolean hasContinuationId()Indicates whether a continuation identifier is available- Returns:
truewhen a continuation identifier is available; orfalseotherwise- Since:
- 1.0
-
continuationId
Returns the unique identifier of the current continuation.- Returns:
- the unique identifier of the current continuation; or
nullif no continuation is active - Since:
- 1.0
-
print
Prints the string representation of an object to the request text output. The string representation will be created through aString.valueOf(value)call.- Parameters:
object- the object that will be output- Throws:
EngineException- if an error occurs during the output of the content- Since:
- 1.0
- See Also:
-
print
Prints a template to the response.If no response content type was set yet, the template's content type will be used.
Printing a template will automatically process all the filtered tags.
Printing a template instead of the string representation of its content has many advantages, the biggest one being that the out-of-container testing API will have access to this template instance, allowing you to assert of value content, instead of having to parse a response.
- Parameters:
template- the template to print- Throws:
TemplateException- if an error occurs while processing the templateEngineException- if an error occurs during the output of the content- Since:
- 1.0
-
fromTemplate
Retrieves the context that was stored in a template attribute.Each template that was obtained through a context, automatically has the context store itself in the template as an attribute. This convenience method makes it easy to retrieve that context elsewhere.
- Returns:
- the current context stored in a template attribute.
- Since:
- 1.8.0
-
template
Instantiates an HTML template with the name corresponding to the identifier of this route's element.For lambda elements, this will be the path of the route and for class elements this will be the shortened uncapitalized name of the class.
- Returns:
- the HTML template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
template
Instantiates an HTML template with a given name.- Parameters:
name- the template name- Returns:
- the HTML template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
template
Instantiates an HTML template with a given name and encoding.- Parameters:
name- the template nameencoding- the template's encoding- Returns:
- the HTML template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
templateTxt
Instantiates a TXT template with the name corresponding to the identifier of this route's element.For lambda elements, this will be the path of the route and for class elements this will be the shortened uncapitalized name of the class.
- Returns:
- the TXT template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
templateTxt
Instantiates a TXT template with a given name.- Parameters:
name- the template name- Returns:
- the TXT template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
templateTxt
Instantiates a TXT template with a given name and encoding.- Parameters:
name- the template nameencoding- the template's encoding- Returns:
- the TXT template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
templateXml
Instantiates an XML template with the name corresponding to the identifier of this route's element.For lambda elements, this will be the path of the route and for class elements this will be the shortened uncapitalized name of the class.
- Returns:
- the XML template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
templateXml
Instantiates an XML template with a given name.- Parameters:
name- the template name- Returns:
- the XML template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
templateXml
Instantiates an XML template with a given name and encoding.- Parameters:
name- the template nameencoding- the template's encoding- Returns:
- the XML template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
templateJson
Instantiates an JSON template with the name corresponding to the identifier of this route's element.For lambda elements, this will be the path of the route and for class elements this will be the shortened uncapitalized name of the class.
- Returns:
- the JSON template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
templateJson
Instantiates an JSON template with a given name.- Parameters:
name- the template name- Returns:
- the JSON template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
templateJson
Instantiates an JSON template with a given name and encoding.- Parameters:
name- the template nameencoding- the template's encoding- Returns:
- the JSON template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
templateSvg
Instantiates an SVG template with the name corresponding to the identifier of this route's element.For lambda elements, this will be the path of the route and for class elements this will be the shortened uncapitalized name of the class.
- Returns:
- the SVG template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
templateSvg
Instantiates an SVG template with a given name.- Parameters:
name- the template name- Returns:
- the SVG template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
templateSvg
Instantiates an SVG template with a given name and encoding.- Parameters:
name- the template nameencoding- the template's encoding- Returns:
- the SVG template if it was found.
- Throws:
TemplateException- when an error occurred instantiating the template- Since:
- 1.0
- See Also:
-
gateUrl
Retrieves the URL portion that corresponds to the entrance gate of the RIFE2 web engine, this is usually equivalent with the HTTP request context path.- Returns:
- the URL of the web engine gate
- Since:
- 1.0
-
serverRootUrl
Returns the root URL of the server that is running this web applications.This includes the protocol, the server name and the server port, for example:
http://www.somehost.com:8080.- Parameters:
port- the server port to use, or-1to use the sane port as the active request- Returns:
- the server's root url
- Since:
- 1.0
-
webappRootUrl
Returns the root URL of this web application.This includes the protocol, the server name and the server port, and the gate URL.
- Returns:
- this web application's root URL
- Since:
- 1.0
-
webappRootUrl
Returns the root URL of this web application.This includes the protocol, the server name and the server port, and the gate URL.
- Parameters:
port- the server port to use, or-1to use the sane port as the active request- Returns:
- this web application's root URL
- Since:
- 1.0
-
urlFor
Start building a URL towards a particular route.The result is a instance that can be used for further customization of the URL, if needed.
- Parameters:
route- the target route- Returns:
- an instance of
- Since:
- 1.0
-
engineException
Retrieves the exception that was triggered during the RIFE2 web engine execution.- Returns:
- the triggered exception; or
nullif no exception was triggered - Since:
- 1.0
-
selectParameter
Sets a select box option, a radio button or a checkbox to selected or checked.This method delegates all logic to the
FormBuilder.selectParameter(Template, String, String[])method of the provided template instance.- Parameters:
template- the template instance where the selection should happenname- the name of the parametervalues- the values that should be selected or checked- Returns:
- a list with the identifiers of the template values that have
been set, this is never
null, when no values are set an empty list is returned - Since:
- 1.0
- See Also:
-
generateForm
Generates a form that corresponds to a bean instance.- Parameters:
template- the template instance where the generation should happenbeanInstance- the instance of the bean that should be used to generate the form- Since:
- 1.0
- See Also:
-
generateForm
Generates a form that corresponds to a bean instance.This method delegates all logic to the
FormBuilder.generateForm(Template, Object, Map, String)method of the provided template instance.- Parameters:
template- the template instance where the generation should happenbeanInstance- the instance of the bean that should be used to generate the formprefix- the prefix that will be prepended to all bean property names- Since:
- 1.0
- See Also:
-
generateEmptyForm
Generates a form that corresponds to an empty instance of a bean class.- Parameters:
template- the template instance where the generation should happenbeanClass- the class of the bean that should be used to generate the form- Since:
- 1.0
- See Also:
-
generateEmptyForm
Generates a form that corresponds to an empty instance of a bean class.An 'empty' instance is an object that has been created by calling the default constructor of the bean class, without making any additional changes to it afterward.
This method delegates all logic to the
FormBuilder.generateForm(Template, Class, Map, String)method of the provided template instance.- Parameters:
template- the template instance where the generation should happenbeanClass- the class of the bean that should be used to generate the formprefix- the prefix that will be prepended to all bean property names- Since:
- 1.0
- See Also:
-
removeForm
Removes a generated form, leaving the builder value tags empty again as if this form had never been generated.- Parameters:
template- the template instance where the form should be removed frombeanClass- the class of the bean that should be used to remove the form- Since:
- 1.0
- See Also:
-
removeForm
Removes a generated form, leaving the builder value tags empty again as if this form had never been generated.This method delegates all logic to the
FormBuilder.removeForm(Template, Class, String)method of the provided template instance.- Parameters:
template- the template instance where the form should be removed frombeanClass- the class of the bean that should be used to remove the formprefix- the prefix that will be prepended to all bean property names- Since:
- 1.0
- See Also:
-
defer
Interrupts the execution in RIFE2 completely and defers it to the servlet container.If RIFE2 is being run as a filter, it will execute the next filter in the chain.
If RIFE2 is being run as a servlet, the status code
404: Not Foundwill be sent to the client.- Throws:
DeferException- an exception that is used to immediately interrupt the execution, don't catch this exception- Since:
- 1.0
-
redirect
Interrupts the execution in this element and redirects the client to another URL.- Parameters:
url- the URL to which the request will be redirected,String.valueOf()will be called with this object, so a variety of types can be used- Throws:
RedirectException- an exception that is used to immediately interrupt the execution, don't catch this exception- Since:
- 1.0
-
redirect
Interrupts the execution in this element and redirects the client to another URL.- Parameters:
route- the route to which the request will be redirected- Throws:
RedirectException- an exception that is used to immediately interrupt the execution, don't catch this exception- Since:
- 1.0
-
respond
public void respond()Interrupts the execution in this element, stops processing any other element, and sends the current response directly to the client.- Throws:
RespondException- an exception that is used to immediately interrupt the execution, don't catch this exception- Since:
- 1.0
-
next
public void next()Interrupts the execution in this element, moving processing on to the next element in the before/route/after chain- Throws:
NextException- an exception that is used to immediately interrupt the execution, don't catch this exception- Since:
- 1.0
-
preventCaching
public void preventCaching()Sets up the current response to prevent all caching of the response by the client.- Since:
- 1.0
-
method
Returns the HTTPRequestMethodwith which this context's request was made.- Returns:
- the
RequestMethodof this context's request - Since:
- 1.0
-
parameters
Retrieves the parameters that were sent to this context.- Returns:
- a
Mapwith all the parameter names and values - Since:
- 1.0
-
hasParameterValue
Checks whether a value has been provided to a parameter.- Parameters:
name- the name of the parameter- Returns:
trueif the parameter has a value; orfalseotherwise- Since:
- 1.0
- See Also:
-
isParameterEmpty
Checks whether a parameter is empty.- Parameters:
name- the name of the parameter- Returns:
trueif the parameter is empty; orfalseotherwise- Since:
- 1.0
- See Also:
-
parameter
Retrieves the value of a parameter.- Parameters:
name- the name of the parameter- Returns:
- the value of the parameter; or
nullif no value is present for this parameter - Since:
- 1.0
- See Also:
-
parameter
Retrieves the value of a parameter and returns a default value if no parameter value is present- Parameters:
name- the name of the parameterdefaultValue- the default value that will be used when no parameter value is present- Returns:
- the parameter value; or
the default value if no parameter value is present
- Since:
- 1.0
- See Also:
-
parameterNames
Retrieves the names of all the parameters that are present.- Returns:
- the list with the parameter names
- Since:
- 1.0
- See Also:
-
parameterValues
Retrieves the values of a parameter.- Parameters:
name- the name of the parameter- Since:
- 1.0
- See Also:
-
parameterBoolean
Retrieves the value of a parameter and converts it to a boolean.- Parameters:
name- the name of the parameter- Returns:
- the converted parameter value; or
falseif no parameter value is present or if the parameter value is not a valid boolean - Since:
- 1.0
- See Also:
-
parameterBoolean
Retrieves the value of a parameter and converts it to a boolean, using a default value if no parameter value is present.- Parameters:
name- the name of the parameterdefaultValue- the default value that will be used when no parameter value is present- Returns:
- the converted parameter value; or
the default value if no parameter value is present
- Since:
- 1.0
- See Also:
-
parameterInt
Retrieves the value of a parameter and converts it to an integer.- Parameters:
name- the name of the parameter- Returns:
- the converted parameter value; or
0if no parameter value is present or if the parameter value is not a valid integer - Since:
- 1.0
- See Also:
-
parameterInt
Retrieves the value of a parameter and converts it to an integer, using a default value if no parameter value is present.- Parameters:
name- the name of the parameterdefaultValue- the default value that will be used when no parameter value is present- Returns:
- the converted parameter value; or
the default value if no parameter value is present
- Since:
- 1.0
- See Also:
-
parameterLong
Retrieves the value of a parameter and converts it to a long.- Parameters:
name- the name of the parameter- Returns:
- the converted parameter value; or
0Lif no parameter value is present or if the parameter value is not a valid long - Since:
- 1.0
- See Also:
-
parameterLong
Retrieves the value of a parameter and converts it to a long, using a default value if no parameter value is present.- Parameters:
name- the name of the parameterdefaultValue- the default value that will be used when no parameter value is present- Returns:
- the converted parameter value; or
the default value if no parameter value is present
- Since:
- 1.0
- See Also:
-
parameterDouble
Retrieves the value of a parameter and converts it to a double.- Parameters:
name- the name of the parameter- Returns:
- the converted parameter value; or
0.0dif no parameter value is present or if the parameter value is not a valid double - Since:
- 1.0
- See Also:
-
parameterDouble
Retrieves the value of a parameter and converts it to a double, using a default value if no parameter value is present.- Parameters:
name- the name of the parameterdefaultValue- the default value that will be used when no parameter value is present- Returns:
- the converted parameter value; or
the default value if no parameter value is present
- Since:
- 1.0
- See Also:
-
parameterFloat
Retrieves the value of a parameter and converts it to a float.- Parameters:
name- the name of the parameter- Returns:
- the converted parameter value; or
0.0fif no parameter value is present or if the parameter value is not a valid float - Since:
- 1.0
- See Also:
-
parameterFloat
Retrieves the value of a parameter and converts it to a float, using a default value if no parameter value is present.- Parameters:
name- the name of the parameterdefaultValue- the default value that will be used when no parameter value is present- Returns:
- the converted parameter value; or
the default value if no parameter value is present
- Since:
- 1.0
- See Also:
-
parameterInts
Retrieves the values of a parameter as an array of integers.- Parameters:
name- the name of the parameter- Returns:
- an integer array with all the parameter values; or
nullif no parameter values are present - Since:
- 1.0
- See Also:
-
parameterLongs
Retrieves the values of a parameter as an array of longs.- Parameters:
name- the name of the parameter- Returns:
- a long array with all the parameter values; or
nullif no parameter values are present - Since:
- 1.0
- See Also:
-
parameterFloats
Retrieves the values of a parameter as an array of floats.- Parameters:
name- the name of the parameter- Returns:
- a float array with all the parameter values; or
nullif no parameter values are present - Since:
- 1.0
- See Also:
-
parameterDoubles
Retrieves the values of a parameter as an array of doubles.- Parameters:
name- the name of the parameter- Returns:
- a double array with all the parameter values; or
nullif no parameter values are present - Since:
- 1.0
- See Also:
-
parametersBean
Creates an instance of a bean and populates the properties with the parameter values.This bean is not serialized or de-serialized, each property corresponds to a parameter and is individually sent by the client.
- Parameters:
beanClass- the class of the submission bean- Returns:
- the populated bean instance
- Throws:
EngineException- Since:
- 1.0
- See Also:
-
parametersBean
public <BeanType> BeanType parametersBean(Class<BeanType> beanClass, String prefix) throws EngineException Creates an instance of a bean and populates the properties with the parameter values, taking the provided prefix into account.This bean is not serialized or de-serialized, each property corresponds to a parameter and is individually sent by the client.
- Parameters:
beanClass- the class of the submission beanprefix- the prefix that will be put in front of each property name- Returns:
- the populated bean instance
- Throws:
EngineException- Since:
- 1.0
- See Also:
-
parametersBean
Fills the properties of an existing bean with the parameter values.- Parameters:
bean- the submission bean instance that will be filled- Throws:
EngineException- Since:
- 1.0
- See Also:
-
parametersBean
Fills the properties of an existing bean with the parameter values that were sent, taking the provided prefix into account.- Parameters:
bean- the submission bean instance that will be filledprefix- the prefix that will be put in front of each property name- Throws:
EngineException- Since:
- 1.0
- See Also:
-
body
Retrieves the body of this context's request as a string.- Returns:
- the string of the request body
- Since:
- 1.0
- See Also:
-
bodyAsBytes
public byte[] bodyAsBytes()Retrieves the body of this context's request as a byte array.- Returns:
- the byte array of the request body
- Since:
- 1.0
- See Also:
-
fileNames
Retrieves the list of uploaded file names.- Returns:
- the set of uploaded file names
- Since:
- 1.0
- See Also:
-
isFileEmpty
Checks if an uploaded file wasn't sent or if it is empty.- Parameters:
name- the name of the file- Since:
- 1.0
- See Also:
-
files
Retrieves the files that were uploaded in this context.- Returns:
- a
Mapwith all the uploaded files - Since:
- 1.0
- See Also:
-
hasFile
Checks if a particular file has been uploaded in this context.- Parameters:
name- the name of the file- Returns:
trueif the file was uploaded; orfalseotherwise- Since:
- 1.0
- See Also:
-
file
Retrieves an uploaded file.- Parameters:
name- the name of the file- Returns:
- the uploaded file; or
nullif no file was uploaded - Since:
- 1.0
- See Also:
-
files
Retrieves all files that have been uploaded for a particular name.- Parameters:
name- the name of the file- Returns:
- the uploaded files; or
nullif no files were uploaded for that name - Since:
- 1.0
- See Also:
-
hasCookie
Checks whether a cookie is present.- Parameters:
name- the name of the cookie- Returns:
trueif the cookie was present; orfalseotherwise- Since:
- 1.0
- See Also:
-
cookieNames
Retrieves the names of the cookies.- Returns:
- a list of strings with the cookie names
- Since:
- 1.0
- See Also:
-
cookieValue
Retrieves the value of a cookie.- Parameters:
name- the name of the cookie- Returns:
- the value of the cookie; or
nullif no such cookie is present - Since:
- 1.0
- See Also:
-
cookieValues
Retrieves all current cookies names with their values.- Returns:
- a new map of all the current cookies names with their values
- Since:
- 1.0
- See Also:
-
cookieValue
Retrieves the value of a named cookie, using a default value as fallback.- Parameters:
name- the name of the cookiedefaultValue- the default value that will be used when no cookie value is present- Returns:
- the cookie value; or
the default value if no cookie value is present
- Since:
- 1.0
- See Also:
-
cookieBoolean
Retrieves the value of a named cookie and converts it to a boolean.- Parameters:
name- the name of the cookie- Returns:
- the converted cookie value; or
falseif no cookie value is present or if the cookie value is not a valid boolean - Since:
- 1.0
- See Also:
-
cookieBoolean
Retrieves the value of a named cookie and converts it to a boolean, using a default value if no input value is present.- Parameters:
name- the name of the cookiedefaultValue- the default value that will be used when no cookie value is present- Returns:
- the converted cookie value; or
the default value if no cookie value is present
- Since:
- 1.0
- See Also:
-
cookieInt
Retrieves the value of a named cookie and converts it to an integer.- Parameters:
name- the name of the cookie- Returns:
- the converted cookie value; or
0if no cookie value is present or if the cookie value is not a valid integer - Since:
- 1.0
- See Also:
-
cookieInt
Retrieves the value of a named cookie and converts it to an integer, using a default value if no input value is present.- Parameters:
name- the name of the cookiedefaultValue- the default value that will be used when no cookie value is present- Returns:
- the converted cookie value; or
the default value if no cookie value is present
- Since:
- 1.0
- See Also:
-
cookieLong
Retrieves the value of a named cookie and converts it to a long.- Parameters:
name- the name of the cookie- Returns:
- the converted cookie value; or
0Lif no cookie value is present or if the cookie value is not a valid long - Since:
- 1.0
- See Also:
-
cookieLong
Retrieves the value of a named cookie and converts it to a long, using a default value if no input value is present.- Parameters:
name- the name of the cookiedefaultValue- the default value that will be used when no cookie value is present- Returns:
- the converted cookie value; or
the default value if no cookie value is present
- Since:
- 1.0
- See Also:
-
cookieDouble
Retrieves the value of a named cookie and converts it to a double.- Parameters:
name- the name of the cookie- Returns:
- the converted cookie value; or
0.0dif no cookie value is present or if the cookie value is not a valid double - Since:
- 1.0
- See Also:
-
cookieDouble
Retrieves the value of a named cookie and converts it to a double, using a default value if no input value is present.- Parameters:
name- the name of the cookiedefaultValue- the default value that will be used when no cookie value is present- Returns:
- the converted cookie value; or
the default value if no cookie value is present
- Since:
- 1.0
- See Also:
-
cookieFloat
Retrieves the value of a named cookie and converts it to a float.- Parameters:
name- the name of the cookie- Returns:
- the converted cookie value; or
0.0f if no cookie value is present or if the cookie value is not a valid float - Since:
- 1.0
- See Also:
-
cookieFloat
Retrieves the value of a named cookie and converts it to a float, using a default value if no input value is present.- Parameters:
name- the name of the cookiedefaultValue- the default value that will be used when no cookie value is present- Returns:
- the converted cookie value; or
the default value if no cookie value is present
- Since:
- 1.0
- See Also:
-
attribute
Returns the value of the named attribute.- Parameters:
name- the name of the attribute- Returns:
- an Object containing the value of the attribute; or
nullif the attribute does not exist - Since:
- 1.0
- See Also:
-
hasAttribute
Checks if a request attribute exists.- Parameters:
name- aStringspecifying the name of the attributefalseotherwise- Since:
- 1.0
- See Also:
-
attributeNames
Returns a list of attribute names available to this request.- Returns:
- a list of strings containing the names of the request's attributes; or
an empty list if not attributes are present
- Since:
- 1.0
- See Also:
-
removeAttribute
Removes an attribute from this request. This method is not generally needed as attributes only persist as long as the request is being handled.- Parameters:
name- the name of the attribute to remove- Since:
- 1.0
- See Also:
-
setAttribute
Stores an attribute in this request. Attributes are reset between requests.Attribute names should follow the same conventions as package names. If the object passed in is
null, the effect is the same as callingremoveAttribute.- Parameters:
name- the name of the attribute to setobject- the object to store- Since:
- 1.0
- See Also:
-
characterEncoding
Returns the name of the character encoding used in the body of this request.- Returns:
- a
Stringcontaining the name of the character encoding; ornullif the request does not specify a character encoding - Since:
- 1.0
-
contentType
Returns the MIME type of the body of the request, or null if the type is not known.- Returns:
- a
Stringcontaining the name of the MIME type of the request; ornullif the type is not known - Since:
- 1.0
-
header
Returns the value of the specified request header as a String.- Parameters:
name- the case-insensitive name of the header- Returns:
- a
Stringwith the value of the requested header; ornullif the request does not have a header of that name - Since:
- 1.0
- See Also:
-
headerDate
Returns the value of the specified request header as a long value that represents a date. Use this method with headers that contain dates, such as If-Modified-Since.- Parameters:
name- the case-insensitive name of the header- Returns:
- a long value representing the date specified in the header expressed
as the number of milliseconds since January 1, 1970 GMT; or
-1if the named header was not included with the request - Throws:
IllegalArgumentException- if the header can't be converted to a date- Since:
- 1.0
- See Also:
-
headerInt
Returns the value of the specified request header as an int.- Parameters:
name- the case-insensitive name of the header- Returns:
- an integer expressing the value of the request header; or
-1if the request doesn't have a header of this name - Throws:
NumberFormatException- if the header value can't be converted to an int- Since:
- 1.0
- See Also:
-
headerNames
Returns a list of all the header names in the request.- Returns:
- a list of all the header names sent with this request;
if the request has no headers, an empty list will be returned
- Since:
- 1.0
- See Also:
-
headers
Returns all the values of the specified request header as a list ofStringobjects.Some headers, such as
Accept-Languagecan be sent by clients as several headers each with a different value rather than sending the header as a comma separated list.- Parameters:
name- the case-insensitive name of the header- Returns:
- a list containing the values of the requested header;
itf the request does not have any headers of that name an empty list will be returned
- Since:
- 1.0
- See Also:
-
locale
Returns the preferredLocalethat the client will accept content in, based on theAccept-Languageheader.If the client request doesn't provide an Accept-Language header, this method returns the default locale for the server.
- Returns:
- the preferred Locale for the client
- Since:
- 1.0
-
locales
Returns a list ofLocaleobjects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on theAccept-Language} header.If the client request doesn't provide an Accept-Language header, this method returns a list containing one Locale, the default locale for the server.
- Returns:
- a list of preferred Locale objects for the client
- Since:
- 1.0
-
remoteAddr
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.- Returns:
- a String containing the IP address of the client that sent the request
- Since:
- 1.0
-
remoteUser
Returns the login of the user making this request.Whether the username is sent with each subsequent request depends on the browser and type of authentication.
- Returns:
- a String specifying the login of the user making this request; or
nullif the user login is not known - Since:
- 1.0
-
remoteHost
Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address.- Returns:
- a String containing the fully qualified name of the client
- Since:
- 1.0
-
session
Returns the current session associated with this request, or if the request does not have a session, creates one.- Returns:
- the
Sessionassociated with this request - Since:
- 1.0
- See Also:
-
session
Returns the currentSessionassociated with this request or, if there is no current session andcreateis true, returns a new session.If
createisfalseand the request has no validSession, this method returnsnull.- Parameters:
create-trueto create a new session for this request if necessary;falseto returnnullif there's no current session- Returns:
- the
Sessionassociated with this request ornullifcreateisfalseand the request has no valid session - Since:
- 1.0
-
serverPort
public int serverPort()Returns the port number to which the request was sent.- Returns:
- an integer specifying the port number
- Since:
- 1.0
-
protocol
Returns the name and version of the protocol the request uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1.- Returns:
- a String containing the protocol name and version number
- Since:
- 1.0
-
scheme
Returns the name of the scheme used to make this request.- Returns:
- the name of the scheme used to make this request
- Since:
- 1.0
-
serverName
Returns the host name of the server to which the request was sent.- Returns:
- the name of the server
- Since:
- 1.0
-
contextPath
Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". The container does not decode this string.- Returns:
- the portion of the request URI that indicates the context of the request
- Since:
- 1.0
-
secure
public boolean secure()Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.- Returns:
- a boolean indicating whether the request was made using a secure channel
- Since:
- 1.0
-
enableTextBuffer
public void enableTextBuffer(boolean enabled) Enables or disables the response text buffer. By default, it is enabled.Disabling an enabled text buffer, flushes the already buffered content first.
If the text buffer is disabled, text content will be sent immediately to the client, this can decrease performance. Unless you need to stream content in real time, it's best to leave the text buffer enabled. It will be flushed and sent in one go at the end of the request.
- Parameters:
enabled-trueto enable the text buffer; orfalseto disable it- Since:
- 1.0
- See Also:
-
textBufferEnabled
public boolean textBufferEnabled()Indicates whether the response text buffer is enabled or disabled.- Returns:
trueif the text buffer is enabled; orfalseif it is disabled- Since:
- 1.0
- See Also:
-
clearBuffer
public void clearBuffer()Clears the text buffer is it's enabled.If the text buffer is disabled, this method does nothing.
- Since:
- 1.0
-
flush
public void flush()Forces all the streamed content to be output to the client.If the text buffer is enabled, this will flush its content to the output stream first.
- Since:
- 1.0
-
outputStream
Returns an output stream suitable for writing binary data in the response.When possible and applicable, this output stream will automatically handle gzip encoding.
- Returns:
- an
OutputStreamfor binary data output - Throws:
EngineException- Since:
- 1.0
-
setContentType
Sets the content type of the response being sent to the client.- Parameters:
contentType- the MIME type of the content- Since:
- 1.0
-
setContentLength
public void setContentLength(int length) Sets the length of the content body in the response.- Parameters:
length- an integer specifying the length of the content being returned to the client- Since:
- 1.0
-
setLocale
Sets the locale of the response.- Parameters:
locale- the locale of the response- Since:
- 1.0
-
setParameter
Sets a named parameter value for URL generation withurlFor(rife.engine.Route)or the `route:` filtered template value tags.The parameter value will be converted to a string array.
Setting parameters acts on a different collection than incoming request parameters and is used for RIFE2 state-related features like URL generation.
- Parameters:
name- the name of the parameter to setvalue- the value of the parameter- Since:
- 1.0
- See Also:
-
setParametersBean
Sets named parameters values from bean properties for URL generation withurlFor(rife.engine.Route)or the `route:` filtered template value tags.- Parameters:
bean- the bean whose properties will be set as parameters- Since:
- 1.0
- See Also:
-
setParametersBean
Sets named parameters values from bean properties for URL generation withurlFor(rife.engine.Route)or the `route:` filtered template value tags.- Parameters:
bean- the bean whose properties will be set as parametersprefix- the prefix that will be added to the parameter names- Since:
- 1.0
- See Also:
-
removeParameter
Removes a name parameter that was previously set.- Parameters:
name- the name of the parameter to remove- Since:
- 1.0
- See Also:
-
addCookie
Adds theCookiecreated by aCookieBuilderto the response. This method can be called multiple times to set more than one cookie.- Parameters:
builder- theCookieBuilderto use for building theCookie- Since:
- 1.0
-
removeCookie
Removes a cookie with path"/".- Parameters:
name- name of the cookie- Since:
- 1.0
-
removeCookie
Removes a cookie with given path and name.- Parameters:
path- path of the cookiename- name of the cookie- Since:
- 1.0
-
setHeader
Sets a response header with the given name and value.If the header had already been set, the new value overwrites the previous one.
- Parameters:
name- the name of the headervalue- the additional header value- Since:
- 1.0
-
addHeader
Adds a response header with the given name and value.This method allows response headers to have multiple values.
- Parameters:
name- the name of the headervalue- the additional header value- Since:
- 1.0
-
setDateHeader
Adds a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch.If the header had already been set, the new value overwrites the previous one.
- Parameters:
name- the name of the header to setdate- the additional date value- Since:
- 1.0
-
addDateHeader
Adds a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch.This method allows response headers to have multiple values.
- Parameters:
name- the name of the header to setdate- the additional date value- Since:
- 1.0
-
setHeader
Adds a response header with the given name and integer value.If the header had already been set, the new value overwrites the previous one.
- Parameters:
name- the name of the headervalue- the assigned integer value- Since:
- 1.0
-
addHeader
Adds a response header with the given name and integer value.This method allows response headers to have multiple values.
- Parameters:
name- the name of the headervalue- the assigned integer value- Since:
- 1.0
-
setStatus
public void setStatus(int statusCode) Sets the status code for the response.- Parameters:
statusCode- the status code- Since:
- 1.0
-