title: JasperReport export to pdf not working
body: <p>I have the following controller to export a report as <code>pdf, xls, csv</code>. The code for it is given below</p>
  
  <pre><code>@Controller
  @RequestMapping(value = ServicePath.COMMON_PREFIX + "/test-report")
  public class ReportController 
  {
  
  @Autowired
  private UserService userService;
  
  public static JasperDesign jasperDesign;
  public static JasperPrint jasperPrint;
  public static JasperReport jasperReport;
  public static String reportTemplateUrl = "/lms-internet/src/main/webapp/report.jrxml";
  
  @RequestMapping(method = RequestMethod.GET , value = "/pdf")
  public void generatePdf()
  {
      try{
      List&lt;User&gt; usersList = userService.findAll();
  
      JRDataSource JRdataSource = new JRBeanCollectionDataSource(usersList);
  
      InputStream resourceAsStream = Thread.currentThread().getContextClassLoader()
              .getResourceAsStream(reportTemplateUrl);
      //get report file and then load into jasperDesign
      jasperDesign = JRXmlLoader.load(resourceAsStream);
      //compile the jasperDesign
      jasperReport = JasperCompileManager.compileReport(jasperDesign);
  
      ByteArrayOutputStream output = new ByteArrayOutputStream();
      OutputStream outputfile = new FileOutputStream(new File("c:/temp/person.xls"));
  
      HashMap params = new HashMap();
  
      //fill the ready report with data and parameter
      jasperPrint = JasperFillManager.fillReport(jasperReport, params, JRdataSource);
  
      //coding for Excel
      JRXlsExporter exporterXls = new JRXlsExporter();
      exporterXls.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
      exporterXls.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, output);
      exporterXls.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);
      exporterXls.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
      exporterXls.exportReport();
      outputfile.write(output.toByteArray());
      }
      catch(Exception e)
      {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>When i run it, i get the following exception:</p>
  
  <pre><code>net.sf.jasperreports.engine.JRException: java.net.MalformedURLException
  </code></pre>
  
  <p>Can someone please tell me what did i do wrong and how to fix it. And also tell me where to add the jrxml file.</p>