$Web
Determine whether running a web request
$Web indicates whether the current processing is the result of a request to Janus Web Server.
$Web takes no arguments and returns either a 0 or a 1.
Syntax
%rc = $Web
Return codes
Code | Meaning |
---|---|
0 | Not running a web request. |
1 | Running a web request. |
Usage notes
- The $Web function is most useful for:
- Preventing code that should only be run for a web request from running for 3270 (or other non-web) requests.
- Ensuring that non-web, possibly 3270 specific code, is not run for web requests.
In the example below, the variable %DISTRICT is set from a form field when running a web request and from a screen field otherwise:
IF $Web THEN %DISTRICT = $Web_Form_Parm('DISTRICT') ELSE %DISTRICT = %QUERY:DISTRICT END IF
- $Web has several advantages over other techniques for determining whether a request is running a web request, such as checking $Web_Port or doing a
$VIEW('IODEV')
:- It is syntactically simple and easy to understand.
- It works correctly even when a request is being debugged using JANUSDEBUG.
- It works correctly and does not cause a "CONNECTION WAS LOST" user restart after the connection was closed either with a $Web_Done or by the browser. This can be especially useful if there is web-specific processing, like APSY navigation code, that happens after a $Web_Done.