How can we pass parameter to server jasper report from cllient machine

0

I want to display jasper report in PDF format on client machine on the basis of value of dropdown list (parameter).

I had wriiten below code , but it giving me error file not found excepiton:

package com.org.Jasper;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.simext.DBquery.DBConnectivity;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRPrintPage;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;


public class BarcodelabelbyqtyJasper {
    
    private static JRViewerProvider viewerProvider = new SwingJRViewerProvider();
    
    public static void jasperreportdisplay(String name , Object m_inout_id ){
        Connection con = null;
    String sourceFileName =
             "http://192.168.0.107:4911/CustomReports/barcodeprint.jrxml";

        JasperPrint jasperPrint;
         // DataBeanList DataBeanList = new DataBeanList();
         // ArrayList<DataBean> dataList = DataBeanList.getDataBeanList();
            JRPrintPage object;
            ConcurrentHashMap<String, Object> params = new ConcurrentHashMap<String, Object>();
            params.put(name, m_inout_id);
        
    
        //  JRBeanCollectionDataSource beanColDataSource =
        //  new JRBeanCollectionDataSource(dataList);
          con = DBConnectivity.getOracleDBConnection();
        //  Map parameters = new HashMap();
          /**
           * Passing ReportTitle and Author as parameters
           */
       //   parameters.put("ReportTitle", "List of Contacts");
        //  parameters.put("Author", "Prepared By Manisha");

          try {
             //JasperFillManager.fillReportToFile(
            // sourceFileName, params, beanColDataSource);
             
             jasperPrint = JasperFillManager.fillReport( sourceFileName, params, con);
             JRViewerProvider viewerLauncher = getReportViewerProvider();
            // viewerLauncher.openViewer(jasperPrint, pi.getTitle()+" - " + reportPath);
             
          } catch (JRException e) {
             e.printStackTrace();
          
          }
    }
    
    public static void setReportViewerProvider(JRViewerProvider provider) {
        if (provider == null)
            throw new IllegalArgumentException("Cannot set report viewer provider to null");
        viewerProvider = provider;
    }

    /**
     * Get the current jasper report viewer provider
     * @return JRViewerProvider
     */
    public static JRViewerProvider getReportViewerProvider() {
        return viewerProvider;
    }
       
}

ERROR:

net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: http:\192.168.0.107:4911\CustomReports\barcodeprint.jrxml
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:110)
    at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:99)
    at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:272)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:745)
    at com.simext.Jasper.BarcodelabelbyqtyJasper.jasperreportdisplay(BarcodelabelbyqtyJasper.java:49)
    at org.apache.jsp.page2try_jsp._jspService(page2try_jsp.java:112)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:612)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:503)
    at java.lang.Thread.run(Unknown Source)

 

 


 

 

linathakur92's picture
Joined: Jun 19 2017 - 2:08am
Last seen: 2 months 1 day ago

0 Answers:

No answers yet
Feedback