NOTE: Servlet API version 2.2.1 is fully backward compatible with version 2.1, so all existing servlets will continue to work without modification or recompilation.To develop servlets, use Sun Microsystems' Java Servlet API. For information about using the Java Servlet API, see the documentation provided by Sun Microsystems at:
http://java.sun.com/products/servlet/index.htmliPlanet Web Server 4.1 includes all the files necessary for developing Java Servlets. The
servlets.jar
file is in the iPlanet Web Server 4.1 installation directory at:
server_root
/bin/https/jar
When compiling servlets, make sure the servlets.jar
file is accessible to your Java compiler. Include the servlets.jar
file in your CLASSPATH.
iPlanet Web Server 4.1 supports the <SERVLET>
tag as introduced 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 <SERVLET>
tag is enabled.
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 the servlets.properties
file, see Appendix C, "Properties Files." For more information about SSI commands, see the Programmer's Guide for iPlanet Web Server.
NOTE: JSP API version 1.x is not backward compatible with JSP API version 0.92. To run version 0.92 JSPs, you must create legacy directories for them as described in the section "Running 0.92 JSP."A JSP is a page, much like an HTML page, that can be viewed in a web browser. However, as well as containing HTML tags, it can include a set of JSP tags that extend the ability of the web page designer to incorporate dynamic content in a page. These tags provide functionality such as displaying property values and using simple conditionals. One of the main benefits of JSPs is that, like HTML pages, they do not need to be compiled. The web page designer simply writes a page that uses HTML and JSP tags and puts it on their web server. The web page designer does not need to learn how to define Java classes or use Java compilers. JSP pages can access full Java functionality in the following ways:
http://java.sun.com/products/jsp/index.htmlFor information about Java Beans, see Sun Microsystem's JavaBeans web page at:
http://java.sun.com/beans/index.html
Table 1.1 Supported JRE/JDK Versions by Platform
Platform | JRE/JDK Version |
---|---|
NOTE: On Sun Solaris, the JRE included is the JRE 1.2.2 reference implementation from JavaSoft. For better performance, use the latest SunSoft production release of JDK.JDK 1.2 (and other JDK versions) are available from Sun Microsystems at:
http://java.sun.com/products/jdk/1.2/You can specify the path to the JDK in either of the following ways:
.jsp
extension as JSPs. (Do not put JSP files in a registered servlet directory, since the iPlanet Web Server expects all files in a registered servlet directory to be servlets.) An exception is a JSP page written to the 0.92 spec, which must be placed in a legacy directory; see the section "Running 0.92 JSP" for details.
In detail, to enable the iPlanet Web Server to serve servlets and JSP pages, do the following steps:
obj.conf
. These directives first load the shared library containing the servlet engine, which is in server_root
/bin/https/bin/NSServletPlugin.dll
on Windows NT or server_root
/bin/https/lib/libNSServletPlugin.so
on Unix. Then they initialize the servlet engine.
Init fn="load-modules" shlib="server_root
/bin/https/bin/NSServletPlugin.dll" funcs="NSServletEarlyInit,NSServletLateInit,NSServletNameTrans,NSServletService" shlib_flags="(global|now)"
Init fn="NSServletEarlyInit" EarlyInit="yes"
Init fn="NSServletLateInit" LateInit="yes"In the default object in
obj.conf
, add the following NameTrans
directive:
NameTrans fn="NSServletNameTrans" name="servlet"By default, regardless of whether servlets are enabled or disabled, the file
obj.conf
contains additional objects with names such as servlet
, jsp
, and ServletByExt
. Do not delete these objects. If you delete them, you can no longer activate servlets through the Server Manager.
A JSP page written to the 0.92 spec must be placed in a legacy directory; see the section "Running 0.92 JSP" for details.
servlets.properties
in the server's config
directory.
The following code shows an example of the settings in servlets.properties
:
# General properties:
servlets.startup=hello
servlets.config.reloadInterval=5
servlets.config.docRoot=C:/Netscape/Server4/docs
servlets.sessionmgr=com.netscape.server.http.session.SimpleSessionManager
server_root
/docs/servlet/
.
For example, if the SimpleServlet.class
servlet is in the servlet
subdirectory of the server's document root directory (the default servlet directory), you can invoke the servlet by pointing the web browser to:
The iPlanet Web Server expects all files in a registered servlet directory to be servlets. The server treats any files in that directory that have thehttp://
your_server
/servlet/SimpleServlet
.class
extension as servlets. The iPlanet Web Server does not correctly serve other files, such as HTML files or JSPs, that reside in that directory.
The server can have multiple servlet directories. You can map servlet directories to virtual directories if desired. For example, you could specify that http://poppy.my_domain.com/products/
invokes servlets in the directory server_root
/docs/january/products/servlets/
.
To register servlet directories and to specify their URL prefixes, use the Servlets>Servlet Directory page in the interface.
Alternatively, you can register servlet directories by adding appropriate NameTrans
directives to the default object in the file obj.conf
, such as:
NameTrans fn="pfx2dir" from="/products" dir="d:/netscape/server4/docs/january/products/servlets/" name="ServletByExt"You can invoke a servlet in a subdirectory of a registered servlet directory if you include a package directive in the servlet code that corresponds to the path from the registered servlet directory. For example, suppose the servlet is in the following location, and that
server_root
/docs/servlet/
is a registered servlet directory:
Include the following package directive as the first line in the Java source file:server_root
/docs/servlet/HelloWorld/HelloWorldServlet.class
package HelloWorld;You can then invoke the servlet by pointing the web browser to:
http://
your_server
/servlet/HelloWorld.HelloWorldServlet
.jar
file. The server does not search .class
or .jar
files for packaged servlets.servlets.properties
to add an entry for the servlet.
When registering an individual servlet, specify the following attributes:
.class
extension..jar
or .zip
file, or a URL to a directory. (You cannot specify a URL as a classpath for a zip or jar file.) buynow1A
resides in the directory D:/Netscape/server4/docs/servlet/buy
. This servlet is configured under the name BuyNowServlet
. It takes additional arguments of arg1=45
, arg2=online
, arg3="quick shopping"
.
Figure 1.1 Configuring attributes for an individual servlet
The following code shows an example of the configuration information for the same servlet inservlets.properties
:
servlet.BuyNowServlet.classpath=D:/Netscape/server4/docs/servlet/buy;D:/Netscape/server4/docs/myclassesNote that you can specify multiple values as the servlet classpath if needed.
servlet.BuyNowServlet.code=BuyNow1A
servlet.BuyNowServlet.initArgs=arg1=45,arg2=online,arg3="quick shopping"
http://poppy.my_domain.com/plans/plan1
invokes the servlet defined in the directory
You can set up servlet virtual paths for servlets that reside anywhere in the file system, in or out of a registered servlet directory. To specify a servlet virtual path, use the Servlets>Configure Servlet Virtual Path Translation page in the Server Manager interface. In this page, specify the virtual path name and the servlet name. You can alternatively manually edit theserver_root
/docs/plans/releaseA/planP2Version1A.class
rules.properties
configuration file to add a servlet virtual path. Only servlets for which a virtual path has been set up can use initial arguments (See "GenericServlet.getInitParameter and getInitParameterNames" for information about initial arguments.)
Before using a servlet virtual path, a servlet identifier (or servlet name) must be added for the servlet in the Servlets>Configure Servlet Attributes page of the interface (or in the servlets.properties
configuration file).
http://poppy.my_domain.com/plans/plan1invokes the servlet defined in
server_root
/docs/plans/releaseA/planP2Version1A.class.
1. Specify the servlet identifier, class file, and class path.
In the Servlets>Configure Servlet Attributes page in the interface, do the following:
plan1A
. (Notice that this is not necessarily the same as the class file name).planP2Version1A
. Don't specify any directories. The .class
extension is not required.server_root
/docs/servlet/plans/releaseA
. (For example: D:/netscape/server4/docs/servlet/plans/releaseA
.)Figure 1.2 Specifying the servlet name, code, and class path
To make this change programmatically, add the following lines to the configuration fileservlets.properties
:
servlet.plan1A.classpath=D:/Netscape/server4/docs/servlet/plans/releaseA/
servlet.plan1A.code=planP2Version1A2. Specify the virtual path for the servlet. In the Servlets>Configure Servlet Virtual Path Translations page, do the following:
/plans/plan1
to specify the virtual path http://poppy.mcom.com/plans/plan1
.plan1A
. Figure 1.3 Adding a virtual path
To do this programmatically, add the following line torules.properties
:
/plans/plan1=plan1AAfter this virtual servlet path has been established, if a client sends a request to the server for the
URL http://poppy.my_domain.com/plans/plan1
, the server sends back the results of invoking the servlet in server_root
/docs/servlet/plans/releaseA/plan2PVersion1A.class
.
servlets.properties
and contexts.properties
files. For more information, see Appendix C, "Properties Files."
http://java.sun.com/products/jdk/1.2/iPlanet Web Server 4.1 requires you to use version of the JDK listed in the section "What Does the Server Need to Run Servlets and JSP?" Regardless of whether you choose to install the JRE or specify a path to the JDK during installation, you can tell the iPlanet Web Server to switch to using either the JRE or JDK at any time. Switch to the Web Server Administration Server, select the Global Settings tab, and use the Configure JRE/JDK Paths page. You can also change the path to the JDK in this page. On the Configure JRE/JDK Paths page, supply values for the following fields if you select the JDK radio button:
NOTE: If you are not sure of the JDK runtime libpath, the JDK runtime classpath, or the JRE runtime libpath, leave these fields blank to tell the server to use the default paths.It is easiest to use the Configure JRE/JDK Paths page to switch between the JRE and the JDK, but you can also make the change programmatically, as follows:
server_root
/https-admserv/start-jvm
.
If the server is currently using the JRE, this file has a variable NSES_JRE.
To enable the server to use a JDK, add the variable NSES_JDK
whose value is the JDK directory. You'll also need to change the value of the NSES_JRE
variable.
NSES_JDK
should point to the installation directory for the JDK, while NSES_JRE
should point to the JRE directory in the installation directory for JDK (that is, jdk_dir
/jre
).extrapath
setting in magnus.conf
.
Edit the NSES_JDK
and NSES_JRE
variables in the registry HKEY_LOCAL_MACHINE/SOFTWARE/Netscape/Enterprise/4.0/
. If the server is enabled to use the JDK, both these variables are needed. If the server is to use the JRE, only the NSES_JRE
variable should be set.
NSES_JDK
should point to the installation directory for the JDK, while NSES_JRE
should point to the JRE directory in the installation directory for JDK (that is, jdk_dir
/jre
).NOTE: To activate changes to the JRE/JDK paths, you must restart the server from the On/Off option on the Preferences tab.
.java
and a .class
file associated with the JSP and stores them in the JSP class cache under the ClassCache
directory.MMapSessionManager
session manager, it stores persistent session information in the SessionData
directory. (For more information about session managers, see Appendix A, "Session Managers.")version
file containing a version number that the server uses to determine the structure of the directories and files in the caches. You can clean out the caches by simply deleting the version file.
When the server starts up, if it does not find the version files, it deletes the directory structures for the corresponding caches and re-creates the version files. Next time the server serves a JSP page, it recreates the JSP class cache. The next time the server serves a JSP page or servlet while using MMapSessionManager
session manager, it recreates the session data cache.
If a future upgrade of the server uses a different format for the caches, the server will check the number in the version file and clean up the caches if the version number is not correct.
You can delete the version files simply by deleting them from the ClassCache
or SessionData
directories as you would normally delete a file, or you can use the Servlets>Delete Version Files page in the Server Manager to delete them. After deleting one or both version files, be sure to restart the iPlanet Web Server to force it to clean up the appropriate caches and to recreate the version files before the server serves any servlets or JSPs.
jvm12.conf
.
The default settings in iPlanet Web Server for JVM are suitable for running servlets. However, there may be times when you want to change the settings. For example, if a servlet or bean file uses a JAR file, add the JAR location to the Classpath variable. To enable the use of a remote profiler, set the OPTITDIR and Profiler variables.
NOTE: A few attributes on the Configure JVM Attributes page on the Servlets tab show as "Default." Since you can use different JVMs, these default values are unknown. You cannot query a JVM to find out the actual default values; instead, refer to your JVM documentation. For example, for Sun's JVM, if you choose Yes for the JIT Compiler option, it shows as "Default" because JIT is enabled in the JVM by default. However, if you choose No for the JIT compiler, an explicit entry,The JVM parameters you can set are:jvm.compiler=NONE
, is added to thejvm12.conf
file.
The classpath must not include backslashes in directory names. If you use
backslashes in the directory path when using the Web Server Administrative
Server interface, the system automatically converts the backslashes to
forward slashes. However, if you edit the jvm12.conf
file, do not use
backslashes in directory names.
obj.conf
file manually, make sure that the servlet NameTrans
(NameTrans fn="NSServletNameTrans" name="servlet"
) is always the first NameTrans
directive. This directive uses a highly optimized URI cache for loaded servlets and returnsREQ_PROCEED
if the match is found, thus eliminating the need of otherNameTrans
directives to be executed.
rules.properties
and servlets.properties
) are slightly faster than dynamically loaded servlets (in servlet directories). jvm12.conf
file has a configuration parameter, jvm.stickyAttach
. Setting the value of this parameter to 1 causes threads to remember that they are attached to the JVM, thus speeding up request processing by eliminating AttachCurrentThread
and DetachCurrentThread
calls. It can, however, have a side-effect: recycled threads which may be doing other processing can be suspended by the garbage collector arbitrarily. Thread pools can be used to eliminate this side effect for other subsystems. For more information about thread pools, see "Adding and Using Thread Pools" in Chapter 7, "Configuring Server Preferences," in the iPlanet Web Server Administrator's Guide.
magnus.conf
(via the StackSize
variable), or the respective pool stack size parameter if you're using thread pools. For more information, see the NSAPI Programmer's Guide for iPlanet Web Server.jvm.minHeapSize
or maxHeapSize
or the Configure JVM Attributes page. jvm.classpath
(if you don't need some of the examples). You can set jvm.include.CLASSPATH=1
, so it won't inherit the CLASSPATH
environment variable. You can set the stack space using theStackSize
parameter in themagnus.conf
file. For more information, see the NSAPI Programmer's Guide for iPlanet Web Server.
Init fn="nsapi-cache-init" enable=true
Last Updated: 02/25/00 16:19:08
© Copyright © 2000 Sun Microsystems, Inc. Some preexisting portions Copyright © 2000 Netscape Communications Corp. All rights reserved.
[an error occurred while processing this directive]