Monday, May 7, 2012

Component design for web projects

JSP lets web designers employ the same component design principles that other software developers have been using for years. Rather than having to embed complex logic directly into pages through scripting code, or building page content into the programming logic, they can simply employ HTML layout around components. The component model’s ability to reuse common components can reduce development time and project complexity.
Isolating application logic from presentation layout is a necessity for web development organizations that are built around teams whose members have a diverse set of complementary skill sets. In many enterprises the web team is composed of both application developers and web developers. Java application developers are skilled in tasks such as exchanging information with a database and optimizing back-end server code for performance, while web developers are good with the presentation aspects such as interface design and content layout. In a componentized JSP development project, application developers are free to concentrate on developing components that encapsulate program logic, while web developers build the application around these components, focusing their energies on its presentation.
In some cases a single person may handle both aspects of design, but as project complexity grows, splitting up the tasks of the development process can yield a number of benefits. Even for web projects being handled by a small, unified team of developers, a component-based architecture makes sense. The flexibility offered by components allows a project to handle the sudden changes in requirements that often seem to accompany web projects.

Monday, April 23, 2012

Modelling Abstractions, Using Classes and Objects

Abstractions is one of the fundamental ways in which we handle complexity. An abstraction denotes the essential properties and behaviors of an object that differentiate it from other objects. The essence of OOP is modelling abstractions, using classes and objects, and the hard part in this endeavour is finding the right abstractions.
A class denotes a category of objects, and acts as a blueprint for creating such objects. A class models an abstraction by defining the properties and behaviors for the objects representing the abstraction. An object exhibits the properties and behaviors defined by its class. The properties of an object of a class are also called attributes, and are defined by fields in Java. A field in a class definition is a variable which can store a value that represents a particular property. The behaviors of an object of a class are also known as operations, and are defined using methods in Java. Fields and methods in a class definition are collectively called members.
As an example, we will implement different versions of a class that models the abstraction of a stack that can push and pop characters. The stack will use an array of characters to store the characters, and a field to indicate the top element in the stack. Using Unified Modeling Language (UML) notation, a class called CharStack is graphically depicted in Figure, which models the abstraction.  

Its intention is to illustrate the salient features of a class definition in Java, and not effective implementation of stacks.
A class definition consists of a series of member declarations. In the case of the class CharStack, it has two fields:
  • stackArray, which is an array to hold the elements of the stack (in this case characters)
  • topOfStack, which denotes the top element of the stack (i.e., index of the last character stored in the array)
The class CharStack has five methods that implement the essential operations on a stack:
  • push() pushes a character on to the stack
  • pop() removes and returns the top element of the stack
  • peek() returns the top element of the stack for inspection
  • isEmpty() determines whether the stack is empty
  • isFull() determines whether the stack is full
The class definition also has a method-like declaration with the same name as the class, (2). Such declarations are called constructors. As we shall see, a constructor is executed when an object is created from the class. However, the implementation details in the example are not important for the present discussion.

Tuesday, April 17, 2012

Use XML-Based Layouts for User Interface

 بِسۡمِ ٱللهِ ٱلرَّحۡمَـٰنِ ٱلرَّحِيمِ
It is technically possible to create and attach widgets to our activity purely through Java code, but the more common approach is to use an XML-based layout file. Dynamic instantiation of widgets is reserved for more complicated scenarios, where the widgets are not known at compile-time.
An XML-based layout is a specification of widgets' relationships to each other encoded in XML format. Specifically, Android considers XML-based layouts to be resources, and as such layout files are stored in the res/layout directory inside each Android project.
Each XML file contains a tree of elements specifying a layout of widgets and containers that make up one View. The attributes of the XML elements are properties, describing how a widget should look or how a container should behave. For example, if a Button element has an attribute value of android:textStyle = "bold", that means that the text appearing on the face of the button should be rendered in a boldface font style.
Most everything you do using XML layout files can be achieved through Java code. For example, you could use setTypeface() to have a button render its text in bold, instead of using a property in an XML layout. Since XML layouts are yet another file for you to keep track of, we need good reasons for using such files.
Perhaps the biggest reason is to assist in the creation of tools for view definition, such as a GUI builder in an IDE like Eclipse. Such GUI builders could, in principle, generate Java code instead of XML. The challenge is re-reading the definition in to support edits – that is far simpler if the data is in a structured format like XML than in a programming language. Moreover, keeping the generated bits separated out from hand-written code makes it less likely that somebody's custom-crafted source will get clobbered by accident when the generated bits get re-generated. XML forms a nice middle ground between something that is easy for tool-writers to use and easy for programmers to work with by hand as needed.

Saturday, April 14, 2012

How to Create Android Application to Support All Screen Sizes

بِسۡمِ ٱللهِ ٱلرَّحۡمَـٰنِ ٱلرَّحِيمِ
Android devices come with a wide range of screen sizes, from 2.8" tiny smartphones to 46" Google TVs. Android divides these into four buckets, based on physical size and the distance at which they are usually viewed: Small (under 3"), Normal (3" to around 4.5"), Large (4.5" to around 10"), Extra-large (over 10"). By default, your application will not support small screens, will support normal screens, and may support large and extra-large screens via some automated conversion code built into Android. We may want to test Android application on an emulator, or we may want to test it on a phone, or we may want to test it on a tablet. To run the Android application work better, we need to modify the manifest for our project, to add a <supports-screens> element, declaring what sizes we support and do not by modifying the AndroidManifest.xml file in the root of your project tree. Below is the example:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="apt.tutorial" android:versionCode="1" android:versionName="1.0"> <supports-screens android:xlargeScreens="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="false" /> <application android:label="@string/app_name"> <activity android:name=".LunchList" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
The application will not run on a small-screen device (typically under 3" diagonal screen size). However, it will run well on everything bigger than that.

Monday, March 26, 2012

Inheritance In Java

One of the fundamental mechanisms for code reuse in OOP, is inheritance. It allows new classes to be derived from an existing class. The new class (a.k.a. subclass, subtype, derived class, child class) can inherit members from the old class (a.k.a. superclass, supertype, base class, parent class). The subclass can add new behavior and properties, and under certain circumstances, modify its inherited behavior.
In Java, implementation inheritance is achieved by extending classes (i.e., adding new fields and methods) and modifying inherited members Inheritance of members is closely tied to their declared accessibility. If a superclass member is accessible by its simple name in the subclass (without the use of any extra syntax like super), then that member is considered inherited. This means that private, overridden, and hidden members of the superclass are not inherite. Inheritance should not be confused with the existence of such members in the state of a subclass object.
 Example Extending Classes: Inheritance and Accessibility
class Light {                       // (1)
    // Instance fields
              int     noOfWatts;    // wattage
    private   boolean indicator;    // on or off
    protected String  location;     // placement

    // Static fields
    private static int counter;     // no. of Light objects created

    // Constructor
    Light() {
        noOfWatts = 50;
        indicator = true;
        location  = "X";
        counter++;
    }

    // Instance methods
    public  void    switchOn()  { indicator = true; }
    public  void    switchOff() { indicator = false; }
    public  boolean isOn()      { return indicator; }
    private void    printLocation() {
         System.out.println("Location: " + location);
    }

    // Static methods
    public static void writeCount() {
         System.out.println("Number of lights: " + counter);
    }
    //...
}

class TubeLight extends Light {     // (2) Subclass uses the extends clause.
    // Instance fields
    private int tubeLength = 54;
    private int colorNo    = 10;

    // Instance methods
    public int getTubeLength() { return tubeLength; }

    public void printInfo() {
        System.out.println("Tube length: "  + getTubeLength());
        System.out.println("Color number: " + colorNo);
        System.out.println("Wattage: "      + noOfWatts); // Inherited.
    //  System.out.println("Indicator: "    + indicator); // Not Inherited.
        System.out.println("Indicator: "    + isOn());    // Inherited.
        System.out.println("Location: "     + location);  // Inherited.
    //  printLocation();                                  // Not Inherited.
    //  System.out.println("Counter: "    + counter);     // Not Inherited.
        writeCount();                                     // Inherited.
    }
    // ...
}

public class Utility {               // (3)
    public static void main(String[] args) {
       new TubeLight().printInfo();
    }
}
Output from the program:
Tube length: 54
Color number: 10
Wattage: 50
Indicator: true
Location: X
Number of lights: 1

The superclass is specified using the extends clause in the header of the subclass declaration. The subclass only specifies the additional new and modified members in its class body. The rest of its declaration is made up of its inherited members. If no extends clause is specified in the header of a class declaration, then the class implicitly inherits from the java.lang.Object class. This implicit inheritance is assumed in the declaration of the Light class at (1). Also , the subclass TubeLight at (2) explicitly uses the extends clause and only specifies additional members to what it already inherits from the superclass Light (which, in turn, inherits from the Object class). Members of the superclass Light that are accessible by their simple names in the subclass TubeLight, are inherited by the subclass.

Private members of the superclass are not inherited by the subclass and can only be indirectly accessed. The private field indicator of the superclass Light is not inherited, but exists in the subclass object and is indirectly accessible.
Using appropriate accessibility modifiers, the superclass can limit which members can be accessed directly and, thereby, inherited by its subclasses. The subclass can use the inherited members as if they were declared in its own class body. This is not the case for members that are declared private in the superclass. Members that have package accessibility in the superclass are also not inherited by subclasses in other packages, as these members are only accessible by their simple names in subclasses within the same package as the superclass.

Thursday, March 22, 2012

J2ME Configurations Overview

The configuration defines the basic run-time environment as a set of core classes and a specific JVM that run on specific types of devices. Currently, two configurations exist for J2ME, though others may be defined in the future:
  • Connected Limited Device Configuration (CLDC) is used specifically with the KVMfor 16-bit or 32-bit devices with limited amounts of memory. This is the configuration(and the virtual machine) used for developing small J2ME applications. Its sizelimitations make CLDC more interesting and challenging (from a development point ofview) than CDC. CLDC is also the configuration that we will use for developing ourdrawing tool application. An example of a small wireless device running smallapplications is a Palm hand-held computer.
  • Connected Device Configuration (CDC) is used with the C virtual machine (CVM) and is used for 32-bit architectures requiring more than 2 MB of memory. An example of such a device is a Net TV box.

Sunday, March 18, 2012

Major Categories of Markup Tags Provided by JSP

بِسۡمِ ٱللهِ ٱلرَّحۡمَـٰنِ ٱلرَّحِيمِ
JSP provides four major categories of markup tags. The first, directives, is a set of tags for providing the JSP container with page-specific instructions for how the document containing the directives is to be processed. Directives do not affect the handling of individual requests, but instead affect global properties of the JSP page that influence its translation into a servlet.
example:
<jsp:directive.page attribute1="value1" 
                 attribute2="value2" attribute3=… />
 
Scripting elements are used to embed programming instructions, written in the designated scripting language for the page, which are to be executed each time the page is processed for a request. Some scripting elements are evaluated purely for their side effects, but they may also be used to generate dynamic content that appears in the output of the page.
example:
<jsp:declaration> declaration(s) </jsp:declaration>

Comments are used for adding documentation strings to a JSP page. JSP supports multiple comment styles, including one which enables documentation to appear in the output from the page. Other JSP comments can only be viewed in the original JSP file, or in the source code for the servlet into which the page is translated.
example:
  <% /* comment */%>

Actions support several different behaviors. Like scripting elements, actions are processed for each request received by a page. Actions can transfer control between pages, specify applets, and interact with server-side JavaBeans components. Like scripting elements, actions may or may not generate dynamic content. All custom tags incorporated via extended tag libraries take the form of actions.

Friday, March 16, 2012

The Oracle Java Newsletter

 بِسۡمِ ٱللهِ ٱلرَّحۡمَـٰنِ ٱلرَّحِيمِ
It's always been that Java releases are EOLed after a certain time and users are encouraged to migrate to the latest release. With such a long time between Java 6 and Java 7, maybe people have forgotten that EOLing happens at all! The EOL date of Java SE 6 is November 2012. For details, read Updated Java 6 EOL Date. Also, as of December 20, 2012, JavaFX 1.2 and JavaFX 1.3 will no longer be available. All developers currently creating JavaFX 1.x applications available are strongly encouraged to migrate their applications to JavaFX 2. For more details, see The JavaFX Blog. We also recommend reading EOLing a Version of Java is Process, Not an Event. Did we mention Java is moving forward?
—The Oracle Technology Network Team
NEWS
 
On February 14th, Oracle announced three Java releases containing security fixes. If you haven't already downloaded your updates, here they are: Java SE 7 Update 3, Java SE 6 Update 31, and JavaFX 2.0.3.
Oracle GlassFish Server 3.1.2 improves upon its ease-of-use features with an improved administration console, support for the WebSocket Protocol RFC 6445, DCOM support, support for non-multicast clustering, and more. NetBeans IDE 7.1.1 supports GlassFish 3.1.2.
The URLs for the Java Language Specification and Java VM Specification have changed to http://docs.oracle.com/javase/specs/index.html. Please update your bookmarks and links as soon as possible. The old links will not be there forever! Thanks to Oracle Tech Pubs for taking good care of the Java specs and documentation.
Parleys.com has posted 63 more sessions from JavaOne 2011 for a total of 117 sessions from the conference. Also, you can watch a short excerpt from the JavaOne 2011 Technical Keynote about the newest innovations in the Java mobile and embedded space.
This book is a fast-paced tutorial for Java EE 6 business component development using EJB 3.1, JPA 2, and CDI. Get discount code and find more discounts at the OTN Member Discount Page.
JavaFX experts Jim Weaver, Weiqi Gao, Stephen Chin, Dean Iverson and Johan Vos have joined forces to write a book entitled Pro JavaFX 2; this definitive guide is now available!
Fabiane Bizinella Nardon is a computer scientist, community leader, and tools expert. She's been a Java Champion since 2005. Read Interview with Mission Impossible Java Hacker -- Fabiane Nardon. Listen to Java Champions, including Fabiane, live at JFokus. Learn more about the Java Champions program.
This new curriculum will include Java Fundamentals and Java Programming courses, designed especially for secondary schools and 2-year colleges, a comprehensive portfolio of Java courses for four-year colleges and universities, and training that supports teachers/faculty to deliver the Oracle Academy’s Java curriculum.
Recent studies by Dice.com, Robert Half Technology and others indicate that skilled Java developers are in high demand. Make sure you have the right set of skills and the certifications to prove it. You can save and get a free retake when you purchase the Oracle training and certification exam vouchers together with the Certification Value Package.
EVENTS
 
DevNexus Atlanta, Mar 21-22. Five tracks of great content for Java/JVM developers. Brought to you by the Atlanta Java Users Group (AJUG).
OTN Developer Days: Oracle ADF and Fusion Development  March-April. Experience a more productive approach for developing Java-based rich Web applications with Oracle ADF, Oracle BPM and Oracle WebCenter in free, hands-on workshops in Toronto, Dallas, London, Singapore, Jakarta, Makati City, Bangkok, and Kuala Lampur.
JUG Events for March Java User Groups are meeting all over the world to learn new technologies and share their knowledge. Check out the JUGs Calendar on Java.net to find events.
JavaOne Japan Tokoyo, April 4-5. Learning about all aspects of Java — Java's future, how to program with the new features of Java SE 7, to using other languages on the JVM and more.
Devoxx France Paris, April 17-19. Created by the Parisian Java User Group, Devoxx France follows the path of its Belgium brother to bring you an astonishing Java conference.
JavaOne Russia Moscow, Apr 17-18 & JavaOne India Hyderabad, May 3-4. Mark your calendar for the return of JavaOne – the powerhouse event that offers the developer community two days of unparalleled education, intense and informative debate, and numerous networking opportunities. Register now for JavaOne Russia or JavaOne India. 
TECHNICAL ARTICLES
 
Agile ALM: A Conversation with Java Champion and ALM Expert Michael Hüttermann “Agile ALM should result in processes and tool chains that are flexible, open to change, and high in quality, ” says Java Champion Michael Hüttermann. He discusses best Agile Application Lifecycle Management (ALM) practices for Java developers.
Laying Out a User Interface with JavaFX 2.0 Let JavaFX expert James Weaver show you how to use the layout capabilities of JavaFX 2.0 to make nodes in the scene graph appear where you want and stay the right size as windows are resized.
UI Construction with JavaFX Java expert Dierk König shows you how to create widgets, lay them out, style them, bind them to data, and attach handlers.
JSF 2.x Update from Ed Burns JSF spec lead Ed Burns shares his viewpoints on where JSF stands in light of Ajax, and HTML5, and what is happening in JSF 2.2.
Adding Some Agility to Java EE Application Deployment with GlassFish Developer Julien Ponge shows how four noteworthy features in GlassFish add agility to Java EE application deployment.
Coherence Clustering Principles Learn about the principles behind Coherence clustering.
VIDEOS, WEBCASTS, AND MORE
 
Webcast: Java SE 7 Language Enhancements Get an in-depth overview of the language enhancements you may be missing out on with Java SE 7 in this Mini Live Virtual Class session led by Oracle University instructor, Luis Segura.
Java Spotlight Podcast: Alex Buckley on the Java Language and VM Specs Hear Alex Buckley, spec lead for the Java Language and the Java Virtual Machine at Oracle, discuss the Java language and VM specifications.
Video: 5 Minutes With Java EE…Or With NetBeans + GlassFish Java Champion Adam Bien shows 5-minute development of an EJB 3.1, CDI, and JSF 2 hack (after a 3-minute installation of the whole environment).
Webcast Series: Oracle WebLogic Server 12c Register for this WebLogic developer webcast series and learn how developers are using WebLogic.
Virtual Developer Day Replay: Oracle WebLogic Server 12c On-demand presentations and hands-on workshops on lightweight development with Java EE 6.
Online Training: Advanced Oracle ADF Get a better understanding of Oracle ADF with these in-depth online training directly from your desk. Over 700 minutes of knowledge transfer available in a self-paced eCourse for free.
Song: Java People Zoran Sevarac wrote the lyrics after the JavaOne 2011 conference, talking about Java Comunity, open source, and the free software movement. Enjoy!

Friday, March 9, 2012

Benefits of a component architecture - JSP component model

 بِسۡمِ ٱللهِ ٱلرَّحۡمَـٰنِ ٱلرَّحِيمِ
Let’s look at an example of component-centric design that’s more concrete. When an architect designs a new home he or she relies on components to save time, reduce complexity, and cut costs. Rather than design every wall unit, window frame, and electrical system from scratch he or she uses existing components to simplify the task. Architects don’t design a custom air-conditioning system; they select an existing unit that will fit their requirements from the many models available on the market. There’s a good chance that the architect doesn’t have the skills or resources to design an air-conditioning system anyway. And conversely the designer of the air-conditioning system probably couldn’t build a house. Because of this component-based approach the architect and contractor can concentrate on building what they know best—houses, and the air-conditioning company can build airconditioners. Component architectures allow us to hide a component’s complexity behind an interface that allows it to interact with its environment or other components. It isn’t necessary to know the details of how a component works in order to access its functionality.
We can use this real world example to illustrate another important feature of component design—reusability. The construction company can select an off-theshelf air-conditioner because it supports standard connectors, fastens with standard screws, and runs off a standard electric voltage. Later, if the homeowner decides to replace the unit with a new and improved model, there is no need to rebuild the house—simply swap out the old component for the new. Standardized environments and design specifications have allowed for a flexible system that is easily maintained. Software components are designed to operate in specific environments, and interact in predetermined ways. The fact that components must follow a certain set of rules allows us to design systems that can accept a wide array of components.
While it would be nice if we could design our entire application from pre-existing components, that’s an approach that’s rarely practical for real application design. Usually an application developed with a component approach involves a combination of general purpose and application specific components. The benefits of component reuse sur face not only by sharing components among differing applications, but through reuse of components across several segments of the same or related applications.
A banking application, for example, might have several different customer interfaces, an employee access module, and an administrative screen. Each of these related applications could make use of a common component that contained all of the knowledge necessary to display the specifics of a particular bank account. With luck, and good forethought during component design, this banking component might be useful to anyone developing financial management applications.
Once a component has been designed, the component’s author is relatively free to change its inner-workings without having to track down all of the component’s users. The key to achieving this high level of abstractness is defining an interface that shields any application relying on the component from the details of its implementation.

Saturday, March 3, 2012

Learning Java Using the Eclipse IDE

بِسۡمِ ٱللهِ ٱلرَّحۡمَـٰنِ ٱلرَّحِيمِ
Advantages to learning Java using the Eclipse integrated development environment (IDE):
  • Eclipse provides a number of aids that make writing Java code much quicker and easier than using a text editor. This means that you can spend more time learning Java, and less time typing and looking up documentation.
  • The Eclipse debugger and scrapbook allow you to look inside the execution of the Java code. This allows you to “see” objects and to understand how Java is working behind the scenes.
  • Eclipse provides full support for agile software development practices such as test-driven development and refactoring. This allows you to learn these practices as you learn Java.
  • If you plan to do software development in Java, you’ll need to learn Eclipse or some other IDE. So learning Eclipse from the start will save you time and effort.
Downloading and Installing Eclipse
Before Installing Eclipse, you need to have either the Java JDK (Java development kit) or Java JRE  (Java runtime engine) installed on your computer. These are available at  http://java.sun.com/javase/downloads/index.jsp.
Installing the JDK or JRE is reasonably simple. Detailed, step-by-step instructions, if needed, are available in the PDF Eclipse Tutorial at the https://www.arctechsoftware.com/tutorial/welcomePage.do.
For Java development, the JDK is recommended because it allows you to see documentation and source code for the standard Java classes. However, either the JDK or JRE will work.

Here are the steps to install Eclipse 3.3 from www.eclipse.org:
  • Navigate to www.eclipse.org/downloads
  • Select “Eclipse IDE for Java Developers”. If your platform is Linux or MacOSX, be sure to select the link to the right. Note that you can use “Eclipse IDE for Java EE Developers”, “Eclipse for RCP/Plug-in Developers”, or “Eclipse Classic” as well. All of these include the Java development portions of Eclipse used in this tutorial.
  • On the www.eclipse.org/downloads page, follow the link “Find out more”. Scroll your browser to display the far right-hand side of the screen to the column “Tutorials and Help”. The first tutorial is a Screencam tutorial that steps you through downloading and installing Eclipse on Windows.
The Eclipse installation is very straightforward. There is no installation program. Instead, you just create the top-level folder and the unzip the file inside this folder. In Windows XP, for example, just copy the zip file to your root directory (e.g., “C:\”) and then unzip the downloaded zip file. This will create a folder called “C:\eclipse”. The Eclipse programs will be created in several subfolders (configuration, features, plugins, readme). The procedure for Linux is similar, except your unzip the .tar.gz file.

Thread-based Multitasking in Java

بِسۡمِ ٱللهِ ٱلرَّحۡمَـٰنِ ٱلرَّحِيمِ
Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between:
  • Process-based multitasking
  • Thread-based multitasking
At the coarse-grain level there is process-based multitasking, which allows processes (i.e., programs) to run concurrently on the computer. A familiar example is running the spreadsheet program while also working with the word-processor. At the fine-grain level there is thread-based multitasking, which allows parts of the same program to run concurrently on the computer. A familiar example is a word-processor that is printing and formatting text at the same time. This is only feasible if the two tasks are performed by two independent paths of execution at runtime. The two tasks would correspond to executing parts of the program concurrently. The sequence of code executed for each task defines a separate path of execution, and is called a thread (of execution).
In a single-threaded environment only one task at a time can be performed. CPU cycles are wasted, for example, when waiting for user input. Multitasking allows idle CPU time to be put to good use.
Some advantages of thread-based multitasking as compared to process-based multitasking are
  • threads share the same address space
  • context switching between threads is usually less expensive than between processes
  • cost of communication between threads is relatively low
Java supports thread-based multitasking and provides high-level facilities for multithreaded programming. Thread safety is the term used to describe the design of classes that ensure that the state of their objects is always consistent, even when the objects are used concurrently by multiple threads.

Friday, March 2, 2012

Reporting Tools in Java Programming

بِسۡمِ ٱللهِ ٱلرَّحۡمَـٰنِ ٱلرَّحِيمِ
Reports are all about querying a database and displaying the results in a nice format.

JasperReports
JasperReports is an engine that takes an XML file and forms a report out of that file using the data source specified in the XML file. This file defines exactly what appears where in the report. Writing this file by hand is not practical. This is where iReport comes into play.
For more information on JasperReports, see
http://jasperreports.sourceforge.net/tutorial/index.html

iReport
iReport is a visual tool to obtain XML files for JasperReports. It provides a WYSIWYG environment to design reports. Anything that can be placed in a report (static text, geometric shapes, images, subreports, groups, texts and images coming from a data source)can be put together in drag’n’drop fashion according to the report template.
For more information on JasperReports, see
http://ireport.sourceforge.net/docs.html

JFreeChart
JFreeChart is a free Java class library for generating charts. Several chart types are supported such as pie charts (2D and 3D), bar charts (regular and stacked, with an optional 3D effect), line and area charts, scatter plots and bubble charts, time series, high/low/open/close charts and candle stick charts, combination charts, Pareto charts, Gantt charts, wind plots, meter charts and symbol charts, wafer map charts. This library is used to create the images of the charts which we want to embed into the report.
For more information on JasperReports, use
keyword "The JFreeChart Class Library"

Creating Java Server Page (JSP) Components from Table Data

بِسۡمِ ٱللهِ ٱلرَّحۡمَـٰنِ ٱلرَّحِيمِ
You may have recognized a similarity between the tables of a relational database and simple JavaBean components. When building your applications think of tables as being analogous to JavaBeans. While JavaBeans have properties, data from a table has columns. A table’s schema is like the class that defines a JavaBean — defining the names and types data that instances will hold. Like Java classes, tables are templates for storing a specific set of information like the data from a purchase order or details about inventory items and by themselves are not particularly useful.
It is only when we create instances of a JavaBean class or add rows to a table that we have something worthwhile. Each row is an instance of what the table represents, just as a bean is an instance of its class. Both classes and tables then serve as data models, a useful container for managing information about some real world object or event. Keep this relationship in mind as we learn about JSP database development. It will form the basis for many of our applications.
One of the most common areas for utilizing databases with JSP applications is to retrieve data stored in a table to create a bean for use within the page. The configuration of JSP components from information in the database is pretty straightforward if your table schema (or the results of a join between tables) closely corresponds to your bean’s properties. We simply use the row access methods of the ResultSet class to configure the bean’s properties with the values in the table’s corresponding columns. If there is more than a single row in the result set we must create a collection of beans, one for each row of the results.
You can use JSP scriptlets to configure a bean’s properties when it is created. After establishing the connection, set its properties as appropriate through the data carried in the ResultSet. Don’t forget to import the java.sql package into the page with the <%@ page import=”java.sql.*” %> directive.