public class JSONPage extends Object implements StreamablePage
Page
, that is used to send a JSON (JavaScript
Object Notation) content back to the browser. Used for Ajax based requests.
Contenttype is set to "application/json".Modifier and Type | Field and Description |
---|---|
static JSONPage |
EMPTY_PAGE |
Constructor and Description |
---|
JSONPage(Object jsonContent)
Initializes an instance of this class using the final content in JSON
form.
|
Modifier and Type | Method and Description |
---|---|
void |
addHeader(String header,
Date value)
Set a header field in the response before writing the page.
|
void |
addHeader(String header,
int value)
Set a header field in the response before writing the page.
|
void |
addHeader(String header,
String value)
Set a header field in the response before writing the page.
|
Object |
getContent() |
String |
getContentType()
Returns the content type of the page, for example "text/html".
|
List<Pair<String,Object>> |
getHeaders()
Returns the list of http-response-headers to be set on the
HttpServletResponse |
void |
output(Writer w) |
String |
show()
For a JSONPage, this is usually never called by the dispatcher; the content will be written directly to the writer of the response.
|
void |
writeTo(HttpServletResponse res)
Deprecated.
since ep 9.0; just return the page in your servlet methods. the required http-headers will be set automatically
|
public static final JSONPage EMPTY_PAGE
public JSONPage(Object jsonContent)
jsonContent
- the response content in JSON form.
If org.json.JSObject or org.json.JSONArray instances are used, the content can be streamed to the client
(in order to to preserve memory).
For all other types, the result of jsonObject.toString() is written to the responsepublic String getContentType()
Page
getContentType
in interface Page
public String show()
show
in interface Page
Page.show()
public Object getContent()
@Deprecated public void writeTo(HttpServletResponse res) throws IOException
res
- IOException
public List<Pair<String,Object>> getHeaders()
Page
HttpServletResponse
getHeaders
in interface Page
String
, Date
or Integer
public void addHeader(String header, String value)
HttpServletResponse.setHeader(String, String)
will be used to set to the new value.header
- the name of the headervalue
- the header valuepublic void addHeader(String header, Date value)
HttpServletResponse.setDateHeader(String,long)
will be used to set to the new value.header
- the name of the headervalue
- the header valuepublic void addHeader(String header, int value)
HttpServletResponse.setIntHeader(String,int)
will be used to set to the new value.header
- the name of the headervalue
- the header valuepublic void output(Writer w)
output
in interface StreamablePage
@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.