bhavinb73 Posted June 28, 2018 Share Posted June 28, 2018 Hello,I have already created .JRXML file using oracle as datasource, using Jasper studio 6.6.How can I use that file in my existing Springboot application so that I can add connection paramater, report parameter and display report to user in a seperate browser window. Thanks in advance. Link to comment Share on other sites More sharing options...
reportdev Posted June 28, 2018 Share Posted June 28, 2018 I'm using JFrame here, but you can change it to something else. public static void main(String[] args) throws ParseException, SQLException, JRException { Connection con = DriverManager.getConnection("jdbc:oracle", "user","password"); java.sql.Date sqlDate = new java.sql.Date((new SimpleDateFormat("MM/dd/yyyy").parse("07/01/2018")).getTime()); Map parameters = new HashMap(); Map<String, String> temp = new HashMap<String, String>(); parameters.put("paramName", sqlDate); String workingDir = System.getProperty("user.dir"); String file = workingDir + "\src\resources\main_jrxml.jasper"; System.out.println("Current working directory : " + file); JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(file); JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, con); JFrame frame = new JFrame("Report"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new JRViewer(jasperPrint)); frame.pack(); frame.setVisible(true); }}[/code] Link to comment Share on other sites More sharing options...
bhavinb73 Posted June 30, 2018 Author Share Posted June 30, 2018 Am not sure how can I respond to an "answer" given by user "reportdev". So please excuse me for that. User "reportdev" thank you for your quick response, really appreciate it. But, it seems like this is for a desktop application. There would be some ways to show the JFrame on a webpage, but am thinking taking JFrame on web page would not be best, although it might work. So, am still looking for a solution to show jasper report output (as a PDF or HTML) within web application (it can open another instance of browser or prompt user to save PDF file). Link to comment Share on other sites More sharing options...
reportdev Posted July 2, 2018 Share Posted July 2, 2018 there are so many community posts, which can guide you through exporting the jasperprint to a browser. please check those. https://community.liferay.com/forums/-/message_boards/message/10540696 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now