ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Java J2EE  >>  Java Related  >>  Struts
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
can anyone help me to send the code for Jasper Reporting in 
java?plz
 Question Submitted By :: Kavitha.0205
I also faced this Question!!     Rank Answer Posted By  
 
  Re: can anyone help me to send the code for Jasper Reporting in java?plz
Answer
# 1
Hi am jasper report expert...Contact me for assistance
 
Is This Answer Correct ?    1 Yes 0 No
Shabbir Ahmed
 
  Re: can anyone help me to send the code for Jasper Reporting in java?plz
Answer
# 2
For Example use this code..I hope it will help u.
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.view.JasperViewer;
import org.apache.commons.digester.Digester;
import net.sf.jasperreports.engine.design.*;
import net.sf.jasperreports.engine.*;
import java.util.*;

public class Report 
{
	public void viewReport() 
	{


			String reportSource 
= "HelloReportWorld.jrxml";
			String reportDest 
= "HelloReportWorld.html";
			String name=null;
			System.out.println("Hello World!");
			Map<String, String> params = new 
HashMap<String, String>();
			params.put("reportTitle", "Shabbir 
Ahmed");
			params.put("author", "shabbir");
			params.put("startDate", (new 
java.util.Date()).toString());

			System.out.println("here1111111");
			try
			{
				System.out.println
("here222222222");
				
				JasperDesign jasperDesign = 
JasperManager.loadXmlDesign
("D:/Tomcat/bin/HelloReportWorld.jrxml");
				JasperReport jasperReport 
=JasperCompileManager.compileReport(jasperDesign);
				
				JasperPrint jasperPrint 
=JasperFillManager.fillReport(jasperReport, params, new 
JREmptyDataSource());
				
			
	JasperExportManager.exportReportToHtmlFile
(jasperPrint, reportDest);
				
				JasperViewer.viewReport
(jasperPrint);
				
				
			}

			catch (JRException ex)
			{
				System.out.println
("here6666666666666");
				ex.printStackTrace();
			}
			catch(Exception e)
			{
				System.out.println
(e.getMessage());
			}
	}
}
////////This simple example shows how to pass parameters to 
jrxml.as it is below.



<?xml version="1.0"?>
<!DOCTYPE jasperReport
  PUBLIC "-//JasperReports//DTD Report Design//EN" 
  "http://jasperreports.sourceforge.net/dtds/jasperreport.dt
d">

<jasperReport name="HelloReportWorld">
     <parameter name="reportTitle" 
class="java.lang.String"/>
    <parameter name="author" class="java.lang.String"/>
    <parameter name="startDate" class="java.lang.String"/>
<title>
        <band height="60">
            <textField>
                <reportElement x="0" y="10" width="500" 
height="40"/>
                <textElement textAlignment="Center">
                    <font size="24"/>
                </textElement>
                <textFieldExpression 
class="java.lang.String">
                    <![CDATA[$P{reportTitle}]]>
                </textFieldExpression>
            </textField>
            <textField>
                <reportElement x="0" y="40" width="500" 
height="20"/>
                <textElement textAlignment="Center"/>
                <textFieldExpression 
class="java.lang.String">
                    <![CDATA["Run by: " + $P{author} 
                        + " on " + $P{startDate}]]>
                </textFieldExpression>
            </textField>
        </band>
    </title>

    <detail>
        <band height="200">
            <staticText>
                <reportElement x="0" y="0" width="500" 
height="20"/>
                <text><![CDATA[Hello shabbir Report World!]]
></text>
            </staticText>
        </band>
    </detail>
</jasperReport>


////All the best
 
Is This Answer Correct ?    0 Yes 0 No
Shabbir Ahmed
 
 
 

 
 
 
Other Struts Interview Questions
 
  Question Asked @ Answers
 
what is the advantages and diadvantages of Struts?  1
how the error can be showed in the jsp page in struts? Wipro2
How do you know what to give for the "path " under in struts-config.xml ?  1
what is tiles in struts?  5
What is Hibernate?  3
What is meant by portals???  6
How do you customize ActionServlet? Ness-Technologies2
How data transfered from one formbean to another formbean?  4
how will you view ur jsp page to the client by using properties file? Wipro2
How to explain struts work flow TCS5
struts is thread safe or not ?give me answer as early as possible  2
what are tiles in struts? Wipro2
Is form beans are serializable or not? Magna-Infotech6
explain the struts-configuration file? TCS2
How to forward from Array List to Jsp in Struts ActionServlet class?  5
In Struts Programming which is the controller,which is the model?  9
drawback of Validation Framework where and how to write the connection pool object in the programe how to debug the programe and application in struts without using eclips  1
what is purpose cvs and vss in eclipse?  2
what are the type of forward class in Struts? Wipro3
collection framework hirarchy?  2
 
For more Struts Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com