WithExistingSources

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

  1. 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:
    [Image:createTable_WithExistingSources.png]

    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)
)
  1. Download and unzip this file . It contains the source files for a simple Struts application called Registration (from the VisualBuilder.com community site).
  2. 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

  1. Make sure that JavaDB is running.
  2. 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."
  3. Click Next
  4. For Location: select the top-level registration directory that was created when you unzipped the file
  5. Click Next
  6. For Server pick either Tomcat or GlassFish
  7. Click Next
  8. 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."  :-)
  9. Click Finish
  10. The new project is opened. SC: "The IDE has created a project and it understands the structure of the code and the configuration files."
  11. Expand the Web Pages, Configuration Files, Source Packages, and Libraries nodes to show their contents.
  12. 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."
  13. Right-click the project and Run
  14. Log on to the application with username/password of admin/admin
  15. Add a new user if you want (pay attention to data types above)... but that's not really the point of this demo.
  16. Go back to the IDE and depending on the time remaining, show:
    1. Step through the project properties and show how things have been setup correctly, like the recognized framework is Struts 1.2.9.
    2. The IDE can help edit struts.config
    3. The IDE has setup the project so that you can easily debug or profile
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo