server_root
/wai/examples
directory on UNIX and in the server_root
\wai\examples
directory on Windows NT.
NOTE: These examples assume that your server is running in non-secure mode.For more detailed information on setting up, writing, and running WAI applications, see the rest of the chapters in this manual:
server_root
/wai/examples/CIIOP
directory. The source file for the example is CAPIIIOP.c
.
This example sends a page containing the text Hello World back to the client, as shown in the following figure:
The rest of this section explains how to set up and use this example. You can use this as a guideline for setting up and running your own C examples.
To run the sample C application, follow these steps:
osagent
is located under server_root
/wai/bin
in UNIX and
server_root
\wai\bin
in Windows NT.
Specify the
-a
flag to restrict osagent
to the localhost IP address. For
example:
osagent -a 127.0.0.1
From the Server Administration page in the administration server, click the
button labelled with your server name. This displays the Server Manager for
your server.
Click Programs | WAI Management to display the form for administering
WAI on your server.
Under Enable WAI Services, select the Yes radio button and click OK. Save
and apply your changes.
For more information, see "Setting the Option to Enable WAI".
Basically, the code in this source file does the following (for a more
complete explanation of these steps, see Chapter 4, "Writing a WAI
Application in C"):
mooncheese
: CAPIIIOP mooncheese:80
WAIcreateWebAppService()
function to create a new web application service named CAPIIIOP
. Users will be able to access this web service through the following URL (if, for example, your web server is running on port 80 of the server named mooncheese
): http://mooncheese.mydomain.com:80/iiop/CAPIIIOP
WAIregisterService()
function to register the web application with the web server running on the host and port number specified on the command-line. WAIimplIsReady()
function to indicate to the web server that it is ready to receive requests.
WAIsetResponseContentLength()
function to specify the content length of the page returned to the client.WAIStartResponse()
function to start sending the response to the client.WAIWriteClient()
function to send the text "Hello World" to the client.
The sample application includes a Makefile (for example,
Makefile.SOLARIS
or Makefile.WINNT
) that you can use to compile and
link the application.
For more information on compiling and linking your application, see
"Compiling C/C++ Applications".
CAPIIIOP hostname:port
where
hostname
and port
identify the name of the machine that the web
server runs on and the port number that the server listens to. For example:
CAPIIIOP myserver:80
This registers the application with the web server. The web server should
be able to find the CAIIIOP WAI application.
http://hostname:port/iiop/CAPIIIOP
where hostname and
port
identify the name of the machine that the web
server runs on and the port number that the server listens to. For example:
http://myserver:80/iiop/CAPIIIOP
The web server processes the request. While processing the request, the
server parses the URL, retrieves the name of the service you want to access
(CAPIIIOP), and contacts your application.
Your application receives the request and returns the Hello World string.
The web server returns this to the web browser.
server_root
/wai/examples/WASP
directory. The source file for the example is WASP.cpp
.
This example does the following:
You can use this example as a guideline for setting up and running your own C++ examples. To run the sample C++ application, follow these steps:
osagent
is located under server_root
/wai/bin
in UNIX and
server_root\wai\bin
in Windows NT.
Specify the
-a
flag to restrict osagent
to the localhost IP address. For
example:
osagent -a 127.0.0.1
From the Server Administration page in the administration server, click the
button labelled with your server name. This displays the Server Manager for
your server.
Click Programs | WAI Management to display the form for administering
WAI on your server.
Under Enable WAI Services, select the Yes radio button and click OK. Save
and apply your changes.
For more information, see "Setting the Option to Enable WAI".
Basically, the code in this source file does the following (for a more
complete explanation of these steps, see Chapter 5, "Writing a WAI
Application in C++"):
mooncheese
: WASP mooncheese:80
WASP
. Users will be able to access this web service through the following URL (if, for example, your web server is running on port 80 of the server named mooncheese
): http://mooncheese.mydomain.com:80/iiop/WASP
RegisterService
method to register the web application with the web server running on the host and port number specified on the command-line.
getCookie
and setCookie
methods to demostrate how to get and set cookies in the client.getRequestInfo
method.setResponseContentLength
method to specify the length of the content to be delivered to the client.StartResponse
method to start sending the HTTP response back to the client. WriteClient
method to send data back to the client.
The sample application includes a sample Makefile (for example,
Makefile.SOLARIS or Makefile.WINNT) that you can use to compile and link
the application.
For more information on compiling and linking your application, see
"Compiling C/C++ Applications".
WASP hostname:port
where
hostname
and port
identify the name of the machine that the web
server runs on and the port number that the server listens to. For example:
WASP myserver:80
This registers the application with the web server. The web server should
be able to find the WASP WAI application.
http://hostname:port/iiop/WASP
where
hostname
and port
identify the name of the machine that the web
server runs on and the port number that the server listens to. For example:
http://myserver:80/iiop/WASP
The web server processes the request. While processing the request, the
server parses the URL, retrieves the name of the service you want to access
(WASP), and contacts your application.
Your application receives the request and retrieving information from the
request and the web server. The web server returns this information to the
web browser in an HTML page.
server_root
/wai/examples/WASP
directory. The source file for the example is WASP.java
.
This example does the following:
osagent
is located under server_root
/wai/bin
in UNIX and
server_root
\wai\bin
in Windows NT.
Specify the
-a
flag to restrict osagent
to the localhost IP address. For
example:
osagent -a 127.0.0.1
From the Server Administration page in the administration server, click the
button labelled with your server name. This displays the Server Manager for
your server.
Click Programs | WAI Management to display the form for administering
WAI on your server.
Under Enable WAI Services, select the Yes radio button and click OK. Save
and apply your changes.
For more information, see "Setting the Option to Enable WAI".
Make sure to include the following files in your
CLASSPATH
environment
variable:
server_root
/wai/java/nisb.zip
server_root
/wai/java/WAI.zip
java -DDISABLE_ORB_LOCATOR WASP hostname:port
TheIf you are running a 3.0.1 version of a Netscape web server, run the following command:-DDISABLE_ORB_LOCATOR
option specifies thatosagent
should not be used to find the ORB in the Netscape web server.
java WASP hostname:port
This registers the application with the web server. The web server should be able to find the JavaWASP WAI application.
http://hostname:port/iiop/JavaWASP
where
hostname
and port
identify the name of the machine that the web
server runs on and the port number that the server listens to. For example:
http://myserver:80/iiop/JavaWASP
The web server processes the request. While processing the request, the
server parses the URL, retrieves the name of the service you want to access
(JavaWASP), and contacts your application.
(Note that the name used to register the server -- JavaWASP -- does not
necessarily need to be the same as the name of the class -- WASP.)
Your application receives the request and retrieving information from the
request and the web server. The web server returns this information to the
web browser in an HTML page.
FormHandler
class, you can write a WAI application that receives and interprets data submitted through an HTML form.
To read in and parse posted form data (where the client used the HTTP POST
method to submit the form), create an instance of the FormHandler
class. The constructor for this class reads in the data and parses it.
To read in and parse form data submitted through the HTTP GET
method, create an instance of the FormHandler
class and call the ParseQueryString
method.
Depending on the language you are using, you can access the parsed data in different ways:
Get
method to get the value of a specific name-value pair, or you can call the InitIterator
method and the Next
method to iterate through all name-value pairs in the parsed data.You can also call the
Add
method to add a new name-value pair to the
parsed form data and the Delete
method to remove a name-value pair
from the parsed form data.
GetHashTable
method to get a Java hash table containing the parsed data. Then, you can call methods of the java.util.Hashtable
class to access the data.The names serve as keys in the hashtable. The values are stored as Java
vectors (for details, see your Java documentation on
java.util.Vector
).
The values are implemented as Java vectors because a given name may be
associated with multiple values. For example, if the form contains multiple-
selection input, the submitted form data can contain several name-value
pairs with the same name but different values.
server_root
/wai/examples/forms
directory. This directory contains C++ and Java examples of using the WAI FormHandler
class. You can use this class to process data submitted through an HTML form.This directory contains the following files:
The C++ example is written as an in-process server plug-in. The Java example is written as a stand-alone application (running out of process). Both examples process and display data submitted through theform.html
form.
server_root
/wai/examples/forms
directory. The source file for the example is formHandler.cpp
.
This example is written as an in-process server plug-in that performs the following tasks:
NVPair
class.
InitIterator
method and the Next
method to iterate through all name-value pairs in the parsed data.
You can use this example as a guideline for setting up and running your own C++ forms.
For example:
nmake -f Makefile.WINNT
or
make -f Makefile.SOLARIS
obj.conf
file (located in the server-root
/
server-id
/config
directory) in a text editor.
For example:
Init funcs="FormInit" shlib="server-root/wai/examples/forms/form.dll" fm="load-modules"
Init LateInit="yes" fn="FormInit"or
Init funcs="FormInit" shlib="server_root/wai/examples/forms/form.so" fn="load-modules"
Init LateInit="yes" fn="FormInit"When you specify the
Init
directive make sure to set LateInit
to "yes"
.
For example:
<FORM name="submitform" method="POST" ACTION="/iiop/FORMip">
FORMip
is the name with which this WAI server plug-in registers.
http://server-name:port-number/form.html
The WAI server plug-in should send a generated HTML page back to your
browser. The page should display some of the data you have submitted.
form.html
form in the /wai/examples/forms
directory.
javac TestDriver.java
Specify the server name and port number of your Enterprise Server as
follows:
java TestDriver server-name:port-number
For example:
<FORM name="submitform" method="POST" ACTION="/iiop/JavaForm">
JavaForm
is the name with which this WAI application registers.
http://server-name:port-number/form.html
The WAI application should send a generated HTML page back to your
browser. The page should display some of the data you have submitted.
Last Updated: 12/04/97 16:11:51
Any sample code included above is provided for your use on an "AS IS" basis, under the Netscape License Agreement - Terms of Use