27/12/2017 Calling Jasper Report From Java Web Application using JSP | javaknowledge
Home About Contact Privacy Policy DMCA Partners PrimeFaces Core Java
Swing Jasper report Android Sitemap
Calling Jasper Report From Java Web Application
Search...
using JSP
Posted on June 2, 2013 by admin 13 comments
As I mentioned earlier in my previous post that if you are creating a Follow Us!
JRXML/Jasper file using a particular version of iReport you must use
same set of jars for your application.
In this example I will show you how to call Jasper Report (.jasper) file
using JSP.
First create a web application in NetBeans, add the appropriate Recent Posts
version of jar files of Jasper Report you created with(see the required
jar files name here) and change your index.jsp file as follows. Your Struts2 Ajax Validation
report file needs connection, so also add mysql-connector-java- Struts2 Multiple
5.1.13-bin.jar to classpath. Finally place your .jasper file in web Configuration File
folder.
Struts2 Multiple
index.jsp Namespace
1 <%@ page import="java.io.*"%> Struts2 Introduction
2 <%@ page import="java.sql.Connection"%>
3 <%@ page import="java.sql.DriverManager"%> URL Rewriting Example
4 <%@ page import="java.util.HashMap"%> in JSF 2.0 using
5 <%@ page import="java.util.Map"%>
PrettyFaces
6 <%@ page import="net.sf.jasperreports.engine.*"%>
7
8
9 <%@page contentType="text/html" pageEncoding="UTF-
10 <!DOCTYPE HTML>
11 Recent
12 <html> Comments
http://www.javaknowledge.info/calling-jasper-report-from-java-web-application-using-jsp/ 1/7
27/12/2017 Calling Jasper Report From Java Web Application using JSP | javaknowledge
13 <head>
14 <meta http-equiv="Content-Type" content="t admin: If you want to
15 <title>JSP Page</title> choose Java then see
16 </head> this example ...
17 <body>
18 <h2>Hello World!</h2> admin: Does the same
19 <% thing happening when
20 Connection conn = null; you run from th ...
21 try {
22 Class.forName("com.mysql.jdbc.Driv admin: Are you running
23 conn = DriverManager.getConnection your application from
jar file? If ...
24 } catch (Exception ex) {
25 ex.printStackTrace();
26 }
27 File reportFile = new File(application
28 Map parameters = new HashMap();
29 byte[] bytes = JasperRunManager.runRep
30 Categories
31 response.setContentType("application/p
32 response.setContentLength(bytes.length ► Android (19)
33 ServletOutputStream outStream = respon
► Core Java (37)
34 outStream.write(bytes, 0, bytes.length
35 outStream.flush(); ► Free Projects (2)
36 outStream.close();
37 %>
► Hibernate (5)
38 </body> ▼ Jasper report (7)
39 </html>
» Calling Jasper
Report From Java
Application-
Working Example
» Calling Jasper
Report From Java
Web Application
using JSF 2.0
» Calling Jasper
Report From Java
Web Application
using JSP
» Display simple bar
chart using jasper
report
» How to Create
Subreport using
iReport
» How to Display
BLOB Image in
Jasper Report-Video
Tutorial
http://www.javaknowledge.info/calling-jasper-report-from-java-web-application-using-jsp/ 2/7
27/12/2017 Calling Jasper Report From Java Web Application using JSP | javaknowledge
Related Posts » How to Use Group
By in Jasper Report-
Video Tutorial
► JSF 2.0 (14)
► JSP & Servlet (9)
► JSTL 1.1 (4)
► NetBeans (2)
► PrimeFaces (8)
Calling Jasper Report Calling Jasper Report Display simple bar chart
From Java Web From Java Application- using jasper report ► Software (3)
Application using JSF 2.0 Working Example ► Spring (1)
► Struts2 (5)
► Tomcat (2)
Tag Cloud
How to Use Group By in How to Create Subreport How to Display BLOB
Jasper Report-Video using iReport Image in Jasper Report-
Tutorial Video Tutorial
Tweet Share 11 Like 11 Simpan Share
admin
Hello! I am Md. Abdul Bari; founder and
admin of javaknowledge; currently
providing training as a J2EE faculty in The
Computers Ltd. Dhaka, Bangladesh under
Meta
an IT Scholarship project provided by IDB-
BISEW. I am a self learner and passionate Site Admin
about training and writing. I am always Log out
trying my best to share my knowledge
Entries RSS
through my blog.
More Posts - Website Comments RSS
Follow Me: WordPress.org
http://www.javaknowledge.info/calling-jasper-report-from-java-web-application-using-jsp/ 3/7
27/12/2017 Calling Jasper Report From Java Web Application using JSP | javaknowledge
tagged with ireport, jasper report
Archives
Jasper report
70,286` Total Views Archives
Select Month
LEAVE A REPLY
Connect on
Logged in as onnnay. Log out? Facebook
Comment
Javaknowledge
3,747 likes
Like Page Sig
Be the first of your friends to like this
Post Comment
13 COMMENTS
Tweets by
Nitin August 10, 2013 2:43 pm @java_knowledge
Thanks Sir javaknowl…
@java_kn…
It’s really helpful. Now I am able to create PDF Android Apps
file from jsp. Development Bangla
Tutorial. fb.me/KLAg2npl
Reply
May 6, 2017
Manon August 30, 2013 8:18 pm javaknowl…
@java_kn…
I’ve tried your code.
Unfortunately I get several errors in my logfiles Embed View on Twitter
regarding STREAM:
java.lang.IllegalStateException: STREAM
at org.mortbay.jetty.Response.getWriter(Response.java:616) ~
[jetty-6.1.24.jar:6.1.24]
at
javax.servlet.ServletResponseWrapper.getWriter(ServletRespo
nseWrapper.java:122) ~[servlet-api-2.5-20081211.jar:na]
http://www.javaknowledge.info/calling-jasper-report-from-java-web-application-using-jsp/ 4/7
27/12/2017 Calling Jasper Report From Java Web Application using JSP | javaknowledge
Any idea on how to resolve this?
Reply
Manon August 30, 2013 8:19 pm
In addition, the code will simply not run on
older browsers.
What are your thoughts on this?
Reply
Shiva January 20, 2014 5:09 pm
i need to use jasper report in java web
application, such that i’ll create charts and table
based on the sql query(customized)
Reply
Shiva January 20, 2014 5:10 pm
creating both table and charts are dynamic
Reply
sandip February 17, 2014 2:56 pm
I want to create receipt .jsp format, for that I am
using jasper tool it it’s creating .xml file. So can
you suggest any tools to create receipt in .jsp
Reply
sami February 21, 2014 1:26 pm
hi bari…
if i run this example with my jasper ,it showing
error,below mentioned errors ,kindly solve this
error.thanks…..
http://www.javaknowledge.info/calling-jasper-report-from-java-web-application-using-jsp/ 5/7
27/12/2017 Calling Jasper Report From Java Web Application using JSP | javaknowledge
net.sf.jasperreports.engine.JRRuntimeException: No such
parameter REPORT_CONTEXT
net.sf.jasperreports.engine.fill.JRFillDataset.getParameterValue
(JRFillDataset.java:1050)
net.sf.jasperreports.engine.fill.JRFillDataset.getParameterValue
(JRFillDataset.java:1031)
net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValue
s(JRFillDataset.java:559)
net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBa
seFiller.java:1237)
net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java
:869)
net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java
:813)
net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58
)
net.sf.jasperreports.engine.JasperFillManager.fillReport(Jasper
FillManager.java:417)
net.sf.jasperreports.engine.JasperFillManager.fillReport(Jasper
FillManager.java:247)
net.sf.jasperreports.engine.JasperRunManager.runReportToPd
f(JasperRunManager.java:203)
org.apache.jsp.CallJasperReport_jsp._jspService(CallJasperRepo
rt_jsp.java:99)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.ja
va:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServlet
Wrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.ja
va:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334
)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
JSP CODE
Hello World!
Reply
Sandip February 24, 2014 4:16 pm
http://www.javaknowledge.info/calling-jasper-report-from-java-web-application-using-jsp/ 6/7
27/12/2017 Calling Jasper Report From Java Web Application using JSP | javaknowledge
Dude you just do one thing add all jar files
which is there in C:\Program
Files\Jaspersoft\iReport-
4.1.2\ireport\modules\ext.
And Also add mysql-connector-java-5.1.13-bin.jar file and
make sure you copy .jasper file in to Report package.
Reply
Pre. Comment 1 2 Next Comment
Journey to the way of Java...
http://www.javaknowledge.info/calling-jasper-report-from-java-web-application-using-jsp/ 7/7