Build and Deployment of Java EE Web Application (Airline Ticket Reservation)

Background: 
To develop Java EE web application using standard Eclipse Java IDE has many limitations, to overcome those limitations the Eclipse project has already created "Java EE Developers". Below are the steps to demonstrate, Building and Deployment of Web Application on JBoss Application server using "Java EE Developer".

Steps:
1) Download and Install "Eclipse IDE for Java EE Developers"
http://www.eclipse.org/downloads/?osType=win32

2) Create new project by selecting "Dynamic Web Project"
    [File][New][Project...][Web]

3) Set Project name : AirlineTicketReservation
   (Keep other values to default)

4) Add reference to the external Servlet library so that we can use Servlet API in our application
[jboss-5.0.1.GA/common/lib/servlet-api.jar]
/AirlineTicketReservation/WebContent/WEB-INF/web.xml
/AirlineTicketReservation/WebContent/searchView.html
/AirlineTicketReservation/src/controller/SearchController.java
/AirlineTicketReservation/WebContent/image/airline.png

6) Build the project
7) Export as a WAR (Web Archive) file :  AirlineTicketReservation.war
8) Deploy the WAR file to application server (Such as JBoss)
9) Access web application using URL with the web application context AirlineTicketReservation
10) Confirm log information
11) Source reference:
i) /AirlineTicketReservation/WebContent/WEB-INF/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>searchView.html</welcome-file>
  </welcome-file-list>
  
  <servlet>
    <servlet-name>searchController</servlet-name>
    <servlet-class>controller.SearchController</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>searchController</servlet-name>
    <url-pattern>/searchController.do</url-pattern>
  </servlet-mapping>
    
</web-app>


ii) /AirlineTicketReservation/WebContent/searchView.html
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Search Flight</title>
</head>
<body>

<form action="searchController.do" method="post">
<table border = "1" align="center">
  <tr>
<td align ="center" valign="bottom" bgcolor="#000080">
<font size="4" color="#FFFFFF"><b>Airline Ticket Reservation</b></font>
</td>
</tr>
<tr>
<td>
          <img src="image/airline.png" alt="Airline" width=100% height=100%>
</td>
</tr>
<tr>
<td>
<b>Airport</b> <br/>
From <input type="text" name="fromAirport" value="NRT">
To <input type="text" name="toAirport" value="LAX">
</td>
</tr>
<tr>
<td align="left">
<b>Date</b>[yyyy-mm-dd]<br/>
Depart <input type="text" name="fromYear" size="4">-<input type="text" name="fromMonth" size="2">-<input type="text" name="fromDay" size="2">
Return*   <input type="text" name="toYear" size="4"  >-<input type="text" name="toMonth"  size="2" >-<input type="text" name="toDay" size="2">
<br/>
<font size="2" color="#808080">*For one-way flight keep "Return" date blank</font>
</td>
</tr>
<tr>
<td align="right">
<input type="submit" value="Search">
</td>
</tr>
</table>
</form>

</body>
</html>

iii) /AirlineTicketReservation/src/controller/SearchController.java
package controller;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class SearchController extends HttpServlet {

@Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
System.out.println("Calling doPost...");
String fromAirport = req.getParameter("fromAirport");
String toAirport = req.getParameter("toAirport");
System.out.println("From airport =" + fromAirport);
System.out.println("To   airport =" + toAirport);
}
}

iv) /AirlineTicketReservation/WebContent/image/airline.png

How to configure Eclipse IDE Code Completion key binding on Mac OSX

Follow below steps to assign [Ctrl + Space] combination for code completion in Eclipse for Java IDE.

Steps:
i) Open Eclipse Preferences
ii) Under [General][Keys] check for [Command] column
iii) Change [Content Assist] Binding to [^Space]
(Make sure the Binding is not already in use by any other Software including another Eclipse IDE)
iv) Apply changes