iTP Active Transaction Pages (iTP ATP) Programmer's Guide

ATP Web Page and Script Structure
iTP Active Transaction Pages (iTP ATP) Programmer’s Guide522292-002
3-6
Using NonStop SQL from JavaScript
Accepting the Request from the Browser
To identify the kind of request received from the browser, the script
(/examples/sql/homebank/Webpages/address.atp) examines the
atp.request object. Specifically, the script tests the REQUEST_METHOD
environment variable, which is a property of the atp.request object. The value
POST indicates that the user submitted a form. In this case, POST signifies that the user
requested a transaction. (Alternatively, a script could recognize a transaction by
detecting that a specific button was pressed.)
The general structure of the script depends on the request method:
If this is a GET operation, get the current data, then print it.
If this is a POST operation, update the database, get the current (updated) data, and
then print it.
Example 3-3. NonStop SQL Includes and Server-Side JavaScript
</script>
<!--------------------------------------------------------->
</HEAD>
<BODY>
<!--#include file="util_server.inc"-->
<!--#include file="send_to_server.inc"-->
<!--#include file="access_check.inc"-->
<!--------------------------------------------------------->
<SERVER>
// Check why this page is being loaded (the page invokes
// itself to do transactions)
var ServiceName;
if (atp.request.REQUEST_METHOD=="POST")
// page is being loaded because user submitted a transaction
ServiceName = "addresschangeaccept";
else
ServiceName = "addresschangedisplay"
// Check security and get back the userid (in
// 'globalAccessUserid')....