OZ e-Form Developer
  • OZ e-Form Concepts
  • 🌈e-Form DEVELOPER
    • Day 1: Welcome On Board
      • About Course
      • Preparations
      • OZ e-Form Overview
    • Day 2: e-Form Design
      • Designer Environments
      • e-Form Layout Structure
      • e-Form Components
      • e-Form From Documents
      • Preview / Export / Save
      • Hands-on Practice
    • Day 3: Dynamic e-Form
      • e-Form Scripting Guide
      • Hands-on Practice
      • Advanced Features
    • Day 4: e-Form Application
      • Server Deployment
      • Viewer In HTML
      • Viewer APIs
      • Prefilling e-Form
      • Submitting e-Form
      • Sending MemoryStream
    • Get Your Certificate
    • Design Guide
      • Dialogue Flow
        • Overview
        • Creating Dialogue Flow
        • Uploading e-Form to Server
        • Running Dialogue Flow
        • Group and Statement
        • Custom Styling
      • Multilingual e-Form
      • Miscellaneous
      • Videosign
        • Videosign User Guide
      • OZ Verifier
        • OZ Verifier Introduction
        • Implementation and Use
        • Requirements
      • HTML5 Editor
        • HTML5 Editor Introduction
        • HTML Editor
        • Requirements and Sample
    • Day 5. Server & Reporting
  • 🌈Server Developer
    • OZ Server Console
    • OZ Scheduler
      • Features
      • Installing OZ Scheduler
      • Scheduler Task
    • Binding & Exporting
      • Overview
      • Export API Example
        • Extract Input Data
        • Export with OZ Server
        • Export with Scheduler
        • Export with Scheduler Task
    • Repository Server
    • Sync Server
      • Overview
      • Installing Sync-Server
        • SSL configration
      • Sample Application
      • Implementation
    • QR Link Mobile Sign
  • 🌈Report Developer
    • Overview
      • About Course
      • Preparation
      • Report Designer Overview
    • Query Design
      • Database Connection
      • Designer Environment
      • Dataset Design
    • Report Design
      • Designer Environment
      • Components
      • Table
      • Master-Detail
      • ODI Parameter
      • CrossTab
      • Chart
  • 🌈MOBILE DEVELOPER
    • Android Native
    • iOS Native
    • TOTO Framework
      • TOTO Overview
      • Sample App Overview
      • Server Application
      • Android Project
  • ⬇️Product Downloads
  • 📚 Product Documentation
  • 📕Technical Guide
  • ⚛️ ReactJS Integration
Powered by GitBook
On this page

Was this helpful?

  1. Server Developer
  2. Binding & Exporting
  3. Export API Example

Export with OZ Server

Use RequestDispatcher

  1. param.put("connection.inputjson", inputData)

  2. request.setAttribute("OZViewerExportParam", param)

  3. getRequestDispatcher("/server")

  4. request.getAttribute("OZViewerExportResult")

OZViewerExport.jsp
<%@ page import="java.util.*,java.io.*"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%request.setCharacterEncoding("UTF-8");%>
<%
    String ozrName	= request.getParameter("ozrName");
    String exportFormat	= request.getParameter("exportFormat");
    String inputData	= request.getParameter("inputData");
    // Export env
    String exportPath = "C:\\Program Files\\Apache Software Foundation\\Tomcat 9.0\\webapps\\exported\\demo\\";
    String exportFile = ozrName + "_OZViewerExport." + exportFormat; // KYC_Form.ozr
    String exportFilePath = exportPath + exportFile;
    String ozrPath = "demo\\" + ozrName + ".ozr";
    // OZ parameters 	
    Hashtable param = new Hashtable();	
    param.put("connection.reportname", ozrPath);
    param.put("connection.inputjson", inputData); // data to bind with ozr
    param.put("export.mode", "silent");
    param.put("export.confirmsave", "flase"); // no confirm = silent
    param.put("export.format", exportFormat);
    param.put("export.path", exportPath);
    param.put("export.filename", exportFile);
    param.put("pdf.fontembedding", "true"); // embed the font used in the OZR into the target pdf
    // request OZ server to bind and export
    request.setAttribute("OZViewerExportParam", param);
    RequestDispatcher dispatcher = pageContext.getServletContext().getRequestDispatcher("/server");
    dispatcher.include(request, response);
try {
    // get result from OZ server 
    Object obj = request.getAttribute("OZViewerExportResult");
    if (obj != null) {
	Hashtable t = (Hashtable) obj;
	byte[] bytes = (byte[]) t.get(exportFilePath);
	if (bytes != null && writefile(bytes, exportFilePath)) { 
	    out.println("OZViewerExportResult:\n" + exportFilePath);
	} 
    } else {
	Throwable t = (Throwable) request.getAttribute("OZViewerExportError");
	if(t != null) {
	    throw t;
	} else {
	    throw new Exception("No result from OZ Server.");
	}
    }
} catch (Throwable e) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    response.sendError(500, sw.getBuffer().toString());
} finally {
}
%>
<%!
public boolean writefile(byte[] b, String path)
{
    BufferedOutputStream fout = null;
    boolean result = false;
    try{
	fout = new BufferedOutputStream(new FileOutputStream(path));
	fout.write(b);
	fout.flush();
	fout.close();
	fout = null;
	result = true;
    }catch(Exception e){
	result = false; 
    }finally{
	if(fout!=null) try{fout.close();}catch(Exception e){}
    }
    return result;
}
%>
PreviousExtract Input DataNextExport with Scheduler

Last updated 1 year ago

Was this helpful?

Example:

🌈
http://oz.ozeform.io/oz/export/export.html