Created
September 8, 2015 20:11
-
-
Save anonymous/7cbacb9856e9de8a2b1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- test function ---> | |
<CFFUNCTION name="getJSON" returntype="Struct" returnformat="JSON" output="no" access="remote"> | |
<!--- apache derby test table ---> | |
<cfquery name="Local.qData" datasource="someDatasource"> | |
SELECT LastName, FirstName FROM TestUTF8 | |
</cfquery> | |
<cfset Local.result = { lastName=qData.LastName, firstName=qData.FirstName}> | |
<cfreturn Local.result> | |
</cffunction> | |
<!--- simple jasper datasource test ---> | |
<cfscript> | |
urlObj = CreateObject("java", "java.net.URL").init("http://127.0.0.1:8500/SomeComponent.cfc?method=getJSON"); | |
conn = urlObj.openConnection(); | |
input = conn.getInputStream(); | |
// Test #1: simple datasource test | |
ds = createObject("java", "net.sf.jasperreports.engine.data.JsonDataSource").init(input); | |
writeDump("Done"); | |
</cfscript> | |
<!--- display utf8 response as string ---> | |
<cfscript> | |
urlObj = CreateObject("java", "java.net.URL").init("http://127.0.0.1:8500/SomeComponent.cfc?method=getJSON"); | |
conn = urlObj.openConnection(); | |
input = conn.getInputStream(); | |
reader = CreateObject("java", "java.io.InputStreamReader").init(input, "UTF-8"); | |
buffered = CreateObject("java", "java.io.BufferedReader").init(reader); | |
inputLine = buffered.readLine(); | |
while (!isNull(inputLine)) { | |
writedump(inputLine); | |
inputLine = buffered.readLine(); | |
} | |
buffered.close(); | |
reader.close(); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment