JavaEE Pragmatic Introduction

1) Background:
Below steps demonstrate about creation of workable web application based on Java EE architecture. This application will be deployed on "Application Server" [JBoss].


2) Application Server: JBoss 
http://sourceforge.net/projects/jboss/files/JBoss/JBoss-5.0.1.GA/jboss-5.0.1.GA-jdk6.zip/download

- Getting Started:
i) Unzip jboss-5.0.1.GA-jdk6.zip to appropriate location (/user/local/ or c:/)
ii) check for run.bat (windows) or run.sh (unix/linux like systems) and execute it
[use -b option to run it with IP address or hostname, so that it can be accessed using IP or Hostname instead of localhost always]
./run.sh -b 0.0.0.0
iii) check for the runtime logs to see if the server started without any errors


3) UML Tools:
http://astah.net/download
http://argouml.tigris.org/


4) Basic Application Structure:
i) Create new Java project in eclipse [JavaEE_Sample]
        
ii) Add new [Source Folder] named : web
                 

iii) Add new [Folder] named : WEB-INF under web source folder [web/WEB-INF]
iv) Add new file web.xml under WEB-INF folder [web/WEB-INF/web.xml]
This is a application descriptor for web application which maintains operational relationship of web application.
[web.xml]

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
  version="2.4">

  <welcome-file-list>
     <welcome-file>index.html</welcome-file>
  </welcome-file-list>
    
</web-app>

v) Add new index.html file under web folder [web/index.html]

[index.html]
<html>
<body>
This is a sample web application. 
</body>
</html>


5) Deployment:
i) Save the project as war (web archive) file : myjavaee.war
(The war file is a zip file named as war so that Application Server can understand it as a web application)
ii) Copy the war file to the deploy folder of JBoss, which will deploy the web application
/JBossInstallation/server/default/deploy/myjavaee.war

iii) Start JBoss using run command 
/JBossInstallation/bin/run.sh (run.bat for windows)
iv) Confirm deployment by checking log file


6) Test confirmation:
i) Access the deployed web application using below context
http://localhost:8080/myjavaee
(8080 is default port where JBoss runs)
ii) Check output to see below message
=========================================================