I am using Jasper report with java. I want to make the export file ask for the location to download when launching it as web app.
What i am doing now is. I am giving a path for the file(PDF,DOCX,XLS) to be exported in a location. What i need is, the browser should make a popup and ask for the file location to be downloaded just like firefox.
I've done it in a java application, by providing a path,
Connection conn = null;
ResultSet rs = null;
JasperReport jasperReport = null;
JasperPrint print = null;
String filename = "Report.pdf";
String query = "{CALL get_report_data()}";
try {
if (conn == null)
{
String hostName = "localhost";
String dbName = "test";
String userName = "root";
String password = "root";
try {
Class.forName("com.mysql.cj.jdbc.Driver");
String connectionURL = "jdbc:mysql://" + hostName + ":3306/" + dbName;
conn = DriverManager.getConnection(connectionURL, userName, password);
} catch (Exception e) {
System.out.println(e);
}
}
CallableStatement cstmt = conn.prepareCall(query);
rs = cstmt.executeQuery();
JRResultSetDataSource resultSetDataSource = new JRResultSetDataSource(rs);
jasperReport = JasperCompileManager
.compileReport("E:\\Eclipse 2019-03 Workspace\\Report\\static_land_report.jrxml");
Map<String, Object> parameters = new HashMap<String, Object>();
print = JasperFillManager.fillReport(jasperReport, parameters, resultSetDataSource);
JasperExportManager.exportReportToPdfFile(print, "E:\Eclipse 2019-03 Workspace\Report\static_land_report.pdf");
Now, i want the above code to be done in web app, and without providing the path.