October 06, 2009

Jasper Repport

With Jasper Report it has been found that reporting is become easy to desing and integrate with Java application . So far there are many other way to represent a group of data in a organised manner using Jfree chart or iReport or some time may be usiong Open Lazlo. Similarly Jasper Report.... But obviously each has it's own essence and how to make that beat use in any application always comes with profound understanding with technical part .....

Step 1. Get a database connection and Retrive the result for the specific query .
*************************************************************************************

public static ResultSet establishConnection(){
Connection con = null;
Statement stmt = null;
ResultSet rs = null ;

try {
Class.forName("***********").newInstance();
con = DriverManager.getConnection("**********","username", "password");

stmt= con.createStatement();
rs = stmt.executeQuery("SELECT * FROM test.countrylist order by countryName") ;


} catch (Exception e) {
e.printStackTrace();
}

return rs;

}

*************************************************************************************



Step 2.Generate the JRXML file.


step 3.Pass the above with a HashMap in JasperFillManager.fillReport and then generate report.

*************************************************************************************

public static void generateReport(){

int i ;

try {
Date d;
JasperReport jasperReport;
JasperPrint jasperPrint;
ResultSet rs = establishConnection();
HashMap jasperParameter = new HashMap();
JRResultSetDataSource jasperReports = new JRResultSetDataSource(rs);

InputStream input = new FileInputStream(new File("F:/jaspertest.jrxml"));
JasperDesign design = JRXmlLoader.load(input);


jasperReport = JasperCompileManager.compileReport(design);
jasperPrint = JasperFillManager.fillReport(jasperReport,jasperParameter, jasperReports);


JasperExportManager.exportReportToPdfFile(jasperPrint, "F:/sample_report.pdf");
JasperExportManager.exportReportToHtmlFile(jasperPrint, "F:/sample_report.html" );


}
catch (JRException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}

}

*************************************************************************************

June 09, 2009

Struts conceptual questions.....

Some more questions from conceptual part of struts ....
And above all always go through a good tutorial before starting with these things as there is no intelligence to findout and rember the answers without understanding the logic behind that.....


1. How many minimum number of JAR file specific to Struts I need to start with a struts application ?

2. Which class basically populates the values coming from JSP pages to actionform ?

3. "Ideal struts architecture says we should not keep our business logic related thing inside a action form class "...(although it is absolutely possible) ....why?

4.Where or in which scope actually struts keeps instancees of it's action form ---a)request b)session ,c)application

5. What is the significance of load-on-startup with a positive , negative or zero? Now if the value is 10 in that case when the instance of that action class will be created ?
6. What are the parameter of a action forward class accepts ?

7. What is the name of controller in struts framework ?

8. How to setup a validator framework in struts ?

9. What are the different kind of actionform classes ?

10. Which class creates the instance of action class and what is the difference between a execute and perform ?

11. Discuss among various action classes and which one is most efficient in which business situation ?

12. What is the difference between struts 1.1 and struts 1.2 ?

13. How I can create a dropdown using struts tags and which will read value from session ?

14. How could I enable client side validation ?

Regards

Zatty

June 07, 2009

J2EE Interview Questions :

These are same critical questioned related to strust framework as well as JAVA :

1. What is green thread in Java ?
2. How final keyword differ from abstract ?
3. What is the order to write child and parent exception for same try block ?
4. How Java is open source ?
5. What are the property makes java a platform indepedent ?
6. Whether static class is possible ?
7. When a thread will come under deadlock condition ?
9. What is significance of public static void for the main() method in java ?
10. How Struts framework is better compared to spring ?
11. What is the difference between ArrayList and LinkList ?
12. What is the default size for a hashmap ?
13. What are the difference between a comparator and comparable interface ?
14. why global variable concept is not there in java ?


Here are some more on webtechnology ......

1. When cookies are harmfull...?
2. When a jsp file translated to a java file where actually it gets stored for tomcat , resin , JBoss servers ?
4. What is the maximum information a GET can carry ?
5. How struts handle client side validation ...?
6. Can we use thoes struts validator javascript methods in our own need in the same application ?
7. How client side validation can be enabled in struts ?
8. Where struts actually keeps the validator javascript methods and when these methods are generated ?
10. After request submission from a JSP page which method in struts framework basically decides the destinanation of the request ?
11. Which is better way to handle exception---within action class or in side the busines layer ?
12. How we can configure struts with spring ?
13. Point out one feature of struts which Spring framework doesnot has ?


Regards,
Zatty

May 09, 2009

Take some tutorial in J2ME

topic to discussed next :

1. Java network enabling code .
2. Struts validation .
3. javascript for different browser .

Regards ,
Zatty
Programmer in J2EE & SUN IDM