obj.conf
file (note that native threads are turned off):
Init funcs="shtml_init,shtml_send" shlib="install_dir
/bin/https/bin/Shtml.dll" NativeThread="no" fn="load-modules"
Note that you must set NativeThread="no"
for 4.1 iPlanet Web Servers. In addition, these functions now originate from Shtml.dll
(or libShtml.so
on Unix), which is located in install_dir
/bin/https/bin
for Windows NT (and install_dir
/bin/https/lib
for Unix).
parse-html
.
The server replaces each command with data determined by the command and its attributes.
The format for a command is:
<!--#The format for eachcommand
attribute1
attribute2
... -->
attribute
is a name-value pair such as:
Commands and attribute names should be in lower case. The commands are "hidden" within HTML comments so they are ignored if not parsed by the server. The standard server-side commands are:name
="
value
"
config
command initializes the format for other commands.
errmsg
attribute defines a message sent to the client when an error occurs while parsing the file. This error is also logged in the error log file.timefmt
attribute determines the format of the date for the flastmod
command. It uses the same format characters as the util_strftime
function. The default time format is: "%A, %d-%b-%y %T"
.<!--#config timefmt="%r %a %b %e, %Y" sizefmt="abbrev"-->This sets the date format to a value such as 08:23:15 AM Wed Apr 15, 1996, and the file size format to the number of KB or MB of characters used by the file.
include
command inserts a file into the parsed file. You can nest files by including another parsed file, which then includes another file, and so on. The client requesting the parsed document must also have access to the included file if your server uses access control for the directories where they reside.
In iPlanet Web Server 4.1, you can use the include
command with the virtual
attribute to include a CGI program file. You must also use an exec
command to execute the CGI program.
virtual
attribute is the URI of a file on the server.file
attribute is a relative path name from the current directory. It cannot contain elements such as ../
and it cannot be an absolute path.<!--#include file="bottle.gif"-->
echo
command inserts the value of an environment variable. The var
attribute specifies the environment variable to insert. If the variable is not found, "(none)" is inserted. For a list of environment variables, see the section "Environment Variables in Server-Side HTML Commands."
Example:
<!--#echo var="DATE_GMT"-->
fsize
command sends the size of a file. The attributes are the same as those for the include
command (virtual
and file
). The file size format is determined by the sizefmt
attribute in the config
command.
Example:
<!--#fsize file="bottle.gif"-->
flastmod
command prints the date a file was last modified. The attributes are the same as those for the include
command (virtual
and file
). The date format is determined by the timefmt
attribute in the config
command.
Example:
<!--#flastmod file="bottle.gif"-->
exec
command runs a shell command or CGI program.
cmd
attribute (Unix only) runs a command using /bin/sh
. You may include any special environment variables in the command.cgi
attribute runs a CGI program and includes its output in the parsed file.<!--#exec cgi="workit.pl"-->
/shtml/test.shtml
).<SERVLET>
tag as defined by Java Web Server. This tag allows you to embed servlet output in an HTML file. No configuration changes are necessary to enable this behavior. If SSI and servlets are both enabled, the server recognizes the <SERVLET>
tag.
The <SERVLET>
tag syntax is slightly different from that of other SSI commands; it resembles the <APPLET>
tag syntax:
<servlet name=name
code=classfile
codebase=path
iParam1
=v1
iParam2
=v2
>
<param name=param1
value=v3
>
<param name=param2
value=v4
>
.
.
</servlet>The
code
parameter, which specifies the .class
file for the servlet, is always required. The .class
extension is optional. The codebase
parameter is required if the servlet is not defined in the servlets.properties
file and the .class
file is not in the same directory as the HTML file containing the <SERVLET>
tag. The name
parameter is required if the servlet is defined in the servlets.properties
file, and must match the servlet name defined in that file.
For more information about creating servlets, see the Programmer's Guide to Servlets in iPlanet Web Server.
.shtml
files in iPlanet Web Server 4.1 has been substantially improved over previous releases of iPlanet Web Server. First, the performance of handling server-side tags has been significantly sped up. Secondly, users can now define their own server-side tags.
For example, you could define the tag <PRICE>
to invokes a function that calculates and displays the price of a product. Then in your .shtml
file you could have code such as:
<H2>Product Prices</H2>When the browser displays this code, each occurrence of the
<UL>
<LI>Oak Table: <PRICE product="oaktable">
<LI>Pine Bench: <PRICE product="pinebench">
<LI>Patio Chair: <PRICE product="patiochair">
</UL>
<PRICE>
tag calls the function that is associated with that tag, and returns the price of the relevant product. The result in the browser might look like this:
You must define the tag execution function, and you can optionally also define other functions that are called on tag loading and unloading and on page loading and unloading.
Write an initialization function that registers the tag using the
shtml_add_tag
function.
shtml_public.h
, which is in the directory install_dir
/plugins/include/shtml
. shtml
shared library. On Windows NT, shtml.dll
is in install_dir
/bin/https/bin.
On Unix platforms, libshtml.so
or .sl
is in install_dir
/bin/https/lib.
ShtmlTagExecuteFunc
is the actual tag handler. It gets called with the usual NSAPI pblock, Session, and Request variables. In addition, it also gets passed the TagUserData
created from the result of executing the tag loading and page loading functions (if defined) for that tag.
The signature for the tag execution function is:
typedef int (*ShtmlTagExecuteFunc)(pblock*, Session*, Request*, TagUserData, TagUserData);Write the body of the tag execution function to generate the output to replace the tag in the
.shtml
page. Do this in the usual NSAPI way, using the net_write
NSAPI function, which writes a specified number of bytes to a specified socket from a specified buffer.
For more information about writing NSAPI plugins, see Chapter 4, "Creating Custom SAFs," in the NSAPI Programmer's Guide for iPlanet Web Server.
For more information about net_write
and other NSAPI functions, see Chapter 5, "NSAPI Function Reference," of the NSAPI Programmer's Guide for iPlanet Web Server.
The tag execution function must return an int
that indicates whether the server should proceed to the next instruction in obj.conf
or not, which is one of:
REQ_PROCEED
-- the execution was successful.REQ_NOACTION
-- nothing happened.REQ_ABORTED
-- an error occurred. REQ_EXIT
-- the connection was lost.ShtmlTagExecuteFunc
whenever the execution function is called. ShtmlTagInstanceLoad
function. It gets passed the result that was originally returned from the ShtmlTagInstanceLoad
function.ShtmlTagPageLoadFunc
and hence gets passed the result returned from the ShtmlTagPageLoadFunc
. #define TagUserData void*
typedef TagUserData (*ShtmlTagInstanceLoad)(
const char* tag, pblock*, const char*, size_t);
typedef void (*ShtmlTagInstanceUnload)(TagUserData);
typedef int (*ShtmlTagExecuteFunc)(
pblock*, Session*, Request*, TagUserData, TagUserData);
typedef TagUserData (*ShtmlTagPageLoadFunc)(
pblock* pb, Session*, Request*);
typedef void (*ShtmlTagPageUnLoadFunc)(TagUserData);
shtml_add_tag
. The signature is:
NSAPI_PUBLIC int shtml_add_tag (Any of these arguments can be
const char* tag,
ShtmlTagInstanceLoad ctor,
ShtmlTagInstanceUnload dtor,
ShtmlTagExecuteFunc execFn,
ShtmlTagPageLoadFunc pageLoadFn,
ShtmlTagPageUnLoadFunc pageUnLoadFn);
NULL
except for the tag
and execFn
.
obj.conf
:
Init
directive whose fn
parameter is load-modules
and whose shlib
parameter is the shared library to load. Init
directive whose fn
parameter is the initialization function in the shared library that uses shtml_add_tag
to register the tag.Last Updated: 03/01/00 09:14:04
© Copyright © 2000 Sun Microsystems, Inc. Some preexisting portions Copyright © 2000 Netscape Communications Corp. All rights reserved.
[an error occurred while processing this directive]