KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Clearing web form variables in COMPILER_WEB
PRODUCT: 4D | VERSION: 6.5 | PLATFORM: Mac & Win
Published On: March 16, 2001

When submitting an HTML form to 4D, the contents of all named inputs will be automatically placed into process variables with the same name. Consider the following page:




When this form is submitted by a web browser, the project method AcceptForm01 executes and 4D will fill the process variable "vtName" with the submitted value which can then be accessed from the code.

In Non-contextual mode, it is good practice to both declare and clear your form variables in the special COMPILER_WEB project method (i.e. initialize their values). This is because under high-load conditions 4D recycles web processes to increase performance - avoiding the overhead of frequently spawning new processes to handle new requests. If a web process has just finished handling the submission of a query from UserA, then is immediately allocated to another user submission of the same HTML form, the process variables from UserA's query will still be resident in memory and can cause wrong results to be returned. Since COMPILER_WEB is called automatically by 4D at the beginning of every HTML form submission before 4D parses the form data, this is the correct place to initialize form variables.



NOTE: In 4D v6.7 and above, you can take advantage of the new command GET WEB FORM VARIABLES and avoid having to initialize your HTML form variables.

Command: Web Services, Special URLs and Form Actions

Command: Web Services, HTML and Javascript Encapsulation

Command: Web Services, Non Contextual Mode

Command: Web Services, Web Connection Processes

Command: GET WEB FORM VARIABLES