The Complete Magazine on Open Source

Developing a Web-app Using the Eclipse Editor

SHARE
/ 187 0
Eclipse Editor
This article is the first in a series on developing a Web application called ‘Online Banking’ using the Eclipse Editor. The application will perform all the normal functions of offline banking. This task will be spread over a number of articles. In this first article, the author covers the basics of what is required to develop the Web-app, starting with Java.

Java is a programming language created by James Gosling from Sun Microsystems in 1991. The first publicly available version of Java (Java 1.0) was released in 1995. The Java virtual machine (JVM) is a software implementation of a computer that executes programs like a real machine.

The JVM is written specifically for a particular operating system, e.g., for Linux. A special implementation is required for Windows.

Figure 1

Figure 1: Java virtual machine

Figure 2

Figure 2: Communication between servlet and the browser

Figure 3

Figure 3: Servlet life cycle

Characteristics of Java
The aim of the creators of Java was to be able to write a program once and then run it on multiple operating systems.

Java has the following properties.

  • Platform independence: Java programs use the Java virtual machine as abstraction and do not access the operating system directly. This makes Java programs highly portable. A Java program (which is standards-compliant and follows certain rules) can run unmodified on all supported platforms, e.g., Windows or Linux.
  • An object-orientated programming language: Except for the primitive data types, all elements in Java are objects.
  • A strongly-typed programming language: Java is strongly-typed; the types of variables used must be pre-defined and conversion to other objects is relatively strict. In most cases, it must be done by the programmer.
  • An interpreted and compiled language: Java source code is transferred into the byte-code format, which does not depend on the target platform. These byte-code instructions are interpreted by the Java Virtual Machine (JVM). The JVM contains a so called ‘hotspot-compiler’, which translates performance critical byte-code instructions into native code instructions.
  • Automatic memory management: Java manages the memory allocation and de-allocation for creating new objects. The program does not have direct access to the memory. The garbage collector automatically deletes objects to which no active pointer exists.
Figure 4

Figure 4: Welcome page

Figure 5

Figure 5: Opening account page

Figure 6

Figure 6: Confirmation of account opened

An introduction to the Java editor—Eclipse
Eclipse is an integrated development environment (IDE) for developing applications using programming languages like Java and others such as C/C++, Python, PERL, Ruby, etc.

The Eclipse platform provides the foundation for the Eclipse IDE. It is composed of plugins and is designed to be extensible through the use of additional plugins. Developed using Java, the Eclipse platform can be used to develop rich client applications, integrated development environments (IDEs) and other tools.

Eclipse can be used as an IDE for any programming language for which a plugin is available.

  • The Java Development Tools (JDT) project provides a plugin that allows Eclipse to be used as a Java IDE
  • PyDev is a plugin that allows Eclipse to be used as a Python IDE
  • C/C++ Development Tools (CDT) is a plugin that allows Eclipse to be used for developing applications using C/C++
  • The Eclipse Scala plugin allows Eclipse to be used as an IDE to develop Scala applications
  • PHPeclipse is a plugin to Eclipse that provides the complete development tools for PHP
Figure 7

Figure 7: Balance checking page

Figure 8

Figure 8: Deposit form

Figure 9

Figure 9: Withdrawal form

Introducing Servlet
Servlet technology is used to create Web applications and it uses the Java language to do so.

Web applications are ‘helper applications’ that reside in the Web server and build dynamic Web pages — like a page that randomly chooses a picture to display or even a page that displays the current time.
As Servlet technology uses Java, Web applications made using Servlet are secure, scalable and robust.
The advantages of using Servlet are:

  • Low response time because each request runs in a separate thread
  • Servlet is scalable
  • It is robust and object oriented
  • It is platform independent

The Servlet life cycle

  • Loading a Servlet class: A Servlet class is loaded when the first request for the Servlet is received by the Web container.
  • Creating a Servlet instance: After the Servlet class is loaded, the Web container creates an instance of it. A Servlet instance is created only once in its life cycle.
  • Calling the init() method: init() is called by the Web container on a Servlet instance to initialise the Servlet.
Signature of init() method: public void init (ServletConfig config) throws ServletException
  • Calling the service() method: The containers call the service() method each time the request for Servlet is received.
Signature of service() method: public void service(ServletRequest request,ServletResponse response) throws ServletException, IOException
  • Calling the destroy() method: The Web container calls the destroy() method before removing the Servlet instance, giving a chance for clean-up activity.
Figure 10

Figure 10: Transferring amount form

Figure 11

Figure 11: Account closing form

An introduction to Oracle

An Oracle database is a collection of data treated as a unit. The purpose of a database is to store and retrieve related information. A database server is the key to solving the problems of information management. In general, a server reliably manages a large amount of data in a multi-user environment so that many users can concurrently access the same data. All this is accomplished while delivering high performance. A database server also prevents unauthorised access and provides efficient solutions for failure recovery.

Oracle Database is the first database designed for enterprise grid computing, and is a flexible and cost-effective way to manage information and applications. Enterprise grid computing creates large pools of industry-standard, modular storage and servers. With this architecture, each new system can be rapidly provisioned from the pool of components. There is no need for peak workloads, because capacity can be easily added or reallocated from the resource pools, as needed.
The database has logical structures and physical structures. Because the physical and logical structures are separate, the physical storage of data can be managed without affecting the access to logical storage structures.

An introduction to Apache Tomcat Server
Apache Tomcat is an open source Web server and Servlet container developed by the Apache Software Foundation (ASF). Tomcat implements several Java EE specifications including Java Servlet, JavaServer Pages (JSP), Java EL and Web Socket. It also provides a ‘pure Java’ HTTP Web server environment for Java code to run in.

The components of Apache are:

1. Catalina
2. Coyote
3. Jasper
4. Cluster
Figures 4 to 11 give the UI snaps for the ‘Online Banking’ Web application that we will be building in subsequent articles.
The forthcoming articles in this series will deal with Oracle Database, Apache Tomcat Server and Servlet, which have been used in developing this Web application.