Previous Contents Index DocHome Next |
Application Builder 6.0 iPlanet Application Builder User's Guide |
Chapter 9 Compiling, Testing, and Debugging Applications
This chapter describes debugging applications as well as deploying the finished product onto one or more iPlanet Application Servers.The following topics are described in this chapter:
Compiling Applications
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:
Rebuild Project is the recommended procedure for all milestone builds, and especially before deployment.
Registering Files
iPlanet Application Builder incorporates automatic registration for project servlets.
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 iPlanet Application Builder compiles your Java files. For more information, see "Setting Application Builder Options."
Compiling a Java file does not affect a class that has already been loaded into the runtime or test servers. iPlanet 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:
Select the desired Java code file.
To compile all your Java files, perform the following steps:Choose Compile file from the Build menu.
- Messages from the compiler appear within the output message window of iPlanet Application Builder, as shown in the following illustration. If the compiler finds an error, the location of the error is shown. The messages box that iPlanet Application Builder displays allows you to double-click on a line giving the position of a compile error; iPlanet Application Builder then displays that specific line of code.
- Click Stop to stop the compile process; click Clear to reset the message window.
- If the servlet contains no syntax errors, iPlanet Application Builder displays the Compiled Successfully message.
From the Build menu, choose Build Project.
If the servlet contains no syntax errors, iPlanet Application Builder displays the Compiled Successfully message.
Click Stop to stop the compile process; click Clear to reset the message window.
- Messages from the compiler appear within the output message window of iPlanet Application Builder. If the compiler finds an error, the location of the error is shown. The messages box that iPlanet Application Builder displays allows you to double-click on a line giving the position of a compile error; iPlanet Application Builder then displays that specific line of code.
Note You must stop and restart the webserver after you build a component
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 iPlanet 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:
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 Compile file(s) from the Build menu or choose Build or Rebuild Project, iPlanet Application Builder opens the EJB Stubs tab in the Messages window to display the results of the compilation. Errors during compilation appear in this window as well.
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.
This section describes the following topics:
Testing Queries
iPlanet Application Builder enables you to test your queries before you deploy your application.To test a query, perform the following steps:
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.
Click the Query Properties Results tab.
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.
- If you check New Login, iPlanet Application Builder displays a dialog box that enables you to specify the following information:
Type the appropriate information for these fields and click OK.
- If input parameters are required for this query, iPlanet Application Builder displays a dialog box for you to specify them. Note that you must place string parameters in single quotes if the query doesn't supply them.
To test the SQL for a new login, click New Login.
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 iPlanet Application Builder cannot parse your SQL, all other query editing tabs are disabled except the SQL and Results tabs.
- If the SQL code contains :<variables>, iPlanet Application Builder displays a dialog box for you to enter the associated input parameters.
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 servlet 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:
Run your application and access the URL that causes the JSP to be called.
where <ias> is the location in which iAS is installed, <appName> is the name of your application (for example, cdx), and <JSP_name> is the name of your JSP.
- The code is created in the following location:
- <ias>\Apps\compiled_jsp\<appName>\<JSP_name>.java
Add this file to your project as you would any other Java file.
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 iPlanet 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:
Open or select the servlet file.
It takes a few seconds for the server to start up, even though iPlanet Application Builder immediately displays the HTML page that leads to the code being tested. Exiting iPlanet Application Builder automatically shuts down any server that was started by iPlanet Application Builder. You should wait until your Messages window displays the "Server is ready to execute Servlets" message.Choose Test <servlet File Name> from the Test menu.
- iPlanet Application Builder tests the selected servlet file.
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 iAB with Symantec Visual Café.If your Java object doesn't compile correctly, or if your objects do not provide you with the expected behavior, you can use iPlanet Application Builder to check the state your program at a particular point in its execution via the Test and View menus or Debug toolbar.
Previous Contents Index DocHome Next
Copyright © 2000 Sun Microsystems, Inc. Some preexisting portions Copyright © 2000 Netscape Communications Corp. All rights reserved.
Last Updated April 28, 2000