Chapter 50. HTP

Table of Contents

50.1. Overview
50.2. Interoperation with Apache
50.3. Procedures and Functions
50.3.1. BODYCLOSE
50.3.2. BODYOPEN
50.3.3. BR
50.3.4. CENTER
50.3.5. CENTERCLOSE
50.3.6. CENTEROPEN
50.3.7. FONTCLOSE
50.3.8. FONTOPEN
50.3.9. FORMSELECTCLOSE
50.3.10. FORMSELECTOPEN
50.3.11. FORMSELECTOPTION
50.3.12. GET_PAGE
50.3.13. HEADCLOSE
50.3.14. HEADER
50.3.15. HEADOPEN
50.3.16. HR
50.3.17. HTMLCLOSE
50.3.18. HTMLOPEN
50.3.19. IMG
50.3.20. IMG2
50.3.21. LINE
50.3.22. PRINT
50.3.23. PRN
50.3.24. TITLE

This chapter briefly introduces the HTP package, and describes how to use the procedures and functions of the package.

50.1. Overview

HTP is used to generate HTML source code. This package generates HTML tags using procedures, and outputs the resulting source code. For example, HTP.HTMLOPEN creates the <HTML> tag, and HTP.HTMLCLOSE creates the </HTML> tag.

50.2. Interoperation with Apache

The Apache module, mod_tbpsm was implemented in Tibero 5.0. To process requests from the Apache HTTP server, the mod_tbpsm module calls the required HTP package procedures and returns the resulting HTML code.

Note

To learn how to configure and use mod_tbpsm, refer to Tibero Application Developer's Guide.

50.3. Procedures and Functions

This section describes the procedures and functions provided by the HTP package, in alphabetical order.

50.3.1. BODYCLOSE

Creates the </BODY> tag that indicates the end of the body in an HTML document.

Details about the BODYCLOSE procedure are as follows:

  • Prototype

    HTP.BODYCLOSE
    
  • Example

    BEGIN
        HTP.BODYCLOSE;
    END;

    This example generates the following HTML code.

    </BODY>

50.3.2. BODYOPEN

Creates the <BODY> tag that indicates the start of the body in an HTML document, and this procedure can also change the document background by specifying the attribute.

Details about the BODYOPEN procedure are as follows:

  • Prototype

    HTP.BODYOPEN 
    (
        background       IN      VARCHAR2       DEFAULT NULL,
        attributes       IN      VARCHAR2       DEFAULT NULL
    )
    
  • Parameter

    ParameterDescription
    backgroundBackground attribute value of the <BODY> tag. This specifies the path to a background image file for the HTML document.
    attributesOther attributes and values of the <BODY> tag.
  • Example

    BEGIN
        HTP.BODYOPEN('/img/tibero.jpg');
    END;
    

    This example generates the following HTML code.

    <BODY background="/img/tibero.jpg">
    

50.3.3. BR

Generates the <BR> tag, which indicates a new line in an HTML page.

Details about the BR procedure are as follows:

  • Prototype

    HTP.BR 
    (
        clear         IN     VARCHAR2      DEFAULT NULL,
        attributes    IN     VARCHAR2      DEFAULT NULL
    )
    
  • Parameter

    ParameterDescription
    clearCLEAR attribute value.
    attributesOther attribute-value pairs.
  • Example

    BEGIN
        HTP.BR;
    END;

    This example generates the following HTML code.

    <BR>

50.3.4. CENTER

Generates the <CENTER> tag, text to centrally align, and the </CENTER> tag.

Details about the CENTER procedure are as follows:

  • Prototype

    HTP.CENTER 
    (
        text      IN       VARCHAR2
    )
    
  • Parameter

    ParameterDescription
    textText to centrally align on the web page.
  • Example

    BEGIN
        HTP.CENTER('Tibero');
    END;

    This example generates the following HTML code.

    <CENTER>Tibero</CENTER>

50.3.5. CENTERCLOSE

Generates the </CENTER> tag.

Details about the CENTERCLOSE procedure are as follows:

  • Prototype

    HTP.CENTERCLOSE
  • Example

    BEGIN
        HTP.CENTERCLOSE;
    END;

    This example generates the following HTML code.

    </CENTER>

50.3.6. CENTEROPEN

Generates the <CENTER> tag.

Details about the CENTEROPEN procedure are as follows:

  • Prototype

    HTP.CENTEROPEN
    
  • Example

    BEGIN
        HTP.CENTEROPEN;
        HTP.IMG(url => '/img/tibero.gif');
        HTP.CENTERCLOSE;
    END;

    This example generates the following HTML code.

    <CENTER>
    <IMG src="/img/tibero.glf">
    </CENTER>

50.3.7. FONTCLOSE

Generates the </FONT> tag. Attributes specified inside the <FONT> tag are only applied to the contents that comes before the </FONT> tag.

Details about the FONTCLOSE procedure are as follows:

  • Prototype

    HTP.FONTCLOSE
  • Example

    BEGIN
        HTP.FONTCLOSE;
    END;

    This example generates the following HTML code.

    </FONT>

50.3.8. FONTOPEN

Generates the <FONT> tag for specifying font details for text.

Details about the FONTOPEN procedure are as follows:

  • Prototype

    HTP.FONTOPEN 
    (
        color         IN       VARCHAR2    DEFAULT NULL,
        face          IN       VARCHAR2    DEFAULT NULL,
        size          IN       VARCHAR2    DEFAULT NULL,
        attributes    IN       VARCHAR2    DEFAULT NULL
    )
  • Parameter

    ParameterDescription
    colorCOLOR attribute value.
    faceFACE attribute value.
    sizeSIZE attribute value.
    attributesOther attribute-value pairs.
  • Example

    BEGIN
        HTP.FONTOPEN(NULL, 'Fixedsys', 3);
    END;

    This example generates the following HTML code.

    <FONT face="Fixedsys" size="3">

50.3.9. FORMSELECTCLOSE

Generates the </SELECT> tag.

Details about the FORMSELECTCLOSE procedure are as follows:

50.3.10. FORMSELECTOPEN

Generates the <SELECT> tag.

Details about the FORMSELECTOPEN procedure are as follows:

  • Prototype

    HTP.FORMSELECTOPEN 
    (
        cname       IN  VARCHAR2,
        cprompt     IN  VARCHAR2    DEFAULT NULL,
        nsize       IN  VARCHAR2    DEFAULT NULL,
        cattributes IN  VARCHAR2    DEFAULT NULL
    )
  • Parameter

    ParameterDescription
    cpromptText that precedes the tag.
    cnameNAME attribute value.
    nsizeSIZE attribute value.
    cattributesOther attribute-value pairs.
  • Example

    BEGIN
        HTP.FORMSELECTOPEN('favorite_fruit', 'What's your favorite fruit?');
        HTP.FORMSELECTOPTION('apple');
        HTP.FORMSELECTOPTION('grape');
        HTP.FORMSELECTOPTION('tangerine');
        HTP.FORMSELECTOPTION('plum');
        HTP.FORMSELECTCLOSE;
    END;

    This example generates the following HTML code.

    What's your favorite fruit?:
    <SELECT NAME="favorite_fluit">
    <OPTION>apple
    <OPTION>grape
    <OPTION>tangerine
    <OPTION>plum
    </SELECT>          

50.3.11. FORMSELECTOPTION

Generates the <OPTION> tag.

Details about the FORMSELECTOPTION procedure are as follows:

  • Prototype

    HTP.FORMSELECTOPTION 
    (
        cvalue         IN  VARCHAR2,
        cselected      IN  VARCHAR2    DEFAULT NULL,
        cattributes    IN  VARCHAR2    DEFAULT NULL
    )
  • Parameter

    ParameterDescription
    cvalueText to select.
    cselectedSELECTED attribute value.
    cattributesOther attribute-value pairs.
  • Example

    Refer to the example in “50.3.10. FORMSELECTOPEN”.

50.3.12. GET_PAGE

Gets a web page output.

Details about the GET_PAGE procedure are as follows:

  • Prototype

    HTP.GET_PAGE 
    (
        page OUT NOCOPY  CLOB
    )
  • Parameter

    ParameterDescription
    pageUsed to get the web page output.
  • Example

    DECLARE
        page CLOB;
    BEGIN
        HTP.HTMLOPEN;
        HTP.HTMLCLOSE;
    
        htp.get_page(page);
        dbms_output.put_line(page);
    END;

50.3.13. HEADCLOSE

Generates the </HEAD> tag that indicates the end of the head in an HTML document.

Details about the HEADCLOSE procedure are as follows:

  • Prototype

    HTP.HEADCLOSE
    
  • Example

    BEGIN
        HTP.HEADCLOSE;
    END;

    This example generates the following HTML code.

    </HEAD>

50.3.14. HEADER

Generates the tag that starts the header (<H1> - <H6>), the header text, and the closing header tag (</H1> - </H6>).

Details about the HEADER procedure are as follows:

  • Prototype

    HTP.HEADER 
    (
        level       IN      PLS_INTEGER,
        name        IN      VARCHAR2,
        align       IN      VARCHAR2    DEFAULT NULL,
        nowrap      IN      VARCHAR2    DEFAULT NULL,
        clear       IN      VARCHAR2    DEFAULT NULL,
        attributes  IN      VARCHAR2    DEFAULT NULL
    )
  • Parameter

    ParameterDescription
    levelHeader level. A number from 1 to 6.
    nameHeader text.
    alignALIGN attribute value.
    nowrapNOWRAP attribute value.
    clearCLEAR attribute value.
    attributesOther attribute-value pairs.
  • Example

    BEGIN
        HTP.HEADER(1, 'Tibero');
    END;

    This example generates the following HTML code.

    <H1>Tibero</H1>

50.3.15. HEADOPEN

Generates the <HEAD> tag that indicates the start of the head in an HTML document.

Details about the HEADOPEN procedure are as follows:

  • Prototype

    HTP.HEADOPEN
    
  • Example

    BEGIN
        HTP.HEADOPEN;
    END;

    This example generates the following HTML code.

    <HEAD>

50.3.16. HR

Generates the <HR> tag that draws a horizontal line in an HTML page.

Details about the HR procedure are as follows:

  • Prototype

    HTP.HR 
    (
        clear       IN      VARCHAR2    DEFAULT NULL,
        src         IN      VARCHAR2    DEFAULT NULL,
        attributes  IN      VARCHAR2    DEFAULT NULL
    )
  • Parameter

    ParameterDescription
    clearCLEAR attribute value.
    srcSRC attribute value that specifies a background image file for the horizontal line.
    attributesOther attribute-value pairs.
  • Example

    BEGIN
        HTP.HR(src => '"/img/tibero.jpg"',
               attributes => 'size="10" noshade style="color:gray;"');
    END;

    This example generates the following HTML code.

    <HR src="/img/tibero.jpg" size="10" noshade style="color:gray;">

50.3.17. HTMLCLOSE

Generates the </HTML> tag that indicates the end of the HTML document.

Details about the HTMLCLOSE procedure are as follows:

  • Prototype

    HTP.HTMLCLOSE
  • Example

    BEGIN
        HTP.HTMLCLOSE;
    END;

    This example generates the following HTML code.

    </HTML>

50.3.18. HTMLOPEN

Generates the <HTML> tag that indicates the start of the HTML document.

Details about the HTMLOPEN procedure are as follows:

  • Prototype

    HTP.HTMLOPEN
    
  • Example

    BEGIN
        HTP.HTMLOPEN;
    END;

    This example generates the following HTML code.

    <HTML>

50.3.19. IMG

Generates the <IMG> tag, which inserts an image in the HTML page.

Details about the IMG procedure are as follows:

  • Prototype

    HTP.IMG 
    (
        url        IN      VARCHAR2,
        align      IN      VARCHAR2    DEFAULT NULL,
        alt        IN      VARCHAR2    DEFAULT NULL,
        ismap      IN      VARCHAR2    DEFAULT NULL,
        attributes IN      VARCHAR2    DEFAULT NULL
    )
  • Parameter

    ParameterDescription
    urlURL attribute value that specifies an image file.
    alignALIGN attribute value.
    altALT attribute value that specifies the text that is displayed when the web browser does not support images.
    ismapNon-NULL value specifies the ISMAP attribute value that indicates whether the image is an image map.
    attributesOther attribute-value pairs.
  • Example

    BEGIN
        HTP.IMG(url => '"/img/tibero.gif"', 
                attributes => 'WIDTH="200" HEIGHT="200" BORDER="1"');
    END;

    This example generates the following HTML code.

    <IMG src="/img/tibero.gif" WIDTH="200" HEIGHT="200" BORDER="1">

50.3.20. IMG2

Generates the <IMG> tag that inserts an image in the HTML page. Its only difference from the IMG procedure is that the IMG2 procedure has the usemap parameter.

Details about the IMG2 procedure are as follows:

  • Prototype

    HTP.IMG 
    (
        url        IN      VARCHAR2,
        align      IN      VARCHAR2    DEFAULT NULL,
        alt        IN      VARCHAR2    DEFAULT NULL,
        ismap      IN      VARCHAR2    DEFAULT NULL,
        usemap     IN      VARCHAR2    DEFAULT NULL,
        attributes IN      VARCHAR2    DEFAULT NULL
    )
  • Parameter

    ParameterDescription
    urlSRC attribute value that specifies an image file.
    alignALIGN attribute value.
    altALT attribute value that specifies the text that is displayed when the Web browser does not support images.
    ismapNon-NULL value specifies the ISMAP attribute value that indicates whether the image is an image map.
    usemapUSEMAP attribute value.
    attributesOther attribute-value pairs.
  • Example

    BEGIN
        HTP.IMG2(url => '"/img/tibero.gif"', 
                 attributes => 'WIDTH="200" HEIGHT="200" BORDER="1"');
    END;

    This example generates the following HTML code.

    <IMG src="/img/tibero.gif" WIDTH="200" HEIGHT="200" BORDER="1">

50.3.21. LINE

Generates the <HR> tag that draws a horizontal line on an HTML page. This has the same functionality as the HR procedure.

Details about the LINE procedure are as follows:

  • Prototype

    HTP.LINE 
    (
        clear       IN      VARCHAR2    DEFAULT NULL,
        src         IN      VARCHAR2    DEFAULT NULL,
        attributes  IN      VARCHAR2    DEFAULT NULL
    )
  • Parameter

    ParameterDescription
    clearCLEAR attribute value.
    srcSRC attribute value that specifies a background image file for the horizontal line.
    attributesOther attribute-value pairs.
  • Example

    BEGIN
        HTP.LINE(src => '"/img/tibero.jpg"',
                 attributes => 'size="10" noshade style="color:gray;"');
    END;

    This example generates the following HTML code.

    <HR src="/img/tibero.jpg" size="10" noshade style="color:gray;">

50.3.22. PRINT

Appends input string and a newline character to the current HTML source code. This represents a new line in the HTML source code. To add a new line to the actual web page, the <br> tag must be used.

Details about the PRINT procedure are as follows:

  • Prototype

    HTP.PRINT 
    (
        str       IN       VARCHAR2        DEFAULT NULL
    )
  • Parameter

    ParameterDescription
    strText to append to the HTML source code.
  • Example

    BEGIN
        HTP.PRINT('<html>');
        HTP.PRINT('<head>');
        HTP.PRINT('</head>');
        HTP.PRINT('<body>');
        HTP.PRINT('He');
        HTP.PRINT('llo');  
        HTP.PRINT('</body>');
        HTP.PRINT('</html>');    
    END;

    This example generates the following HTML code.

    <html>
    <head>
    </head>
    <body>
    He
    llo
    </body>
    </html>

50.3.23. PRN

Appends input string to the current HTML source code. Unlike the PRINT procedure, a newline character is not appended.

Details about the PRN procedure are as follows:

  • Prototype

    HTP.PRN 
    (
        str       IN       VARCHAR2     DEFAULT NULL
    )
  • Parameter

    ParameterDescription
    strString to append to the HTML source code.
  • Example

    BEGIN
        HTP.PRN('<html>');
        HTP.PRN('<head>');
        HTP.PRN('</head>');
        HTP.PRN('<body>');
        HTP.PRN('He');
        HTP.PRN('llo');  -- Added just after 'He' to make 'Hello' 
        in the generated HTML source code.
        HTP.PRN('</html>');    
    END;

    This example generates the following HTML code.

    <html><head></head><body>Hello</body></html>

50.3.24. TITLE

Generates the <TITLE> tag, a title text, and the </TITLE> tag. The <TITLE> tag specifies the text to displayed in the title header of the web browser.

Details about the TITLE procedure are as follows:

  • Prototype

    HTP.TITLE 
    (
        title      IN       VARCHAR2
    )
  • Parameter

    ParameterDescription
    titleTitle text
  • Example

    BEGIN
        HTP.TITLE('Tibero');
    END;

    This example generates the following HTML code.

    <TITLE>Tibero</TITLE>