This tutorial demonstrate how you can use the rich set of tools and APIs that comes with the Web Tools Platform Project. This first tutorial will give you a step by step tour of using some the tools for web development. For this purpose we will build and run a J2EE web application using WTP tools and Apache Tomcat.
Reference (JBuilder / eclipse help content)
We are going to be build a web application that runs on a server. To do this tutorial you will need a server runtime that is supported by WTP. Apache Tomcat , ObjectWeb Jonas , and JBoss are some of the OSS licensed server runtimes supported by WTP.
WTP uses components from other eclipse projects: The eclipse modeling framework, emf, java emf model, jem, are used to define models for artifacts defined in many java, w3c, xml and j2ee standards; The graphical editing framework, gef, is used to provide graphical editing capabilities for xml, xsd and wsdl editors, etc. You can obtain these components from their projects.
Web Tools Platform
You will need to download the full WTP package that is used in this tutorial from wtp downloads. You will need a WTP runtime.
Once you have everything downloaded, install JDK and your favorite server runtime, and unzip eclipse, emf, gef, jem and wtp zip files to a folder. You are ready to go!
Add or Choose a Server Runtime Environment
This can be done in Window-Preferences-Server
click “Add…”. A wizard will popup and display a list of server runtimes that are supported by WTP. Choose your server runtime from the list. Jonas and JBoss are currently supported under the “Generic Server Runtime”. Basic “J2EE Runtime Library” is not a true server runtime, but can be used for coding support only. It does not provide a server instance that can be used to run web artifacts. (Apache Tomcat v5.5 , GlassFish Java EE 5 )
After you click “Next”, you will have to choose the JDK and the folder where you have installed your server runtime. Of course, based on your choice of the server runtime, you will be asked to provide different properties. Click finish. Now we can do the fun part.
We chose Apache Tomcat. You can also choose another server such as ObjectWeb Jonas. If you would like to use them as your runtime, select the “Generic Server”, and follow the wizard to define the properties for Jonas, JBoss or Weblogic. There are differences between for server runtimes; Apache Tomcat provides dynamic development support; i.e: the ability to run the web application from the eclipse project without the need to publish the artifacts to a server. Generic server does not support dynamic development, but it will automatically publish the artifacts (your web application) to the server when you run.
Developing the Application
In this section we will create a J2EE web application that contains typical components such as servlets and JSPs. We will:
• Create a project with a web module
• Create a servlet
• Edit deployment descriptor
• Create and edit a JSP
Create a J2EE Web Project with a web module
Go to New->Project. Choose Web category from the list of available wizards to create a new eclipse resource. You will find two project types available under this category. Simple Web Project is a basic Eclipse resource project that can be associated with a server. We are interested in creating a J2EE Web Application, so we will choose the J2EE Web Project.
A J2EE Web Project is a type of Java project that has been initialized to host a server-side application. It needs to be associated with a Target Server.
A target server provides the container which will be used to execute our web application. Specifically, it will provide a set of libraries (jars), that are added to the project classpath, which are needed to compile our custom classes. E.g.: to create a new Servlet, we need javax.servlet.* packages. These are not a part of the JDK libraries. Server runtime provides them to the project. If yiu have skipped the previos step where we defined a server runtime, you will get a chance to define one here by clicking on the New….
Make sure that “Add module to an EAR project” is not selected. We will create a standalone web application that can be deployed as a standard web module.
Finally, we will change the context root to “tutorial”. This is used when you access the web application with a URL, i.e. http://localhost:8080/tutorial