Web application with existing source
This demo script is part of the NetBeans World Tour 2008 session #2, Using NetBeans For Your Existing Projects.
Main Points to Hit
- Have you got source code but no build.xml? Not a problem! You can create a NetBeans project easily.
Prerequisities
- JDK5 or JDK6
- NetBeans 5.5 (or higher) -- tested successfully with 6.1
- A database - all testing done with JavaDB (Derby)
- A web server - works with Tomcat or GlassFish
Setup
- Create a table named USERS with these columns: user_id, first_name, last_name, age, email, password. The user_id and age columns should be INTEGER, the rest are VARCHAR. Alternatively, you can run the SQL script below:

create table "APP"."USERS"
(
"user_id" NUMERIC(10) not null primary key,
"first_name" VARCHAR(20),
"last_name" VARCHAR(30),
"age" INTEGER,
"email" VARCHAR(45),
"password" VARCHAR(20)
)
- Download and unzip this file . It contains the source files for a simple Struts application called Registration (from the VisualBuilder.com community site).
- In the unzipped directory, edit the registration/src/com/visualbuilder/struts/action/ApplicationResources.properties file to set the database name/connection values for your environment. Example:
database.driver = org.apache.derby.jdbc.ClientDriver
database.url = jdbc:derby://localhost:1527/sample
database.user = app
database.password = app
Demo Steps
- Make sure that JavaDB is running.
- File > New Project. Select Web and Web Application with Existing Sources. Suggested Comment (SC): "I have the source for a simple Struts application that I got from an online tutorial. If a build.xml file had been provided then I could create a free-form project in the IDE. But since there is no build.xml I choose the 'with Existing Sources' option. The IDE will create a build.xml for me."
- Click Next
- For Location: select the top-level registration directory that was created when you unzipped the file
- Click Next
- For Server pick either Tomcat or GlassFish
- Click Next
- The Existing Sources and Libraries values are already filled in. SC: "The IDE knows that this is a web application so it was able to find the web pages and the libraries under the directory that I specified." :-)
- Click Finish
- The new project is opened. SC: "The IDE has created a project and it understands the structure of the code and the configuration files."
- Expand the Web Pages, Configuration Files, Source Packages, and Libraries nodes to show their contents.
- If using Tomcat: Add the JavaDB Library to the project's libraries. SC: "The IDE has a library defined for the JDBC driver I want to use, so I can add it to the project."
- Right-click the project and Run
- Log on to the application with username/password of admin/admin
- Add a new user if you want (pay attention to data types above)... but that's not really the point of this demo.
- Go back to the IDE and depending on the time remaining, show:
- Step through the project properties and show how things have been setup correctly, like the recognized framework is Struts 1.2.9.
- The IDE can help edit struts.config
- The IDE has setup the project so that you can easily debug or profile