WebFOCUS Online Help > WebFOCUS Administration Console > Manipulating WebFOCUS Variables > Copying WebFOCUS Variables Using the WebFOCUS Servlet Plug-in
In this section: |
A WebFOCUS Servlet built-in plug-in is available containing methods for manipulating WebFOCUS variables. Since the parameters passed to each of these methods cannot be literal values, the values must first be placed into variables, where they can then be used in the method call.
For a list of HTTP header variables placed in the WebFOCUS variable table, see HTTP Header Variables Available for Script Processing.
The CopyHTTPHeaderToWFVar method copies the value of an HTTP Header variable into a WFServlet variable.
Parameters:
HTTP_HEADER_NAME - Is the name of the HTTP Header entry from which the value is retrieved.
WFS_VAR_NAME - Is the name of the WebFOCUS Servlet variable that receives the value.
Returns:
0 = Success
999 = Failure
The WebFOCUS Servlet variable is not initialized upon failure.
The following sample steps show how to use the CopyHTTPHeaderToWFVar method.
HTTP_HEADER_NAME=host WFS_VAR_NAME=WFV <call> CopyHTTPHeaderToWFVar (HTTP_HEADER_NAME,WFS_VAR_NAME) <set> WFV (PASS)
-TYPE &WFV
The Web server name in the HTTP Header is copied into a WFServlet variable.
The CopyWFVarToSessionVar method copies the value of a WFServlet variable into a Web Application session variable.
Parameters:
WFS_VAR_NAME - Is the name of the WebFOCUS Servlet variable. The value of this variable is the name of the actual WebFOCUS variable whose value is copied into the Web Application session variable.
SESSION_VAR_NAME - Is the name of the Web Application session variable that receives the value.
Returns:
This function always returns 0 (zero).
The following sample steps show how to use the CopyWFVarToSessionVar method.
<HTML> <BODY> Session variable value is <%= session.getAttribute("sampleVariable") %> </BODY> </HTML>
<ifdef> IBIC_user SESSION_VAR_NAME=sampleVariable WFS_VAR_NAME=IBIC_user <call> CopyWFVarToSessionVar() (WFS_VAR_NAME, SESSION_VAR_NAME) <endif>
Upon running sample.jsp, the session variable displays the user ID that was provided on the sign-on page.
The CopySessionVarToWFVar method copies the value of a Web Application session variable into a WFServlet variable.
Parameters:
SESSION_VAR_NAME - Is the name of the Web Application session variable.
WFS_VAR_NAME - Is the name of the WebFOCUS Servlet variable that receives the value.
Returns:
0 = Success
999 = Failure
The WebFOCUS Servlet variable is not initialized upon failure.
The following sample steps show how to use the CopySessionVarToWFVar method.
<%@ page language="java" contentType="text/html"%> <% session.setAttribute("sampleVariable","sampleValue"); %>
SESSION_VAR_NAME=sampleVariable WFS_VAR_NAME=WFV <call> CopySessionVarToWFVar (SESSION_VAR_NAME,WFS_VAR_NAME) <set> WFV (PASS)
-TYPE &WFV
The Application Server session variable and its associated value that was copied to the WFServlet variable is displayed.
The CopyHTTPMethodToWFVar method copies a value representing the HTTP request type into a WFServlet variable. The request type is usually GET or POST.
Parameters:
WFS_VAR_NAME - Is the name of the WebFOCUS Servlet variable that receives the value.
Returns:
0 = Success
999 = Failure
The WebFOCUS Servlet variable is not initialized upon failure.
The following sample steps show how to use the CopyHTTPMethodToWFVar method.
WFS_VAR_NAME=WFV <call> CopyHTTPMethodToWFVar(WFS_VAR_NAME) <set> WFV (PASS)
-TYPE &WFV
Depending on how the WFServlet is called, a GET or POST operator is displayed.
The CopyHTTPCookieToWFVar method copies the contents of an HTTP cookie into a WFServlet variable.
Parameters:
COOKIE_NAME - Is the name of the HTTP cookie from which the value is retrieved.
WFS_VAR_NAME - Is the name of the WebFOCUS Servlet variable that receives the value.
Returns:
0 = Success
999 = Failure
The WebFOCUS Servlet variable is not initialized upon failure.
The following sample steps show how to use the CopyHTTPCookieToWFVar method.
COOKIE_NAME=WF_SESSIONID WFS_VAR_NAME=WFV <call>CopyHTTPCookieToWFVar (COOKIE_NAME,WFS_VAR_NAME) <set> WFV (PASS)
-TYPE &WFV
The contents of an HTTP cookie, in this case the WF_SESSIONID cookie, is displayed.
The WebFOCUS Servlet Plug-in is enabled by setting the WFEXT variable to the class name ibi.webfoc.WFEXTDefault. This value is set in the cgivars.wfs file by default.
You can see that its class is specified in the WebFOCUS Administration Console.
Note: Only one plug-in can be active at a time. If you need to add additional functionality, you should extend this class to include your functionality so that you do not lose access to the methods provided in this class.
To invoke the WebFOCUS Servlet plug-in, add the following code to the \ibi\client\wfc\etc\site.wfs file:
<CALL> routine(parm1,parm2) <if> RETCODE NE "returncodevalue" # insert your code here <endif>
where:
Is the command that invokes the WebFOCUS Servlet plug-in.
Defines the name of the actual function to be called (for example, CopySessionVarToWFVar).
Are the input parameters of the method being called.
Is the status of the method call.
Is the value you are comparing with what the plug-in returns (for example, 0).
When the following code is added to the \ibi\client\wfc\etc\site.wfs file, the value of IBIC_user is copied from an HTTP session to a WFS variable.
wfvar=IBIC_user httpsession=_ibuser <call> CopySessionVarToWFVar(httpsession,wfvar)
Note: httpsession and wfvar are variables and cannot be replaced with literal values.
WebFOCUS |