To start a WebObjects application from the command line:
If you don't have compiled code and haven't built a custom executable, use the WODefaultApp executable located in NeXT_Root/NextLibrary/Executables.
ApplicationExecutable
-d
DocumentRoot RelativeApplicationDirectory
You must provide a minimum of two arguments to the executable: the HTTP server's document root and the application directory relative to <DocumentRoot>/WebObjects. For example, the resources for HelloWorld are located in <DocumentRoot>/WebObjects/Examples/HelloWorld.woa, so HelloWorld's relative application directory is Examples/HelloWorld. (You must leave off the .woa extension.) You'd use the following command to start HelloWorld:
WODefaultApp.exe -d c:/netscape/ns-home/docs Examples/HelloWorld
To start a compiled application, you'd use the command:
AppName.exe
-d
DocumentRoot RelativeApplicationDirectory
For example, if you wanted to run an application named Registration.woa, you would change directories to the Registration.woa directory and then type:
Registration.exe -d c:/netscape/ns-home/docs
MyApplications/Registration
assuming you've placed Registration in a directory called MyApplications.
Note: If you're using Windows NT, be sure to use forward slashes in the arguments to the application executable, even if you're running the application from the DOS Command Prompt.
http://localhost/cgi-bin/WebObjects/MyApplications/Registration
myString = @"Elvis"; [self logWithFormat:@"The value of myString is %@", myString];When this code is parsed, the value of myString is substituted for the conversion specification %@. The conversion character @ indicates that the data type of the variable being substituted is an object (that is, of the id data type).
Because WebScript only supports the data type id, the conversion specification you use must always be %@. Unlike printf(), you can't supply conversion specifications for primitive C data types such as %d, %s, %f, and so on.
Perhaps the most effective debugging technique you can use in WebScript is to use logWithFormat: to print the contents of self. This causes WebScript to output the values of all of your variables. For example, putting the statement:
[self logWithFormat:@"The contents of self in register are %@", self];at the end of the register method in the Registration application's Main.wos script produces output that resembles the following:
The contents of self in register are <WOComponent 0xafe04 message = You have been successfully registered. newPerson = { address = "Graceland\015\nNashville, TN"; email = "elvis@graceland.com"; name = Elvis; }>Note: If you're writing Java code, the logWithFormat: method is named logString and you can send it only to WebApplication objects. Instead of using printf() conversion specifications, it uses concatenation. Here's how you'd write the same line of code in Java:
this.application().logString("The contents of this in register are " + this.toString());
To use any of the trace methods, you must run your application from a command shell.
- init { [super init]; [self.application traceAssignments:YES]; [self.application traceScriptedMessages:YES]; return self; }Note: The trace methods are not available in the Java interface.
Table of Contents Next Section