Java

Java:Building a Sample Web App with STRUTS

Java:Building a Sample Web App with STRUTS

Fadıl

In this article, I will discuss building a sample web application using STRUTS. STRUTS is a leading open-source Web Application Framework. NetBeans is the leading open-source IDE and we will use it to demonstrate how to simplify application development using the IDE. Finally our application will run on TomCat application server.

Prerequisites:
We will assume that as a reader you are familiar with web application development, specifically using JSP and Java.
Preparation:
We need to install NetBeans IDE (and JDK needed for the IDE). You can install NetBeans from www.netbeans.org. Or click here for simple instructions on how to install the IDE.
Quick overview:
We will create a very simple web application just to demonstrate screen flow and action handling using STRUTS. We will use NetBeans to create the JSP aNDjava files, use tools such as auto generation of getters and setters and finally use the IDE to compile and test the app. NetBeans comes with integrated TomCat.

Java:The Pitfalls of Inheritance Part-2

Fadıl

Listing 3 A Simple inheritance model

Following this example, we would do the following to create an instance of the Car object:

//create a new instance of the Car object

Car car = new Car();

In this, the instance variable of the Car class named model and also the instance variable registration of the super class Vehicle both will get initialized to their default values. By default, the Java Virtual Machine will allocate enough space for all the instance variables of the Objects own class and all the instance variable in all its super classes. Do not forget that in Java you can have multi-level inheritance, that is a Car IS A Automobile IS A Vehicle. In such cases, the same initialization mechanism will be followed. The initialization chain finally leads to the java.lang.Object class as all the classes in Java implicitly inherits from the Object class.

Java:The Pitfalls of Inheritance Part-1

Fadıl

In Object Oriented Programming, inheritance is a commonly used mechanism to model the relationship between two types. However, modelling such relationship without realizing the impact on the overall application may result in unexpected problems. In this article, I will try to present some internal details of inheritance mechanism based on the Java language and highlight some of the problems that a developers should be aware of when using inheritance of types.

Using Program Parameters in Java Part-3

Fadıl

Databases

Why not store parameters in a database? If your application is already using a database, you might consider defining a special table for this purpose. To hold key-value pairs you need two columns of type char: “key” and “value”. If you want a really flexible solution you should consider making a small (Swing or web?) application that can be used to insert and update the data in this table.

Using Program Parameters in Java Part-2

Fadıl

Alternatives to the command line

Giving parameters on the command line is not always the best way to enter properties for your program. A typical situation where something else is needed is when your Java program isn’t invoked through a main method. An good example is when you have coded a servlet for a web server. In this situation you may use the web.xml file to specify the parameters you need.