<?xml version="1.0" encoding="UTF-8"?>
<!-- XPage which is not rendered but returns data like XML, JSON, etc.     -->
<!-- More: http://www.wissel.net/blog/d6plinks/shwl-7mgfbn                 -->

<xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false">
var externalContext = facesContext.getExternalContext();
var writer = facesContext.getResponseWriter();
var response = externalContext.getResponse();
// set content type, e.g. ...
// response.setContentType("application/json"); 

response.setHeader("Cache-Control", "no-cache");
// read parameters, e.g. ...
var param = context.getUrlParameter("myParam");
// write HTML output e.g. ...
// writer.write("{'jsonvar'='jsonvalue'}"); 

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
3 comment(s)Login first to comment...
Adam Foster
(at 05:06 on 15.10.2018)
writer.endDocument() is coming up as a unknown member, should it be writer.close() ?
Serdar Basegmez
(at 05:17 on 14.02.2012)
I did a second test...
Niklas Heidloff
(at 05:15 on 14.02.2012)
testing comments