Time for action – creating a new Dynamic Web project

We will create a project of the Dynamic Web type for which we will define a new runtime. We will specify the version and location of our recently installed Apache Tomcat. We will also specify the version and location of our JRE. Finally, we will configure the section dedicated to Java and the Web module.

  1. We will create and configure a new project of the Dynamic Web type. To do so, once we have initiated Eclipse, we will head to the main menu and go to File | New | Other....
  2. A new assistant will be opened that will help us create and configure our project. On this new window, we will select the Dynamic Web Project item, which is found inside the Web category as shown in the following screenshot:
    Time for action – creating a new Dynamic Web project
  3. We will click on the Next > button to continue.
  4. We will place the value prd5Ch14 in the Project Name textbox and click on the New Runtime (Time for action – creating a new Dynamic Web project) button.
  5. On this new window, we will select the Apache Tomcat v7.0 item inside the Apache category as shown in the following screenshot:
    Time for action – creating a new Dynamic Web project
  6. We will click on the Next > button to continue.
  7. We need to inform the wizard where Apache Tomcat is installed. To do so, we will complete Tomcat installation directory with the full path to [TOMCAT_HOME].
  8. On the JRE selector, we need to select the JRE to be used; in our case, the right value will be java-7-oracle.
    Time for action – creating a new Dynamic Web project
  9. If when pressing the JRE selector we find out that java-7-oracle is not available, we will need to do the following:
    1. Click on the Installed JREs... button.
    2. Click on Add... to add a new JRE.
    3. Select Standard VM from the list of JRE types and click on the Next > button.
    4. On JRE home, place the full path to our JRE. On Linux it is usually found at /usr/lib/jvm/java-7-oracle/jre while on Windows the usual location is C:Program FilesJavajdk1.7.0_04. For JRE name, we will put java-7-oracle.
    5. Finally, we will click on the Finish button.
    6. In the main window, we must make sure that java-7-oracle is checked and then click on OK:
      Time for action – creating a new Dynamic Web project
    7. To continue, we will click on the Finish button.

    With the previous steps, we complete the configuration of our server:

    Time for action – creating a new Dynamic Web project
  10. We will click on the Next > button to continue. We will now proceed with the Java configuration:
    Time for action – creating a new Dynamic Web project

    We will leave the default configuration as it is and click on the Next > button.

  11. Next we will need to configure the web module. In Context root, we will place the value prdweb and check the Generate web.xml deployment descriptor option as shown in the following screenshot:
    Time for action – creating a new Dynamic Web project

    Context root will be the name of the web application. Later on we will see that to access it, we will need to use this name in addition to the URL previously used to test Tomcat, that is, http://localhost:8080/ prdweb.

  12. We will finally click on the Finish button to conclude the configuration of our Dynamic Web type project.

What just happened?

We created a Dynamic Web type project, specified its name, and created a new runtime. We chose Apache Tomcat v7.0 and indicated its location. As the JRE version to be used, we selected java-7-oracle. For the Java configuration, we used the default values, and when it was time to configure the web module, we modified its context root with the value prdweb.

Configuring Eclipse Perspectives

Once we have completed the wizard, we will obtain a base environment for a Java website that is configured and working. The environment is configured by default on the Java EE Perspective:

Configuring Eclipse Perspectives

One of the basic concepts in Eclipse usage is that of Perspectives. A Perspective is a combination of Views and Editors thought out to perform a concrete task in an easy and intuitive way.

  • Editor: This area allows for the creation and modification of programs or other components of the project. Editors are not only meant for source code; there are graphical editors available as well.
  • View: This area allows us to easily visualize various items, such as the console output, navigable class outline, and outline of a project for easy schema administration. To enable a View, we should use Window | Show View.

In order to perform the following practice, we will be using the Web Perspective . We should head to the top menu and go to Window | Open Perspective | Other…, then search the list for the Web option and finally click on OK.

We should now be able to see that the Web Perspective is currently available and enabled on the Eclipse UI as shown in the following screenshot:

Configuring Eclipse Perspectives

It can be observed that as we go along adding Perspectives, these will be placed in the top-right area of the Eclipse UI so that we can easily switch between them using a single click.

Infrastructure configurations

Now we will need to configure all the necessary settings to operate the application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset