code: public static JasperPrint generateJasperPrint(DynamicReport dr, LayoutManager layoutManager, Connection con, Map<String, Object> _parameters) throws JRException {
          log.info("generating JasperPrint");
          JasperPrint jp;
  
          if (_parameters == null)
              _parameters = new HashMap<String, Object>();
  
          visitSubreports(dr, _parameters);
          compileOrLoadSubreports(dr, _parameters, "r");
  
          DynamicJasperDesign jd = generateJasperDesign(dr);
          Map<String, Object> params = new HashMap<String, Object>();
          if (!_parameters.isEmpty()) {
              registerParams(jd, _parameters);
              params.putAll(_parameters);
          }
          registerEntities(jd, dr, layoutManager);
          layoutManager.applyLayout(jd, dr);
          JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).setProperty(JRCompiler.COMPILER_PREFIX, DJCompilerFactory.getCompilerClassName());
          //JRProperties.setProperty(JRCompiler.COMPILER_PREFIX, DJCompilerFactory.getCompilerClassName());
          JasperReport jr = JasperCompileManager.compileReport(jd);
          params.putAll(jd.getParametersWithValues());
          jp = JasperFillManager.fillReport(jr, params, con);
  
          return jp;
      }
docs: For running queries embebed in the report design
  
  @param dr
  @param layoutManager
  @param con
  @param _parameters
  @return
  @throws JRException