i-net Clear Reports

com.inet.report
Class ReportBridge

java.lang.Object
  extended by com.inet.report.ReportBridge

public class ReportBridge
extends java.lang.Object

This class bridges native applications with i-net Clear Reports. It can be used to control i-net Clear Reports from non-java object systems such as Windows COM, or PHP.

<script LANGUAGE="VBSCRIPT" RUNAT="SERVER">
    Sub Application_OnStart
    '*** Initialize the JVM

    Dim JvmCtl
    Set JvmCtl = Server.CreateObject("J2EECAS.JvmControl")
    JvmCtl.Classpath = c:\ClearReports.jar
    JvmCtl.StartJvm

    '*** Create a JavaServices object
    Dim JS
    Set JS = Server.CreateObject("J2EECAS.JavaServices")

    '*** Create a proxy through which static methods on the
    '*** com.inet.report.ReportBridge class can be called
    Dim ClearReports
    Set ClearReports = JS.GetJavaStaticsFor("com.inet.report.ReportBridge")
    Set Application("ClearReports") = ClearReports

End Sub
</script>

 

default.asp

<%
Option Explicit

Dim ClearReports
Set ClearReports = Application("ClearReports")

'*** request a container for parameters
Dim Parameters
Parameters = ClearReports.ParameterContainer

'*** put the user parameter in the container
Dim Key
For Each Key In Request.Form
    Parameters.put Key, CStr( Request.Form(Key) )
Next

For Each Key In Request.QueryString
    Parameters.put Key, CStr( Request.QueryString(Key) )
Next

'*** put the needed server enviroment in the parameter container
Dim url
url = "http://" & Request.ServerVariables("HTTP_HOST")
Parameters.put "http_server_port", url
Parameters.put "http_server", url
Parameters.put "context", CStr( Request.ServerVariables("URL") )
Parameters.put "locale", CStr( Request.ServerVariables( "HTTP_ACCEPT_LANGUAGE" ) )

Dim PageData
PageData = ClearReports.RequestContext( Parameters )
Response.BinaryWrite( PageData )
Response.ContentType = Parameters.get( "content" )
Response.end
%>



For PHP the example would read (the relevant parameters are in blue):

<?php

// request a java properties object
$p=new Java("java.util.Properties");
foreach ($HTTP_POST_VARS as $key => $val)
{
$p->put($key, $val);
}

foreach ($HTTP_GET_VARS as $key => $val)
{
$p->put($key, $val);
}

// add the needed server enviroment in the parameter container
$url="http://".$_SERVER["SERVER_NAME"];
$p->put("http_server_port", $url.":".$_SERVER['SERVER_PORT']);
$p->put("http_server", $url);
$p->put("context", $_SERVER['SCRIPT_NAME']);
$p->put("locale", array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : "en");

// create the report bridge to handle the request
$report_bridge=new Java("com.inet.report.ReportBridge");
$page_data=$report_bridge->RequestContext($p);
header("Content-type: ".$p->getProperty("content"));
print $page_data;

?>



Constructor Summary
ReportBridge()
          Creates a new Report bridge and connect to the i-net Clear Reports.
ReportBridge(java.util.Properties props)
          Creates a new Report bridge with a given properties and connect to the i-net Clear Reports.
 
Method Summary
static java.util.Properties ParameterContainer()
          A helper routine which creates a java.util.Properties
static java.util.Vector ParameterList()
          A helper routine which creates a java.lang.Vector
static byte[] RequestContext(java.util.Properties props)
          This method takes a properties object which should contain at least the keys "report", "http_server_port", "context", "language".
 void dispose()
          Clear all resources
 void execute()
          Executes the bridge, if necessary.
 Engine getEngine()
          After you have created a ReportBridge, you can use this method to obtain the engine.
 byte[] getResponseData()
          Returns the page data of the page as an byte array.
static void logDebug(java.lang.String msg)
          Writes a debug message into the i-net Clear Reports log file.
static void logError(java.lang.String msg)
          Writes an error message into the i-net Clear Reports log file.
static void logMessage(java.lang.String msg)
          Writes an info string into the i-net Clear Reports log file.
 

Constructor Detail

ReportBridge

public ReportBridge()
Creates a new Report bridge and connect to the i-net Clear Reports. This method requires that this Report Bridge was started to wait for local connections. (See the description of the main method and the natcReportBridge example provided for Apache/PHP). Local sockets is the fastest, but requires that you create a JNI file called natcReportBridge). If you do not want to use native JNI code, you can use Internet sockets instead to connect to the running i-net Clear Reports server. Please see the other constructors.

See Also:
ReportBridge(Properties)

ReportBridge

public ReportBridge(java.util.Properties props)
Creates a new Report bridge with a given properties and connect to the i-net Clear Reports. This method requires that this Report Bridge was started to wait for local connections. (See the description of the main method and the natcReportBridge example provided for Apache/PHP). Local sockets is the fastest, but requires that you create a JNI file called natcReportBridge).

Parameters:
props - The properties for the report (report=...&dll=...) that should be created locally.
If you do not want to use native JNI code, you can use Internet sockets instead to connect to the running i-net Clear Reports server. Please see the other two constructors.
Method Detail

ParameterContainer

public static java.util.Properties ParameterContainer()
A helper routine which creates a java.util.Properties

Returns:
a java.util.Properties object

ParameterList

public static java.util.Vector ParameterList()
A helper routine which creates a java.lang.Vector

Returns:
a java.util.Vector

RequestContext

public static byte[] RequestContext(java.util.Properties props)
This method takes a properties object which should contain at least the keys "report", "http_server_port", "context", "language". The byte-array returned is the following:

Parameters:
props - the HTTP request properties
Returns:
a response for a browser

getEngine

public Engine getEngine()
After you have created a ReportBridge, you can use this method to obtain the engine. You can use RDC to modify the engine and then call the execute method of the report bridge.

Returns:
An engine obtained or null if the server already holds a report with the properties you have used to create the ReportBridge. Example:
         Properties props = new Properties();
         props.put("report", "file:c:/test.rpt");
         ReportBridge bridge=new ReportBridge(props);
         Engine e = bridge.getEngine();
         if(e!=null) {
             // use RDC calls to modify the engine
             bridge.execute();
         }
         byte b[] = bridge.getResponseData();
         
See Also:
execute()

execute

public void execute()
Executes the bridge, if necessary.
Example:
 Properties props = new Properties();
 props.put("report", "file:c:/test.rpt");
 ReportBridge bridge=new ReportBridge(props);
 Engine e = bridge.getEngine();
 if(e!=null) {
     // use RDC calls to modify the engine
     bridge.execute();
 }
 byte b[] = bridge.getResponseData();
 


getResponseData

public byte[] getResponseData()
Returns the page data of the page as an byte array.
Example:
 Properties props = new Properties();
 props.put("report", "file:c:/test.rpt");
 ReportBridge bridge=new ReportBridge(props);
 Engine e = bridge.getEngine();
 if(e!=null) {
     // use RDC calls to modify the engine
     bridge.execute();
 }
 byte b[] = bridge.getResponseData();
 System.out.println(props.getProperty("content")); // --> application/crystalclear
 

Returns:
The page data as an byte array. Also the properties object is modified to contain an additional pair: content . <content type>

dispose

public void dispose()
Clear all resources


logDebug

public static void logDebug(java.lang.String msg)
Writes a debug message into the i-net Clear Reports log file.

Parameters:
msg - The debug message

logError

public static void logError(java.lang.String msg)
Writes an error message into the i-net Clear Reports log file.

Parameters:
msg - The error message

logMessage

public static void logMessage(java.lang.String msg)
Writes an info string into the i-net Clear Reports log file.

Parameters:
msg - The info string

i-net Clear Reports

Copyright © 1999-2011 by i-net software GmbH