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.


Top of page

x
CopyHTTPHeaderToWFVar Method

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.



Example: Using the CopyHTTPHeaderToWFVar Method

The following sample steps show how to use the CopyHTTPHeaderToWFVar method.

  1. In the WebFOCUS Administration Console, click Custom Settings under the Configuration menu, and add the following code:
    HTTP_HEADER_NAME=host
    WFS_VAR_NAME=WFV
    <call> CopyHTTPHeaderToWFVar (HTTP_HEADER_NAME,WFS_VAR_NAME)
    <set> WFV (PASS)
  2. Run the following ad hoc procedure:
    -TYPE &WFV

The Web server name in the HTTP Header is copied into a WFServlet variable.


Top of page

x
CopyWFVarToSessionVar Method

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).



Example: Using the CopyWFVarToSessionVar Method

The following sample steps show how to use the CopyWFVarToSessionVar method.

  1. In the /ibi/WebFOCUS/webapps/WebFOCUS/ directory, create the following sample.jsp, which uses the session.getAttribute method to retrieve the value of the Web Application session variable:
    <HTML>
    <BODY>
    Session variable value is  <%= session.getAttribute("sampleVariable") %>
    </BODY>
    </HTML>
  2. In the WebFOCUS Administration Console, click Custom Settings under the Configuration menu, and add the following code:
    <ifdef> IBIC_user
    SESSION_VAR_NAME=sampleVariable 
    WFS_VAR_NAME=IBIC_user
    <call> CopyWFVarToSessionVar() (WFS_VAR_NAME, SESSION_VAR_NAME)
    <endif>
  3. Log on to WebFOCUS using the http://hostname[:port]/ibi_html/wfsignon.html page.
  4. In the same browser window, navigate to http://hostname[:port]/ibi_apps/sample.jsp.

Upon running sample.jsp, the session variable displays the user ID that was provided on the sign-on page.


Top of page

x
CopySessionVarToWFVar Method

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.



Example: Using the CopySessionVarToWFVar Method

The following sample steps show how to use the CopySessionVarToWFVar method.

  1. In the /ibi/WebFOCUS/webapps/WebFOCUS/ directory, create the following sample.jsp, which uses the session.setAttribute method to initialize a Web Application session variable:
    <%@ page language="java" contentType="text/html"%>
    <%  session.setAttribute("sampleVariable","sampleValue"); %>
  2. In the WebFOCUS Administration Console, click Custom Settings under the Configuration menu, and add the following code:
    SESSION_VAR_NAME=sampleVariable
    WFS_VAR_NAME=WFV 
    <call> CopySessionVarToWFVar (SESSION_VAR_NAME,WFS_VAR_NAME)
    <set> WFV (PASS)
  3. Run the following ad hoc procedure:
    -TYPE &WFV

The Application Server session variable and its associated value that was copied to the WFServlet variable is displayed.


Top of page

x
CopyHTTPMethodToWFVar Method

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.



Example: Using the CopyHTTPMethodToWFVar Method

The following sample steps show how to use the CopyHTTPMethodToWFVar method.

  1. In the WebFOCUS Administration Console, click Custom Settings under the Configuration menu, and add the following code:
    WFS_VAR_NAME=WFV 
    <call> CopyHTTPMethodToWFVar(WFS_VAR_NAME) 
    <set> WFV (PASS)
  2. Run the following ad hoc procedure:
    -TYPE &WFV

Depending on how the WFServlet is called, a GET or POST operator is displayed.


Top of page

x
CopyHTTPCookieToWFVar Method

How to:

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.



Example: Using the CopyHTTPCookieToWFVar Method

The following sample steps show how to use the CopyHTTPCookieToWFVar method.

  1. In the WebFOCUS Administration Console, click Custom Settings under the Configuration menu, and add the following code:
    COOKIE_NAME=WF_SESSIONID 
    WFS_VAR_NAME=WFV 
    <call>CopyHTTPCookieToWFVar (COOKIE_NAME,WFS_VAR_NAME) 
    <set> WFV (PASS)
  2. Run the following ad hoc procedure:
    -TYPE &WFV

The contents of an HTTP cookie, in this case the WF_SESSIONID cookie, is displayed.



x
Procedure: How to Enable the WebFOCUS Servlet Plug-in

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.

  1. Select General under Client Settings on the Configuration menu and scroll down.

    Configuration Menu dialog box

  2. If this class is not displayed as the value of the WFEXT variable, you can enter it and click Save.

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.

For more information about the WebFOCUS Administration Console, see WebFOCUS Administration Console.



x
Procedure: How to Invoke the WebFOCUS Servlet Plug-in

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:

<CALL>

Is the command that invokes the WebFOCUS Servlet plug-in.

routine

Defines the name of the actual function to be called (for example, CopySessionVarToWFVar).

(parm1,parm2)

Are the input parameters of the method being called.

RETCODE

Is the status of the method call.

returncodevalue

Is the value you are comparing with what the plug-in returns (for example, 0).



Example: Invoking the WebFOCUS Servlet Plug-in

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