labs / tiddlers / content / labs / lab04 / _Labs_04_Download and Open the

Java has an entire standard that covers what a Java web application looks like, so we need to use a NetBeans project that will produce an application that is in the correct format.

  1. Download the starting project from:

    Use the {{$:/ou/clipart/octicon-cloud-download}} Download Zip button again rather than cloning the project since this makes it easier to save the project in your labs repository (since you don't have to worry about problems caused by nesting repositories inside of repositories).

  2. Extract the downloaded zip file into your labs repository.

  3. Hopefully the NetBeans plugins are finished installing by now. You will need to restart NetBeans to complete the installation.

  4. Open the project folder in Netbeans using <

    Open Project">>.

  5. Build the project to get rid of the warning.

  6. You should see two source folders in the project pane:

    • Web Pages --- which is were the HTML, JSP, and CSS files go. Basically, anything that is part of the web site goes in this folder.

    • Source Packages --- which is the usual Java source packages that contains your Java classes.

  7. Note that we have already created all of the files for you. You should see:

    Source Packages

    • domain.Student --- a typical student domain class. This class is already complete.
    • servlets.AddNewStudent --- a servlet for processing the data entered by the user when creating a new student.Web Pages
    • index.html --- a static web page that contains a menu for the system.
    • add-student.html --- a static web page that contains the form for adding a new student.
    • view-students.jsp --- a dynamic web page that will display the students that have been entered in to the system.
    • style.css --- the CSS file for styling all of the web pages.
  8. Also take a quick look at the Gradle build script at Build Scripts/build.gradle. The only thing that we really need to create a web application project via Gradle is the war plugin. This will cause Gradle to produce a war file that can be deployed to a Java web server such as Tomcat. WAR is short for Web Application aRchive and is a Zip file that packages the web files and compiled Java classes together into a standardised layout that Java web servers can use.