Using the Servlet

How to:

Reference:

If you are using the Servlet to run a dynamic report and pass variable values, you can call it:


Top of page

x
Reference: Requirements for WebFOCUS Servlet Configuration

Your web server must be servlet-enabled and have servlet support. The following types of servlet support are acceptable:


Top of page

x
Syntax: How to Call the Servlet From a Hyperlink
<A HREF="/alias/WFServlet?IBIF_ex=procedure[&var=value[&var=value]...]">text</A>

where:

alias

Points to the directory in which the WebFOCUS Servlet is located. A web server uses an alias to provide a logical name for a physical directory. The default alias is ibi_apps. It is set during WebFOCUS installation and configuration.

To call the WebFOCUS Servlet on another web server, specify a fully qualified URL, such as:

http://web_server/ibi_apps/WFServlet...
procedure

Is the name of the procedure to run.

var=value

Is a variable and its corresponding value. The call can include both HTTP environment variables and application variables passed to the procedure.

You can pass more than one variable-value pair, but do not include a space between pairs. Use an ampersand (&) as a delimiter to separate each variable-value pair.

If a value contains an embedded blank, substitute a plus sign (+) or the characters %20 for the blank.

text

Is the text on the launch page that serves as the hyperlink that runs the procedure.

Note: The maximum length of the URL can be 4K or 4,096 bytes. There is no limit on the number of the parameters, but their total length cannot exceed 4K.



Example: Calling the Servlet From a Hyperlink

This example creates a launch page with four hyperlinks. Each hyperlink calls the Servlet to pass:

Note: For information on where to store the files created in this example, see Defining and Allocating WebFOCUS Files.

  1. Create a procedure named CSALES. It generates a dynamic report that shows total unit and dollar sales for a category and region.

    Procedure: CSALES.FEX

    TABLE FILE GGSALES
    HEADING
    "&CATEGORY Sales for &RGN Region"
    SUM UNITS AND DOLLARS
    WHERE (CATEGORY EQ '&CATEGORY') AND (REGION EQ '&RGN');
    ON TABLE SET PAGE-NUM OFF
    ON TABLE SET STYLE *
    TYPE=REPORT, GRID=OFF,$
    ENDSTYLE
    END
  2. Create a launch page named CSALES. Each instance of the A HREF code calls the WebFOCUS Servlet and passes it the name of the procedure, CSALES. Each instance also passes the value Coffee for CATEGORY, and a value for RGN (Midwest, Northeast, Southeast, or West). The hyperlinks on the launch page prompt the user for the region of interest.

    Launch Page: CSALES.HTM

    <HTML>
    <HEAD>
    <TITLE> WebFOCUS Report </TITLE>
    </HEAD>
    <BODY>
    <H4 ALIGN=CENTER>Coffee Sales by Region</H4>
    <HR>
    <P><FONT SIZE=+2></FONT><BR>
    <FONT SIZE=+1>Select a region:</FONT>
    </P>
    <UL TYPE=SQUARE>
    <LI>
    <A HREF="/ibi_apps/WFServlet?IBIF_ex=csales&CATEGORY=
    Coffee&RGN=Midwest">Midwest</A>
    <LI>
    <A HREF="/ibi_apps/WFServlet?IBIF_ex=csales&CATEGORY=
    Coffee&RGN=Northeast">Northeast</A>
    <LI>
    <A HREF="/ibi_apps/WFServlet?IBIF_ex=csales&CATEGORY=
    Coffee&RGN=Southeast">Southeast</A>
    <LI>
    <A HREF="/ibi_apps/WFServlet?IBIF_ex=csales&CATEGORY=
    Coffee&RGN=West">West</A>
    </UL>
    </BODY>
    </HTML>
  3. Run the launch page in your browser. It will look similar to this:

  4. Click the hyperlink Midwest to receive the report:


Top of page

x
Syntax: How to Call the Servlet From a Form
<FORM ACTION="/ibi_apps/WFServlet" METHOD="get">
<INPUT NAME="IBIF_ex" VALUE="procedure" TYPE="hidden">
   .
   .
   .
</FORM>

where:

procedure

Is the name of the procedure to run. The call can include both HTTP environment variables and application variables passed to the procedure.


Top of page

x
Reference: Conventions for Creating a Form


Example: Calling the Servlet From a Form

This example creates a launch page with a form that calls the Servlet to pass:

Note: For information on where to store the files created in this example, see Defining and Allocating WebFOCUS Files.

  1. If you have not done so in a previous example, create a procedure named CSALES. It generates a dynamic report that shows total unit and dollar sales for the category and region requested by the user.

    Procedure: CSALES.FEX

    TABLE FILE GGSALES
    HEADING
    "&CATEGORY Sales for &RGN Region"
    SUM UNITS AND DOLLARS
    WHERE (CATEGORY EQ '&CATEGORY') AND (REGION EQ '&RGN');
    ON TABLE SET PAGE-NUM OFF
    ON TABLE SET STYLE *
    TYPE=REPORT, GRID=OFF,$
    ENDSTYLE
    END
  2. Create a launch page named SALES.HTM. It contains a form that calls the Servlet to pass the name of the procedure, CSALES. A one-line text box prompts the user for a value for CATEGORY, and radio buttons prompt for a value for RGN.

    The form also contains a Submit button (labeled Run Report) and a Reset button (labeled Clear Form). When you prompt for user input on a form, you must include a Submit button.

    Launch Page: SALES.HTM

    <HTML>
    <HEAD>
    <TITLE> WebFOCUS Report </TITLE>
    </HEAD>
    <BODY>
    <H4 ALIGN=CENTER>Sales Report by Category and Region</H4>
    <HR>
    <FORM ACTION="/ibi_apps/WFServlet" METHOD="get">
    <INPUT NAME="IBIF_ex" VALUE="csales" TYPE="hidden">
    <P ALIGN=LEFT NOWRAP><PRE>
    <B>Enter category: </B><INPUT NAME="CATEGORY" TYPE="text" SIZE="6">
    </PRE></P>
    <P><PRE><B>Select region: </B>
    <INPUT NAME="RGN" TYPE=RADIO VALUE=Midwest>Midwest
    <INPUT NAME="RGN" TYPE=RADIO VALUE=Northeast>Northeast
    <INPUT NAME="RGN" TYPE=RADIO VALUE=Southeast>Southeast
    <INPUT NAME="RGN" TYPE=RADIO VALUE=West>West
    </PRE></P>
    <P>
    <INPUT NAME="submit" TYPE=SUBMIT VALUE="Run Report"> 
    <INPUT NAME="reset" TYPE=RESET VALUE="Clear Form">
    </P>
    </FORM>
    </BODY>
    </HTML>
  3. Run the launch page in your browser. It will look similar to this:

  4. In the Enter category field, type:
    Coffee
  5. Select the Southeast radio button.
  6. Click Run Report to receive the report.


WebFOCUS