aspose file tools*
The moose likes Java in General and the fly likes Help me with the calling of jasper reports through java code  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help me with the calling of jasper reports through java code  " Watch "Help me with the calling of jasper reports through java code  " New topic
Author

Help me with the calling of jasper reports through java code

Krish Khan
Ranch Hand

Joined: Dec 14, 2009
Posts: 46
Hello everyone..
I am new to jasper reports i am using NEtBeans6.5.1 and dowloaded the jasper plugins 3.5.2 and have the jar file jasper report 3.6.2 from netbeans i develop a jrxml file but now when i am trying to call that file though java code i am getting error like...

SEVERE: Servlet.service() for servlet action threw exception
java.lang.ClassNotFoundException: org.springframework.core.io.Resource


my code is..

public class SampleReportAction extends Action{
private ActionForward forward;

public SampleReportAction(){
super();
System.out.println("Call of Constructor");
}
DBUtil mdbc=new DBUtil();
Connection con = null;
Statement st=null;
ResultSet rs=null;

public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception{
Statement stmt=null;
File path=new File(".");
String SrcFolder="",reportSource="",reportDest="";
try {
SrcFolder = path.getCanonicalPath();
} catch (IOException ex) {}
reportSource = SrcFolder + File.separatorChar + "report" + File.separatorChar + "templates" + File.separatorChar + "checking.jrxml";
System.out.println("After report source ----"+reportSource);
Map params=new HashMap();
String mode = request.getParameter("mode");
System.out.println("mode value :::" +mode);

if(mode.equalsIgnoreCase("print")){



try{

con=mdbc.getConnection();
System.out.println("After getting connection----");
String abc=getQuery();
params.put("Query",abc);
System.out.println(abc);

JasperReport jasperReport =JasperCompileManager.compileReport(reportSource);
System.out.println("After JasperComplie....");

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,params,con);
JasperExportManager.exportReportToPdfFile(jasperPrint, "C:/Sadhat/sample_report");


boolean isExitOnClose = false;
JasperViewer view = new JasperViewer(jasperPrint,isExitOnClose);
view.pack();
view.setTitle("FirstIReport ");
view.setSize(1020,720);
view.setLocation(0,30);
view.setVisible(true);
JasperPrintManager.printReport(jasperPrint,true);

} catch(JRException ex){
ex.printStackTrace();
}
}
return forward;
}


public String getQuery(){
String Query="";
Query="select a.team,count(b.[user_id]),count(b.account_id) from [user] a, phone b where a.team is NOT NUll and a.[user_id]=b.[user_id] group by a.team;";
return Query;

}

}


PLease help me out... I will be pleased fr the one who help me out.. thanks in Advance...

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

Sadat,

Welcome to the Ranch.
Please read the following
http://faq.javaranch.com/java/CarefullyChooseOneForum
http://faq.javaranch.com/java/EaseUp
http://faq.javaranch.com/java/UseCodeTags

You have posted both your questions in the Meaningless Drivel forum. I am moving them to the appropriate forum. In future please do take care to post in the proper forum.
More tips on using the Ranch can be found here http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
So ... *is* that class in the classpath when you run the application?


Ping & DNS - my free Android networking tools app
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
Not a "beginning" question. Moving.
Krish Khan
Ranch Hand

Joined: Dec 14, 2009
Posts: 46
yeah these are the jar files in classpath..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
*What* are the jar files in classpath? What's the command you're using to run this code? Which of the files contains that class?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help me with the calling of jasper reports through java code