Call .jrxml file from jsp
hi experts,
i created the jasper report file, and i want to call this file through the jsp.
plz help m.
i written the following code but it gives the error:
==code==
<%@ page import="java.sql.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.lang.Object" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%@ page import="net.sf.jasperreport.engine.*" %>
<%@ page import="net.sf.jasperreport.engine.util.*" %>
<%@ page import="net.sf.jasperreport.engine.export.*" %>
<%@ page import="net.sf.jasperreports.engine.JasperCompileManager" %>
<%@ page import="net.sf.jasperreports.engine.design.JRMultiClassCompiler" %>
<%@ page import="net.sf.jasperreports.engine.JasperManager" %>
<%@ page import="net.sf.jasperreports.engine.xml.JRXmlLoader" %>
<%@ page import="net.sf.jasperreports.engine.JasperPrint" %>
<%@ page import="net.sf.jasperreports.engine.JasperFillManager" %>
<%@ page import="net.sf.jasperreports.engine.JasperExportManager" %>
<%@ page import="net.sf.jasperreport.engine.JREmptyDataSource" %>
<%@ page import="net.sf.jasperreports.engine.JasperReport" %>
<%@ page import="net.sf.jasperreports.engine.design.*" %>
<%@ page import="net.sf.jasperreports.view.JasperViewer" %>
<%@ page import="net.sf.jasperreports.engine.JRException" %>
<%
String reportSource ="C:/apache-tomcat-6.0.16/webapps/ROOT/Emp/report/sample.jrxml";
String reportDest = "C:/apache-tomcat-6.0.16/webapps/ROOT/Emp/report/sample.html";
Map params = new HashMap();
try
JasperDesign jasperDesign=JRXmlLoader.load(reportSource);
JasperManager.loadXmlDesign("sample.jrxml");
JasperReport jasperReport =JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint =JasperFillManager.fillReport(jasperReport, params, new JREmptyDataSource());
JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest);
JasperViewer.viewReport(jasperPrint);
catch (JRException ex)
ex.printStackTrace();
%>
==error==
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 31 in the jsp file: /Emp/report/rept.jsp
JREmptyDataSource cannot be resolved to a type
28: JasperDesign jasperDesign=JRXmlLoader.load(reportSource);
29: JasperManager.loadXmlDesign("sample.jrxml");
30: JasperReport jasperReport =JasperCompileManager.compileReport(jasperDesign);
31: JasperPrint jasperPrint =JasperFillManager.fillReport(jasperReport, params, new JREmptyDataSource());
32: JasperExportManager.exportReportToHtmlFile(jasperPrint, reportDest);
33: JasperViewer.viewReport(jasperPrint);
34: }
plz help m.
Error log tells:
JREmptyDataSource cannot be resolved to a typeYou have missed "s" in package name. Instead of:
<%@ page import="net.sf.jasperreport.engine.JREmptyDataSource" %>do:
<%@ page import="net.sf.jasperreports.engine.JREmptyDataSource" %>Thanks,
Mrityunjoy
Similar Messages
-
Call .jrxml file from java or jsp
hello experts,
i want to know how to call or execute the .jrxml ie report file from the jsp or java
and how to pass the runtime query to the report?
urgntThe below posts should answer your question
[http://forums.sun.com/thread.jspa?threadID=5203324&messageID=9811077]
[http://forums-beta.sun.com/thread.jspa?messageID=9857221]
On the same note please make an effort to search google about jasper API. -
Calling jar file from jsp - serious problem !
Hi there, I'm trying to call a jar from a jsp file. I need an import clause in my jsp, to the class I want to use.
I'm using eclipse, and while i"m writing "<%= " and the begining of my class name , he autocompletes it and automatically puts an import of my class in the top of the html. It is very convenient , but the problem is that he underling the class name (in the impot: <%@page import="myClass"%>), and I get "The import myClass cannot be resolved" error.
I got an advice to put my class in a package, since it was in a default package. I did it. But now I have 2 problems:
1. I can't run my jar in command window: java - jar myJar.jar. in gives me: Exception in thread "main" java.lang.NoClassDefFoundError....
2. I still get an error - "The import myClass cannot be resolved" in the jsp, although I threw the old jar (that his class I want to use was out of package), and brought a new jar after creating it.
I hope I managed to clarify myself. I'll be thankful of any help !!!Hi MSoldier.
There are two ways to do this:
1) You use the java.lang.Runtime classes to start the java application in your JAR file, just like you would have done it from the command line. The Runtime class has three different exec() methods that can be used to run any program just like you would from the command line. Remember, using this method you will have to write everything just like if you run your Java application from the command line, incl. classpath etc. This way your Java application will be run as a separate process. When the application finishes the process is shutdown and the resources (RAM etc.) taken by it freed, just like when you shutdown any other application.
2) You can open the JAR file yourself from inside the JSP page, look inside the META-INF file to find the main class, and then calls the main class main method. There is an example of how to do this in the Java Tutorial available from Sun under the JAR files track. Check these links :
The Java Tutorial at Sun
http://java.sun.com/docs/books/tutorial/
The JAR File Tutorial at Sun
http://java.sun.com/docs/books/tutorial/jar/index.html
Opening JAR Files via the Java JAR File API
http://java.sun.com/docs/books/tutorial/jar/api/index.html
Note however, if you have just created some classes that you want to use from inside your JSP pages, and not a separate application that needs to be run separately, you should just include the JAR file with your custom classes inside the WEB-INF/lib directory. These classes are then automatically available to your JSP pages, just like the rest of the Java API.
I hope this answers your questions,
Kind Regards,
Jakob Jenkov
Software Architect
Jenkov Development
www.jenkov.com -
How to call class file from jsp without creating packages
i m using tomcat 5.5
i stored my class file into WEB-INF\Class directory
how to call that class file. from my jsp page.
i got some error.
i used package concept,that works fine.i m using tomcat 5.5
i stored my class file into WEB-INF\Class directory
how to call that class file. from my jsp page.
i got some error.
i used package concept,that works fine.Then use packages.
As of Java1.4, you can no longer import classes from the default package (no package declared) into classes that are packaged.
All Tomcat classes are in packages, including the compiled JSP.
Therefore: Your classes need to be in a package inorder to be imported and used by the JSP.
Why the problem? If you know it works with packages, why try not to use them? -
Calling RDF files from JSP files
Hi,
I created a report file using Oracle 9i Report Builder and save it as RDF extension.After that I deployed it into the server and it's working properly.But, when I created a simple JSP file(not a report) and try to call that RDF file from this JSP file,the web browser prompts for downloading the entire RDF file.Is there any way to aviod this prompting, and make it to proper ruuning from that JSP ??
Thanks &Regards
Rajesh K.RYou are in the wrong forum
Go to Reports -
How to call cystal report8 report file from jsp page
hi guys
present i am using cystal report8 already i am having ReportViewer.jar and ReportviewerBean.jar files
using that please send me sample code how to call that report from jsp page..
and how to pass the parameters from jsp page to crystalreport8 report file.
it was very urgent task to me..so please send sample code on above topic..
or send me crystalreport8 API
thanks
regardsHi,
I also want to work on crystal report but i dont have the ReportViewerBean.jar and ReportViewer.jar. So, please tell from where will i get those jar files.
Thanks in advanced. -
How to call java class file from jsp
hi
we need to call java classes (which are written separately in .java file )from jsp file. we need it for our project if anyone knows about please reply us.
bye
siva sankariyou can call the methods in a lot of ways. you could use scriptlets with the
<%@ page import="package.class"%> and then inside instantiate an object
<%
MyClass mc = new MyClass(parameters if any);
mc.theMethodYouWantToCall();
%>or as Madathil has stated,
or use the JSP tags
<jsp:useBean id="anyname" class="classname"/>and then use the getProperty tag
or even Custom Tags -
Calling java class from jsp page
Dear Friends.
I wrote jsp page and java class.
Am calling java class from jsp page. after processing result,
I have to refresh jsp page from java class.
processing time may take 5 minutes or 1 minute etc. that depends on user.
Can It be possible ? if possible , How ?Ok, I get a very strange error now:
org.apache.jasper.JasperException: Unable to compile class for JSPerror: An error has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
What is this??? Anyone? -
Hi all,
I can call html or jsp file from jsp file, but how can I call text file in jsp, I put my text file same lever asmy jsp file it don't work!
where I should put the text file??
thank youmary,
since you knew the file name ,when clicked in name send to server,read the file and write to servlet outputstream.
I think this would help you.
If anything wrong in mycode ..forums will help you further
BufferedInputStream bis=null;
BufferedOutputStream bos=null;
int bytesRead=0;
byte buff[]=new byte[1024];
File f=new File(test.txt);
try{
bis= new BufferedInputStream(new FileInputStream(f));
bytesRead=bis.read(buff,0,buff.length);
if(bytesRead!=-1){
// create a BufferedOutputStream from ServletOutputStream
bos=new BufferedInputStream(response.getOutputStream());
do{
bos.write(buff,0,bytesRead);
}while((bytesRead=bis.read(buff,0,buff.length))!=-1)
}catch(Exception e){
////error handling
} -
Calling an EJB from jsp - ServletException
I am unable to call an EJB from jsp, unless I put the actuall classes of
the EJB into the classpath. Is this the right way to do it?
The exception is:
Servlet failed with ServletException
javax.servlet.ServletException: Servlet class: 'jsp_servlet._result'
could not be loaded - the requested class wasn't found in the
classpath:
'/local/apps/bea/wlserver6.0/config/gmodomain/applications/.wl_temp_do_not_delete/wl_local_comp34107.war:/local/apps/bea/wlserver6.0/./config/gmodomain/applications/.wl_temp_do_not_delete/WEB-INF/_tmp_war_gmo_gmo_webwar:/local/apps/bea/wlserver6.0/config/gmodomain/applications/.wl_temp_do_not_delete/WEB-INF/_tmp_war_gmo_gmo_webwar'
at
weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:532)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:191)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:148)
at
weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:306)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:208)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1622)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
where result.jsp is the jsp page calling the EJB. I did an import of the
EJB classes in the jsp.
like i said, it works if I put the bean classes in the classpath. But is
it right?
if I have these in the exploded format, do I need to put anything in the
application web.xml under:
wlserver6.0/config/gmodomain/applications/DefaultWebApp_gmo/WEB-INF ?
redhat 6.2, wl6.0sp1
here are the xml files:
web.xml:
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<!--
$Id: web.xml,v 1.2 2001/03/14 22:23:03 jeff Exp $
$Source:
/usr/local/cvsroot/JUnitEE/example/components/web-war/WEB-INF/web.xml,v
$
-->
<web-app>
<display-name>My Web Application</display-name>
<description>none</description>
<ejb-ref>
<ejb-ref-name>MyWeb</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.blah.ejb.myweb.WyWebHome</home>
<remote>com.blah.ejb.myweb.MyWeb</remote>
</ejb-ref>
</web-app>
weblogic.xml:
<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web
Application 6.0//EN"
"http://www.bea.com/servers/wls600/dtd/weblogic-web-jar.dtd">
<weblogic-web-app>
<jsp-descriptor>
<jsp-param>
<param-name>
pageCheckSeconds
</param-name>
<param-value>
1
</param-value>
</jsp-param>
<jsp-param>
<param-name>
verbose
</param-name>
<param-value>
true
</param-value>
</jsp-param>
<jsp-param>
<param-name>compileCommand</param-name>
<param-value>/local/apps/jdk1.3.0_02/bin/javac</param-value>
</jsp-param>
</jsp-descriptor>
<reference-descriptor>
<ejb-reference-description>
<ejb-ref-name>MyWeb</ejb-ref-name>
<jndi-name>MyWeb</jndi-name>
</ejb-reference-description>
</reference-descriptor>
</weblogic-web-app>
thanks,
Gary
Did you package your JSPs in a WAR and your EJBs in a JAR and package the
WAR and JAR in an EAR? That is how to do it in 6.0. Works well.
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com
+1.617.623.5782
WebLogic Consulting Available
"gmo" <[email protected]> wrote in message
news:[email protected]...
> I am unable to call an EJB from jsp, unless I put the actuall classes of
> the EJB into the classpath. Is this the right way to do it?
> The exception is:
> Servlet failed with ServletException
> javax.servlet.ServletException: Servlet class: 'jsp_servlet._result'
> could not be loaded - the requested class wasn't found in the
> classpath:
>
'/local/apps/bea/wlserver6.0/config/gmodomain/applications/.wl_temp_do_not_d
elete/wl_local_comp34107.war:/local/apps/bea/wlserver6.0/./config/gmodomain/
applications/.wl_temp_do_not_delete/WEB-INF/_tmp_war_gmo_gmo_webwar:/local/a
pps/bea/wlserver6.0/config/gmodomain/applications/.wl_temp_do_not_delete/WEB
-INF/_tmp_war_gmo_gmo_webwar'
>
> at
>
weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav
a:532)
>
> at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:191)
>
> at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:148)
>
> at
>
weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:30
6)
>
> at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:208)
>
> at
>
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:246)
>
> at
>
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:1265)
>
> at
>
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1622)
>
> at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
>
> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
> where result.jsp is the jsp page calling the EJB. I did an import of the
> EJB classes in the jsp.
> like i said, it works if I put the bean classes in the classpath. But is
> it right?
> if I have these in the exploded format, do I need to put anything in the
> application web.xml under:
> wlserver6.0/config/gmodomain/applications/DefaultWebApp_gmo/WEB-INF ?
>
> redhat 6.2, wl6.0sp1
>
> here are the xml files:
> web.xml:
>
> <?xml version="1.0"?>
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
> 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
>
> <!--
> $Id: web.xml,v 1.2 2001/03/14 22:23:03 jeff Exp $
> $Source:
> /usr/local/cvsroot/JUnitEE/example/components/web-war/WEB-INF/web.xml,v
> $
> -->
>
> <web-app>
> <display-name>My Web Application</display-name>
> <description>none</description>
> <ejb-ref>
> <ejb-ref-name>MyWeb</ejb-ref-name>
> <ejb-ref-type>Session</ejb-ref-type>
> <home>com.blah.ejb.myweb.WyWebHome</home>
> <remote>com.blah.ejb.myweb.MyWeb</remote>
> </ejb-ref>
> </web-app>
>
> weblogic.xml:
>
> <!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web
> Application 6.0//EN"
> "http://www.bea.com/servers/wls600/dtd/weblogic-web-jar.dtd">
> <weblogic-web-app>
> <jsp-descriptor>
> <jsp-param>
> <param-name>
> pageCheckSeconds
> </param-name>
> <param-value>
> 1
> </param-value>
> </jsp-param>
> <jsp-param>
> <param-name>
> verbose
> </param-name>
> <param-value>
> true
> </param-value>
> </jsp-param>
> <jsp-param>
> <param-name>compileCommand</param-name>
> <param-value>/local/apps/jdk1.3.0_02/bin/javac</param-value>
> </jsp-param>
> </jsp-descriptor>
> <reference-descriptor>
> <ejb-reference-description>
> <ejb-ref-name>MyWeb</ejb-ref-name>
> <jndi-name>MyWeb</jndi-name>
> </ejb-reference-description>
> </reference-descriptor>
> </weblogic-web-app>
>
> thanks,
>
> Gary
>
>
-
Can anyone help??
I'm trying to call a webservice from within a JSP and i havent a clue how its done,
i have my IF and Impl and Client Coded and my stubs generated and service deployed and running, but i cannot figure out how to call the service from my JSP web-app.
Any help appreciated!Hi ,
Its easy to call a WS from jsp what you can do is this. Think in manner that u will be keeping the client classes on a particular container, then in same container you can refrence the classes and can invoke service through a jsp..this works in my case.. it depends what kind of client do u want to create may be static or proxy or DII -
Call .bat file from java code
I need to call an application that uses a .bat file to execute from a java program. Is that possible?
This is the .bat file:
importcli.exe ciaf2735 C:\Importcli\files\SAI2735*.txt
importcli.exe ciaf2735 C:\Importcli\files\CI2735*.txt
importcli.exe ciaf2735 C:\Importcli\files\SC2735*.txt
importcli.exe db1800 C:\Importcli\files\*.mdbmagaupe wrote:
I need to call an application that uses a .bat file to execute from a java program. Is that possible?
This is the .bat file:
importcli.exe ciaf2735 C:\Importcli\files\SAI2735*.txt
importcli.exe ciaf2735 C:\Importcli\files\CI2735*.txt
importcli.exe ciaf2735 C:\Importcli\files\SC2735*.txt
importcli.exe db1800 C:\Importcli\files\*.mdb
Hmmm, I wonder what would happen if there were a web search engine and you could research like this:
[http://www.google.com/search?hl=en&q=call+.bat+file+from+java] -
How to call java files from different directories
hi, how do i call java files from a different directory??
let say i got partA.java, and i need to include functions from partB.java which is in a different folder. how can i do that?Chicon wrote:
Hi nuttynibbles,
Before the class declaration in partA.java, you must have an import statement like :
import someDirectory.partB;
public class partA {
... and before you ask... you'll probably want to read through this http://java.sun.com/docs/books/tutorial/java/package/index.html -
How to call a webservice from JSP
I want to call a webservice from JSP? How can I do that .
Check out this OBE and I think it's pretty well documented in JDeveloper help.
http://www.oracle.com/technology/obe/obe1013jdev/10131/wsfromplsqlpackage/devwsfrom%20plsql.htm
Thanks, Rob -
How to call Java Beans from JSP (eg.put them in a WAR or package)
Can anyone explain to me what are the steps and ways to call java beans from JSP?
1st, put the javabean classes in the right place:
the web-inf/classes/your_bean.class directory of corresponding web application
2nd in your jsp page:
<jsp:useBean id="obj_var_name" class="your_bean"/>
<jsp:setProperty name="obj_var_name" property="smthg" value="smthg_calue"/>
Micheal
Maybe you are looking for
-
Syntax Error in Generation of Datasource
Hi, I am attempting to generate a datasource for a planning area in APO-DP. I go to Admin of DP & SNP, and in "Change Planning Area", I am in Extras-->Data extraction tools. I name the datasource "DCDatasource" and click to generate. A secondary s
-
Question 1: I am unable to load the Windows 8 Installation DVD in UEFI (only) mode on my T420s. As a result, I can only run the installer in Legacy mode (or both UEFI/Legacy which effectively means the same thing). This in turn means Windows 8 is ins
-
Alternative for / Problems with: "For all entries in data_package"
Hi Guys I doing some ABAP in a Start Rotine in BW and would like to do the following: select * from /BI0/PMATERIAL into table 0mat for all entries in DATA_PACKAGE where material = DATA_PACKAGE-/bic/zmaterial. But I get the following error: E:Wh
-
Can't repair or reset Keychain in OSX 10.10? What to do?
I'm having a problem with a user who just migrated to a new MacBook Air with OSX 10.10 installed, but something went wrong with his keychain during the migration. It now won't store any new passwords, even passwords for WI-FI networks, so he has to
-
Offline Gps for playbook india
I have a BB playbook 16gb version. I am in India. any offline Gps apps available for PB? mine is wifi version. but i cannot connect to wifi when i am outside so need an offline version