Previous Next Contents Index


Compiling, Testing, and Debugging Applications

This chapter describes debugging applications as well as deploying the finished product onto one or more Netscape Application Servers.

The following topics are described in this chapter:


Compiling Applications
You can perform operations on all the files in your application at once by choosing one of the following options from the Build menu:

Build option
Shortcut
Resulting action
Build Project
F7
Compiles all files that either are new or have been changed since the last build (make all)
Rebuild Project
Ctrl+Shift+F7
Removes all files generated by previous builds and then compiles everything (make clean all)
Clean Project

Remove all generated files (make clean)

Rebuild Project is the recommended procedure for all milestone builds, and especially before deployment.

Registering Files
Netscape Application Builder incorporates automatic registration for project servlets. However, you can also register files manually via the Build menu.

To register afile, perform the following steps:

  1. Open or select the file.
  2. Choose Register - File(s) from the Build menu.
To register all project files, Choose Register - All from the Build menu.

Compiling Java files
As you add servlets, HTML pages, and JavaServer Pages (JSPs) to your application project, you can compile and run the incomplete application periodically to test the elements you have completed so far. Before you can test a servlet, you must compile it.

The Java tab of the Development Options dialog box lets you change how Netscape Application Builder compiles your Java files. For more information, see Setting Java Compiler Options.

Note. Compiling a Java file does not affect a class that has already been loaded into the runtime or test servers. Netscape Application Builder prompts you to restart your server for this reason.

The Messages window (usually located just below the Properties window) is an information window that displays the associated compilation errors, warnings, and other data about your servlets.

To compile a single file, perform the following steps:

  1. Select the desired Java code file.
  2. Choose Compile file from the Build menu.
To compile all your Java files, perform the following steps:

  1. From the Build menu, choose Build Project.
  2. Click Stop to stop the compile process; click Clear to reset the message window.
If the servlet contains no syntax errors, Netscape Application Builder displays the Compiled Successfully message.

Starting and Stopping a Test Server
Your application can be run and tested without deploying to an application server. This is done by running it on a test server, a local version of the Netscape Application Server on your development machine.

The test server starts or restarts automatically when you select Test Project (Ctrl+F5) from the Test menu. It also starts when you test individual files, if needed.

Alternatively, you can administer the server by hand using the following commands from the Test menu:

Build Option
Shortcut
Resulting Action
Start Server
F6
Start the test server
Stop Server
Shift+F6
Stop the test server, terminating any running processes
Restart Server
Ctrl+Shift+F6
Stop and then restart the test server, terminating any running processes


Building EJB Stub and Skeleton Code
When you select a bean and then choose Complie file(s) from the Build menu or choose Build or Rebuild Project, Netscape Application Builder opens the EJB Stubs tab in the Messages window to display the results of the compilation:

Errors during compilation will appear in this window as well. For an example of creating and compiling an EJB, see "Task 11: Creating Enterprise JavaBeans" on page 221.


Testing Applications
You can test individual files by using a debugger, such as Visual Cafe, to set breakpoints and walk through the execution of files line by line. You can test the behavior of individual pages. Test a JSP by invoking the servlet that calls it, which also tests the runtime servlet at the same time.

Application flow, however, is the point-to-point interaction between your application and the person using it. Testing at the application level involves exercising application functionality and looking at the results as well as judging the order of the functionality with respect to other features. For example, an online market might allow a user to browse a catalog, select items, and then purchase all selected items at once at "checkout." If your application presents a blank checkout screen before allowing your user to browse the contents of the market, your user will be confused and unsure where to go next.

One way to see an overview of application functionality is to use the Project Map. For more information, see The Project Map.

This section describes the following topics:

Testing Queries
Netscape Application Builder enables you to test your queries before you deploy your application.

To test a query, perform the following steps:

  1. From the File menu, choose Open to open the desired query file or double-click the query file in the project map window or within the Project window.
  2. Click the Query Properties Results tab.
  3. To execute the associated SQL code for the specified query, click Execute SQL. Note that you can also right-click the query file from the Project window and select Test to perform this action or from the Test menu, select Test MyQuery_Name.
  4. Type the appropriate information for these fields and click OK.
  5. To test the SQL for a new login, click New Login.
  6. Click Finish if you are satisfied with the test results; otherwise, continue to edit the associated query SQL until you obtain the correct results. If Netscape Application Builder cannot parse your SQL, all other query editing tabs are disabled except the SQL and Results tabs.
Testing HTML Pages and JSPs
At any point, you can test your page or template by viewing it in a browser.

Testing HTML Pages
Select the page you want to test, and then choose Test Pagename from the Test menu or type Ctrl+Shift+F5. The page appears in the default browser.

Testing JavaServer Pages
You must associate an servle with your JavaServer Page (JSP) before it can be tested, as a JSP is meaningless without the context of data from a servlet.

Select the JSP you want to test, and then choose Test Pagename from the Test menu or type Ctrl+Shift+F5. If more than one servlet/EJB calls this JSP, you are prompted to choose one.

A static HTML page is generated that contains a link to the servlet/EJB that calls this JSP. This static page appears in the default browser. To test the template, click the link that calls the servlet/EJB. The results appear in the browser.

You can also test or debug a JSP by adding the Java code it produces to your project and using a debugger on that code. To generate the code:

  1. Run your application and access the URL that causes the JSP to be called.
  2. Add this file to your project as you would any other Java file.
  3. Set breakpoints or perform other debug operations on this file.
Testing Servlets
Once you've successfully designed, registered, and compiled your Java objects, you can use Netscape Application Builder to test them. When you test a Java object, your preferred HTML browser displays an HTML page from which you can submit a request to run the object.

Before testing an object, you must compile it. For more information about how to compile your Java objects, see Compiling Java files.

To Test a servlet, perform the following steps:

  1. Open or select the servlet file.
  2. Choose Test <servlet File Name> from the Test menu.
Note. It takes a few seconds for the server to start up, even though Netscape Application Builder immediately displays the HTML page that leads to the code being tested. Exiting Netscape Application Builder automatically shuts down any server that was started by Netscape Application Builder. You should wait until your Messages window displays the "Server is ready to serve Servlets" message.


Debugging Applications
If your Java object doesn't compile correctly, or if your objects do not provide you with the expected behavior, you can use Visual Cafe to check the state your program at a particular point in its execution. For information about debugging with Visual Cafe, "Using NAB 4.0 with Symantec Visual Café" on page 473.

 

© Copyright 1999 Netscape Communications Corp.