Some thoughts on JSF…

Developed through the Java Community Process (JCP) by a group of technology leaders, including Sun Microsystems later acquired by Oracle, Borland, BEA, and IBM, along with a collection of Java and Web experts well known in the industry under JSR – 314, Java Server Faces technology establishes the standard for building server-side user interfaces. With the contributions of the expert group, the JavaServer Faces APIs are being designed so that they can be leveraged by tools that will make web application development even easier.

What is JSF?

JSF LogoJSF is a request-driven MVC web framework based on component-driven UI design model, using XML files called view templates or Facelets views. Requests are processed by the FacesServlet, which loads the appropriate view template, builds a component tree, processes events, and renders the response (typically HTML) to the client. The state of UI components (and some other objects) is saved at the end of each request (called state saving), and restored upon next creation of that view. Several types of state-saving are available, including client-side and server-side state saving. Out of the box, JSF 1.x uses Java Server Pages (JSP) for its display technology, but can also accommodate other technologies (such as XUL and Facelets). JSF 2 uses Facelets by default for this purpose. Facelets is a more efficient, simple, and yet more powerful view description language (VDL).

What’s the difference between JSF and JSP/Servlets?

JSP (Java Server Pages) is a Java view technology running on the server machine which allows you to write template text in (the client side languages like HTML, CSS, JavaScript and so on). JSP supports the so-called tag libraries shortly denoted as taglibs which are backed by pieces of Java code with which you can control the page flow and/or output dynamically (programmatically). A well known taglib is JSTL. JSP also supports the Expression Language which can be used to access back-end data (actually, the attributes which are available in page, request, session and application scopes), mostly in combination with taglibs.

When a JSP is requested for the first time or when the web application starts up, the servlet container will compile it into a servlet, which is a class extending HttpServlet and use it during the lifetime of the web application. In Tomcat, for example, you can find the source code of the generated servlet in the server’s work directory. On a JSP request, the servlet container will execute the compiled JSP class and send the generated output (usually just HTML/CSS/JS) through the web server over the network to the client side which in turn displays it in the web browser.

Continue reading

Best 5 Java open-source web application frameworks


Some programmers think JSF has a steep learning curve

When it comes to developing web applications using Java, writing all the code from scratch has its advantages if you’re trying to master a new technology, but for real life web applications, you have to go for a framework as many expert developers would agree. Otherwise you risk a great deal of failure because of having allocated too much time and too many resources by re-inventing the wheels.

There are some hardliners who still argue why there’s ever a need for a framework, since everything can be accomplished by Servlets, JSP and Filters. One of them is Bear Bibeault author of JQuery in Action.

-Adeel Ansari

The cost is an important factor—although “free” in most cases also means widespread usage, community support, and no dependence on a single vendor. It takes some time for developers to get used to a framework and be good at it. Therefore choosing a framework as a long-term strategy. You cannot be switching frameworks for every project. Sticking with one framework also helps as once the expertise in that framework builds up; customizing the framework also becomes a possibility.

A tempting option is for organizations to build their own framework to address needs specific to the kind of work the organization undertakes. Although it does seam seem to make sense on paper, for my money, this is a suicidal strategy. Thoroughly testing and maintaining a framework is a huge task that will need dedicated human resources. These few people would become critical and the only source of support for others using that framework. Also, with so many quality frameworks available for free, I seriously doubt it really is necessary.

As with many web frameworks emerging nowadays, the ever-increasing number of Java web application frameworks out there today is intimidating for many developers even to look into because of being presented with too many choices. However, matching the criteria of popularity, widespread usage and tooling support, I can list a few of the best Java web application frameworks here and in a descending order of my personal choice. Sorry if I haven’t listed your favorite Java web framework here, feel free to agree or disagree in the comments section. Continue reading

Matrix of compatible platforms and runtimes with JBoss Tools

JBoss Tools Icon
Use Eclipse with the JBoss Tools plugin instead of  JBoss Developer Studio? It can get somewhat tricky to get the right version of the tools plugin to work with the compatible version of Eclipse and the correct version of JSF components, etc.

JBoss Dev Studio is a branded version of a Eclipse packed with the right version of JBoss Tools. The dev studio is usually bundled with a developer subscription from RedHat for $99. (I’ve been told, however, by Max Rydahl Andersen a JBoss employee who is also one of the developers of JBoss tools and the developer studio that the JBoss Developer Studio IDE itself is actually free without the JBoss commercial runtimes – i.e. JBoss EAP).

If you stick with Eclipse IDE with the JBoss tools plugin, I came up with the following matrix of the set of tools showing the coupling of compatible versions.

JBoss Tools Compatibility Matrix

EclipseJBoss ToolsJBDSJBoss EAPJBoss AS (Community)SeamJSFRichFaces
3.6 / Helios3.,5.0,5.15.1, 5.0, 4.2, 4.0, 3.22.2, 2.1, 2.0, 1.22.0 (in VPE), 1.2, 1.13.3.x
3.5/Galileo3., 5.05.1, 5.0, 4.2, 4.0, 3.22.2, 2.1, 2.0, 1.22.0 (in VPE), 1.2, 1.13.3.x
3.4.2/Ganymede3.0.x2.1.04.3, 5.05.0, 4.2, 4.0, 3.22.2, 2.1, 2.0, 1.21.2,
3.3.2/Europa2., 4.2, 4.0, 3.22.0, 1.21.2,, 4.0, 3.22.0, 1.21.2,
Continue reading

Hibernate Derived Properties – @Formula Annotation

HibernateIn Hibernate a derived property (also called a calculated property) is a read-only property whose value is calculated at fetch time using SQL expressions.

Example: For an employee entity with properties such as an id and the employee name also a monthlySalary property, you might also want to have a yearlySalary which is not necessarily stored in the database.

package net.ozar.exp.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

public class Employee implements {

	private static final long serialVersionUID = -7311873726885796936L;

	private Integer id;

	@Column(name="FIRST_NAME", length=31)
	private String firstName;

	@Column(name="LAST_NAME", length=31)
	private String lastName;

	private float monthlySalary;

	public Employee() {

	// getters and setters
     // ...

	public float getMonthlySalary() {
		return monthlySalary;

	public void setMonthlySalary(float monthlySalary) {
		this.monthlySalary = monthlySalary;

     /* This artificial property - as I call it - is a kind of a calculated property, but not with Hibernate derived property support - not just yet */
	public float getYearlySalary() {
		return this.monthlySalary * 12;


The above example gives us a simple calculation in memory for just screen output without Hibernate’s derived property or the @Formula support.  Now take a moment to reflect that we need all the employees whose yearly salary average is above $5000. Then what? In this case, you might wanna make use of Hibernate’s derived property feature.
Continue reading