Java Application Servers
In this part of the Java EE 5 tutorials, we will mention Java Application Servers (AS).
An aplication server is a server side software that provides the business logic for the application. A Java EE AS is a server application that implements the Java EE platform APIs and provides the standard Java EE services. Java EE AS differs from traditional web server by providing components that handle JSP pages and servlets and by working with databases. The main benefit of an application server is the ease of application development.
A three tier application consists of these parts:
- Front end
- Business logic
- Back end
The front end is usually a web based GUI. It displays data and provides the look and feel for the application. The business logic is the logic of the application. In the three tier layered application, the Java EE AS provides most of the business logic. The back end is a database and transaction server. (wikipedia.com, firstcup, techtarget.com)
There are several well known Java EE application servers.
When we installed the Java EE Netbeans pack, we also installed two application servers. Tomcat and Glassfish. After trying several AS, I chose Resin AS for this tutorial. This application server is very fast and easy to use.
Apache Tomcat is an application server that is used in the official Reference Implementation for the Java Servlet and JavaServer Pages technologies. Tomcat is developed by the Apache Software Foundation (ASF). During the installation of the NetBeans IDE, we can choose to install Apache Tomcat AS as well. It is then integrated in the IDE.
Starting and stopping Tomcat
$ cd apache-tomcat-6.0.14/bin/ $ ./startup.sh Using CATALINA_BASE: /home/vronskij/bin/apache-tomcat-6.0.14 Using CATALINA_HOME: /home/vronskij/bin/apache-tomcat-6.0.14 Using CATALINA_TMPDIR: /home/vronskij/bin/apache-tomcat-6.0.14/temp Using JRE_HOME: /home/vronskij/bin/jdk1.6.0_03/
We go to the bin direcory located in the installation directory of the
Apache Tomcat AS. To start the server, we launch the
Tomcat listens on the 8080 port by default.
$ ./shutdown.sh Using CATALINA_BASE: /home/vronskij/bin/apache-tomcat-6.0.14 Using CATALINA_HOME: /home/vronskij/bin/apache-tomcat-6.0.14 Using CATALINA_TMPDIR: /home/vronskij/bin/apache-tomcat-6.0.14/temp Using JRE_HOME: /home/vronskij/bin/jdk1.6.0_03/
To stop the Apache Tomcat AS, we execute the shutdown.sh script.
To deploy a web application, we copy the web archive to the webapps subdirectory of the Apache Tomcat installation directory.
GlassFish is a free and open sourced Java Application server for the Java EE 5. The source code has been donated by Sun Microsystems from its commercial Java System Application Server. It is now endorsed by the Sun Corporation and the NetBeans project. GlassFish can be controlled from the NetBeans IDE.
We can install GlassFish, when we install NetBeans Java EE pack.
Starting and stopping Glassfish
$ ./asadmin start-domain domain1
We start the Glassfish server with the asadmin tool. It is located in the bin subdirectory of the Glassfish installation directory.
GlassFish listens on the 8080 port by default.
$ ./asadmin stop-domain domain1
Here we show, how we stop the GlassFish server.
Web application deployment
We can deploy the web application by copying the web archive to the
$ asadmin deploy --user=admin ~/programming/jee/form/form.war
This is an alternative method of deployment. Here we must also provide a password for user admin. The default password is adminadmin.
Resin is high-performance, open source Java EE Applicaiton Server. Resin is created by the Caucho Technology Corporation. The Resin is the AS used in this tutorial. I found Resin to be the fastest AS.
Installation of Resin AS might be complicated. But for educational purposes, we do not need any compilation or advanced configuring. If we want to use Resin as a standalone server, the installation process is pretty easy. We download Resin from www.caucho.com/download. Unpack it to the install dir.
Starting and stopping Resin
$ ./httpd.sh start Resin/3.1.3 started -server ''.
We go the the bin subdirectory of the Resin installation directory and launch the httpd.sh script with the start parameter.
The Resin Application Server listens on the 8080 port as well.
$ ./httpd.sh stop Resin/3.1.3 stopped -server ''.
This is how we stop the Resin.
The deployment is very easy. We just copy the web archive to the webapps subdirectory.
In this part of the JEE tutorial, we have briefly mentioned Java application servers.