Using the HTTP Post command

MINI LESSONS ›› Actions Editor ›› Programming Commands ››

MINI LESSON

Basics of how to use the Actions Editor HTTP Post command in ToolBook

The HTTP Post command, as offered in the Actions Editor, will permit you to send data that you've collected within your ToolBook project and send it to a Web Server's server-side script.


A Server Side script is a program which is created and stored on a Web Server. These script files are typically Active Server Pages (.ASP), however can be written in a variety of other technologies such as PHP, and CGI. For the purposes of this Article I'll simply refer to this as an ASP page.


Once data is received by the ASP Page, that data can be processed in a variety of ways including storage in a database, and emailing it somewhere.


An ASP page is written to have very specific information (called Parameters) sent to it. This information is sent as a series of Name/Value pairs such as:


   Parameter Name: OrderNumber

   Parameter Value: 151443G


   Parameter Name: UserName

   Parameter Value: John H. Smith


ToolBook allows you to define your own Name/Value pairs and then initiate an HTTP Post command, specifying a particular ASP page.


ToolBook offers two HTTP Post type Actions within the Actions editor:

Set HTTP Post Parameter

Lets you designate a single Name/Value pair. You can call this action from anywhere in your book. ToolBook will cache these Name/Value pairs and will send all of them when the next HTTP Post action is performed.

HTTP Post

Lets you send all of the Name/Value pairs to the ASP Page specified. Once the HTTP Post command is called, ToolBook will forget all previously cached Name/Value pairs.


SCENARIO

This following example shows how to:


  1. Collect some data from page 1, to be posted later
  2. Obtain score data on the last page
  3. And send that data to an ASP Page


DETAILS

When the ToolBook application is first opened, ToolBook has no Name/Value pairs cached yet, so the cached list is considered empty.


   

NOTE

This "list" does not exist anywhere other than in the memory of ToolBook. As such there is no means of having ToolBook show you the current list.


In this example two fields are provided to the user to type information into. This information needs to be included in the HTTP Post information.


 


To ensure these two pieces of information are included as Name/Value pairs to be posted later, the following logic is added to the Field objects, using the Actions Editor.


This logic will ensure that the Name/Value pairs are configured as the user leaves the page.


 


 


Once the user leave the page, ToolBook will now be holding two sets of Name/Value pairs in the cache.


 


On the last page of this lesson the score is shown to the user and a Submit button presented to the user.


 


The Submit button will configure one additional Name/Value pair in order to allow the sending of the score data.


 


Once the final Set HTTP Post Parameter action is processes, the list of Name/Value pairs which ToolBook needs to cache is:


 


Once the actual HTTP Post command is executed, and the list of Name/Value pairs is sent, the cached list is cleared:


 


If your ASP Page is programmed to return some value back to ToolBook in response to ToolBook's Post Action, that value will be stored in a variable. In this example the variable was named retVal. Note that you have to configure a variable to hold a possible returned value into, even if your ASP Page will not be returning any data.


THINGS TO NOTE

The value you send to the ASP Page for any given parameter cannot be a variable defined as an Array. Using an Array will result in the ASP Page not receiving the Array data. The reason for this is that an Array is complex data object which allows for structured storage of information within it. This structure can't be passed as a Parameter of an HTTP Post.


If you use the Set HTTP Post Parameter action to specify a Name/Value pair such as "ID"/"03748DD4", and later in that same book use another Set HTTP Post Parameter action to specify a new value for the that same parameter "ID", what ultimately gets posted to the ASP Page is the most recent value you specified. The older value is essentially overwritten by the new value.


WHERE TO PUT YOUR ASP FILE?

If you place your ASP file on the same Web Server as your ToolBook generated DHTML content, then your browser should have no problems accessing the ASP file.


If you need to have your ASP file located on a different Web Server you'll need to ensure you turn on the following feature during the web export process:


  Use signed applet for AICC and HTTP Post


This setting gives the browser permission to post to a different server (called Cross-Domain Posting).


WRITING SEVER SIDE SCRIPT

The ToolBook Technical Support team cannot assist you in writing or debugging your Server Side Script files. We highly recommend that you contact an expert in this field to help you create your Server Side logic.



Created with the Personal Edition of HelpNDoc: Write eBooks for the Kindle