Deploying our first application

NetBeans comes pre-configured with a number of sample applications. To make sure everything is configured correctly, we will now deploy one of the sample applications to the integrated GlassFish application server that comes bundled with NetBeans.

To open the sample project, we need to go to File | New Project, then select Samples | Java Web from the categories list in the resulting pop up window. Once we have selected Java Web from the categories list, a list of projects is displayed in the Projects list, for this example we need to select the Servlet Stateless project. This sample is a simple project, it uses both a servlet and a stateless session bean, which gives us a chance to use both the GlassFish servlet container and its EJB container.

Deploying our first application

After clicking on the Next> button, we are prompted to enter a project name and location, the default values are sensible.

Deploying our first application

Once we click on the Finish button, our new project is displayed in the Projects window.

Deploying our first application

We can compile, package, and deploy our project all in one shot by right-clicking on it and selecting Run from the resulting pop up menu.

Deploying our first application

At this point we should see the output of the build script. Also both the integrated GlassFish application server and the integrated JavaDB RDBMS system should automatically start.

Deploying our first application

As soon as our application is deployed, a new browser window or a tab automatically starts, displaying the default page for our sample application.

Deploying our first application

The sample web application we just deployed is a simple application that demonstrates a nice feature that was introduced in Java EE 6, namely the ability to use dependency injection on a stateless session bean without the need to implement a business interface for said bean like it was required in Java EE 5, or without needing to use a home interface to obtain an instance of the session bean as we had to do back in the days of J2EE.

If our browser is displaying a page similar to the one above, then we can be certain that NetBeans and GlassFish are working properly and we are ready to start developing our own Java EE applications.

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

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