$Web: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:$Web}}
<span class="pageSubtitle">Determine whether running a web request</span>
<span class="pageSubtitle"><section begin="desc" />Determine whether running a web request<section end="desc" /></span>
 
<var>$Web</var> indicates whether the current processing is the result of a request to <var class="product">[[Janus Web Server]]</var>.
 
<var>$Web</var> takes no arguments and returns either a 0 or a 1.


$Web indicates whether the current processing is the result of a request to ''[[Janus Web Server]]''.
==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %RC = $Web
<p class="syntax"><span class="term">%rc</span> = $Web
<section end="syntax" /></p>
</p>


$Web takes no arguments and returns either a 0 or a 1.
===Return codes===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>Code</th>
<tr><th>Code</th>
<td>Meaning</td></tr>
<th>Meaning</th></tr>
<tr><th>0</th>
<tr><th>0</th>
<td>Not running a web request.</td></tr>
<td>Not running a web request.</td></tr>
<tr><th>1</th>
<tr><th>1</th>
<td>Running a web request.</td></tr>
<td>Running a web request.</td></tr>
</table>
</table>
<p class="caption">$WEB return codes</p>


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 and for ensuring that non-web, possibly 3270 specific code is not run for web requests.
==Usage notes==
<p class="code"> IF $Web THEN
<ul>
%DISTRICT = $Web_Form_Parm('DISTRICT')
<li>The <var>$Web</var> function is most useful for:
ELSE
<ul>
%DISTRICT = %QUERY:DISTRICT
<li>Preventing code that should only be run for a web request from running for 3270 (or other non-web) requests.</li>
END IF
<li>Ensuring that non-web, possibly 3270 specific code, is not run for web requests.</li>
<li>Under Model 204 7.8 and later, transactional daemon descendants of a web thread can also access the web API. However, $Web returns 0 on these threads. To check if the web API is available regardless of the thread type use [[$Web_Api]].</li>
</ul>
In the example below, the variable %DISTRICT is set from a form field when running a web request and from a screen field otherwise:
<p class="code">if $web then
  %district = $web_form_parm('DISTRICT')
else
  %district = %query:district
end if
</p>
</p>


In this example, the variable %DISTRICT is set from a form field when running a web request and from a screen field otherwise. $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'):
<li><var>$Web</var> has several advantages over other techniques for determining whether a request is running a web request, such as checking <var>[[$Web_Port]]</var> or doing a <code>$VIEW('IODEV')</code>:
 
<ul>
<ol>
<li>It is syntactically simple and easy to understand.  
<li>It is syntactically simple and easy to understand.  
<li>It works correctly even when a request is being debugged using JANUSDEBUG.  
<li>It works correctly even when a request is being debugged using JANUSDEBUG.  
<li>It works correctly and does not cause a "CONNECTION WAS LOST" user restart after the connection was closed either with a <var>$Web_Done</var> 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.
<li>It works correctly and does not cause a "CONNECTION WAS LOST" user restart after the connection was closed either with a <var>[[$Web_Done]]</var> or by the browser. This can be especially useful if there is web-specific processing, like APSY navigation code, that happens after a <var>$Web_Done</var>.
</ol>
</ul>


[[Category:Janus Web Server $functions|$Web]]
[[Category:Janus Web Server $functions|$Web]]

Latest revision as of 19:34, 20 January 2020

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.
    • Under Model 204 7.8 and later, transactional daemon descendants of a web thread can also access the web API. However, $Web returns 0 on these threads. To check if the web API is available regardless of the thread type use $Web_Api.

    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.