Server-Side Includes
All the servlets you’ve seen so far generate full HTML pages. If this were all that servlets could do, it would still be plenty. Servlets, however, can also be embedded inside HTML pages with something called server-side include (SSI) functionality.
In many servers that support servlets, a page can be preprocessed by the server to include output from servlets at certain points inside the page. The tags used for a server-side include look similar to those used for applets:[6]
<SERVLET CODE=ServletNameCODEBASE=http://server:port/dirinitParam1=initValue1initParam2=initValue2> <PARAM NAME=param1VALUE=value1> <PARAM NAME=param2VALUE=value2> If you see this text, it means that the web server providing this page does not support the SERVLET tag. </SERVLET>
The CODE attribute specifies the class name or
registered name of the servlet to invoke. The
CODEBASE
attribute is optional. It can refer
to a remote location from which the servlet should be loaded. Without
a CODEBASE attribute, the servlet is assumed to be
local.
Any number of parameters may be passed to the servlet using the
PARAM tag. The servlet can retrieve the
parameter values using the getParameter() method of
ServletRequest. Any number of initialization (init)
parameters may also be passed to the servlet appended to the end of
the SERVLET tag. We’ll cover init
parameters in Chapter 3.
A server that supports SSI detects the
SERVLET tag in the process of returning the page and substitutes in ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access