Jump to content
We've recently updated our Privacy Statement, available here ×

thaniindia

Members
  • Posts

    2
  • Joined

  • Last visited

thaniindia's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. my existing server is running jasper reports using php-java bridge. my ex-colleague installed that server. I have no idea how he was installed. but currently we are using jasper ireports using the following php coding. we do not go to jasperserver to upload the reports. we put all our reports under 'reports' folder under '/var/www/reports' and specified the path in php file. can do the same thing? --------------------------------------------------------------------- <?php session_start(); ?> <?php ob_start(); ?> <?php require_once("http://localhost:8080/Java.inc"); /** * see if the java extension was loaded. */ function checkJavaExtension() { if(!extension_loaded('java')) { $sapi_type = php_sapi_name(); $port = (isset($_SERVER['SERVER_PORT']) && (($_SERVER['SERVER_PORT'])>1024)) ? $_SERVER['SERVER_PORT'] : '8080'; if ($sapi_type == "cgi" || $sapi_type == "cgi-fcgi" || $sapi_type == "cli") { if(!(PHP_SHLIB_SUFFIX=="so" && @dl('java.so'))&&!(PHP_SHLIB_SUFFIX=="dll" && @dl('php_java.dll'))&&!(@include_once("java/Java.inc"))&&!(require_once("http://127.0.0.1:$port/java/Java.inc"))) { error_log("extension not installed"); return "java extension not installed."; } } else { if(!(@include_once("java/Java.inc"))) { error_log("Requiring"); require_once("http://127.0.0.1:$port/java/Java.inc"); } } }else{ error_log("No exension loaded"); error_log(serialize(get_loaded_extensions())); } if(!function_exists("java_get_server_name")) { return "The loaded java extension is not the PHP/Java Bridge"; } return true; } /** * convert a php value to a java one... * @param string $value * @param string $className * @returns boolean success */ function convertValue($value, $className) { // if we are a string, just use the normal conversion // methods from the java extension... try { if ($className == 'java.lang.String') { $temp = new Java('java.lang.String', $value); return $temp; } else if ($className == 'java.lang.Boolean' || $className == 'java.lang.Integer' || $className == 'java.lang.Long' || $className == 'java.lang.Short' || $className == 'java.lang.Double' || $className == 'java.math.BigDecimal') { $temp = new Java($className, $value); return $temp; } else if ($className == 'java.sql.Timestamp' || $className == 'java.sql.Time') { $temp = new Java($className); $javaObject = $temp->valueOf($value); return $javaObject; } } catch (Exception $err) { echo ( 'unable to convert value, ' . $value . ' could not be converted to ' . $className); return false; } echo ( 'unable to convert value, class name '.$className. ' not recognised'); return false; } //Get Query string values $username = $_SESSION['loginid']; $report_format=$_GET['report_format']; $date = date('Y-m-d'); $report_date_time = date("F j, Y, g:i a"); $report_date=date('d-m-Y'); $sortby1=$_GET['sortby1']; $sortby2=$_GET['sortby2']; $sortby3=$_GET['sortby3']; $report_header="STUDENT REQUEST/ISSUES PENDING/OUTSTANDING REPORT AS AT {$report_date} "; $order_by=" ORDER BY {$sortby1},{$sortby2},{$sortby3}"; checkJavaExtension(); $class = new JavaClass('java.lang.Class'); $class->forName('com.mysql.jdbc.Driver'); $driverManager = new JavaClass('java.sql.DriverManager'); $conn = $driverManager->getConnection("jdbc:mysql://".DB_SERVER."/".DB_NAME."?user=".DB_USER."&password=".DB_PASS); if($report_format=='pdf') { $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager"); //report path and name $report = $compileManager->compileReport(realpath("reports/pending_request.jrxml")); $fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); //Assign Parameters $param = new Java("java.util.HashMap"); $param->put("report_filter", $report_filter); $param->put("order_by", $order_by); $param->put("report_date", $report_date); $param->put("report_date_time", $report_date_time); $param->put("report_header", $report_header); $jasperPrint = $fillManager->fillReport($report, $param, $conn); $outputPath = realpath(".")."/"."outputs/Pending_Request.pdf"; $exportManager = new JavaClass("net.sf.jasperreports.engine.JasperExportManager"); $exportManager->exportReportToPdfFile($jasperPrint, $outputPath); header("Content-type: application/pdf"); readfile($outputPath); unlink($outputPath); } ?>
  2. I have installed ubuntu server with php mysql webapplication. Also installed jasperserver 5.5.0 in the same server. Now I have designed reports using iReports and placed in server /var/www/ directory. Now I want to display this report in pdf/xls in client's browser. I have searched many guides, but doesnot work out for me. Can help me the step by step how to ? Thank you, Thanika
×
×
  • Create New...