Netscape ENTERPRISE SERVER 6.1 - PROGRAMMER GUIDE TO SERVLETS Programmer's Manual

Guide to servlets
Table of Contents

Advertisement

Quick Links

Programmer's Guide to Servlets
Netscape Enterprise Server
Version 6.1
April 2002 (Draft)

Advertisement

Table of Contents
loading

Summary of Contents for Netscape NETSCAPE ENTERPRISE SERVER 6.1 - PROGRAMMER GUIDE TO SERVLETS

  • Page 1 Programmer’s Guide to Servlets Netscape Enterprise Server Version 6.1 April 2002 (Draft)
  • Page 2 Netscape Communications Corporation ("Netscape") and its licensors retain all ownership rights to the software programs offered by Netscape (referred to herein as "Software") and related documentation. Use of the Software and related documentation is governed by the license agreement for the Software and applicable copyright law. Your right to copy this documentation is limited by copyright law.
  • Page 3: Table Of Contents

    Contents About This Book ..............7 Where to Find Related Information .
  • Page 4 response-cookie ..............26 role-mapping .
  • Page 5 Specifying a Session Manager ............56 NESSessionManager .
  • Page 6 Legacy Examples ............... 96 Maximizing Legacy Servlet Performance .
  • Page 7: About This Book

    About This Book This book discusses how to enable and install Java™ servlets and JavaServer Pages™ (JSP) in Netscape® Enterprise Server 6.1. This book has the following chapters and appendices: • Chapter 1, “Servlets and JavaServer Pages” This chapter introduces web applications, servlets, and JavaServer Pages. •...
  • Page 8: Where To Find Related Information

    Where to Find Related Information • Chapter 7, “API Clarifications” This chapter discusses methods in the Servlets API that behave marginally differently in Enterprise Server than specified in the Sun Microsystems’ Servlets API documentation or where the behavior documented by Sun Microsystems is ambiguous.
  • Page 9 Where to Find Related Information • Netscape Enterprise Server NSAPI Programmer’s Guide • Netscape Enterprise Server Release Notes You can find Enterprise Server documentation online in PDF and HTML formats http://enterprise.netscape.com/docs About This Book...
  • Page 10 Where to Find Related Information Netscape Enterprise Server Programmer’s Guide to Servlets • April 2002 (Draft)
  • Page 11: Chapter 1 Servlets And Javaserver

    Chapter 1 Servlets and JavaServer Pages Netscape Enterprise Server 6.1 supports servlets and JavaServer Pages (JSPs). This chapter gives a brief overview of servlets and JSPs in Enterprise Server 6.1. The sections in this chapter are: • Web Applications • Servlets •...
  • Page 12: Servlets

    Servlets Servlets Java servlets are server-side Java programs that web servers can run to generate content in response to a client request in much the same way as CGI programs do. Servlets can be thought of as applets that run on the server side without a user interface.
  • Page 13 JavaServer Pages JSP pages can access full Java functionality in the following ways: • by embedding Java code directly in scriptlets in the page • by accessing Java beans • by using server-side tags that include Java servlets Both beans and servlets are Java classes that need to be compiled, but they can be defined and compiled by a Java programmer, who then publishes the interface to the bean or the servlet.
  • Page 14 JavaServer Pages Netscape Enterprise Server Programmer’s Guide to Servlets • April 2002 (Draft)
  • Page 15: Chapter 2 Web Applications

    Chapter 2 Web Applications Netscape Enterprise Server 6.1 supports the Servlet 2.3 API specification, which allows servlets and JSPs to be included in web applications. A web application is a collection of servlets, JavaServer Pages, HTML documents, and other web resources which might include image files, compressed archives, and other data.
  • Page 16: Dynamic Reconfiguration

    Dynamic Reconfiguration A special directory under the document root, , contains everything related WEB-INF to the application that is not in the public document tree of the application. No file contained in can be served directly to the client. The contents of WEB-INF WEB-INF include:...
  • Page 17: Web.xml Clarifications

    web.xml Clarifications For more information about dynamic reconfiguration, see Chapter 1, “Basics of Server Operation” in the Netscape Enterprise Server NSAPI Programmer’s Guide. If you add or remove a web application, servlet, or JSP, you must restart the server. web.xml Clarifications This section provides clarifications for using the file with Enterprise web.xml...
  • Page 18: The Web-Apps.xml File And Virtual Servers

    The web-apps.xml File and Virtual Servers The web-apps.xml File and Virtual Servers file defines contexts for a set of web applications running in a web-apps.xml virtual server. The context information includes a context path of the web application and other properties such as how it handles session management or authentication.
  • Page 19 The web-apps.xml File and Virtual Servers The path to the web-apps.xml file for a virtual server. webapps_file The following file uses these variables: server.xml <?xml version="1.0" encoding="UTF-8"?> <!-- declare any variables to be used in the obj.conf file in the ATTLIST below -->...
  • Page 20: Example Web-Apps.xml File

    The web-apps.xml File and Virtual Servers Example web-apps.xml File Note that the declaration must be present and of the following format: !DOCTYPE <!DOCTYPE vs PUBLIC "-//Netscape Communications Corp.;Netscape//DTD Virtual Server Web Applications 6.1//EN" "http://developer.netscape.com/products/servers/enterprise/dtds/nes -webapps_6_1.dtd"> If for some reason if this URL is not accessible, the DTD file is located here: "file:/server_root/bin/https/dtds/nes-webapps_6_1.dtd"...
  • Page 21: Web-Apps.xml Element Reference

    The web-apps.xml File and Virtual Servers <param-name>session-data-dir</param-name> <param-value>/net/example.com/sessions</param-value> </init-param> </session-manager> <session-tracking use-cookies="true" /> <!-- Define the web applications for this virtual server--> <!-- catalog application --> <web-app uri="/catalog" dir="/webapps/catalog"> <!-- Specify a tempory directory. A path returned in the "javax.servlet.context.tempdir" property; -- defaults to WEB-INF/tmp.
  • Page 22: Class-Loader

    The web-apps.xml File and Virtual Servers class-loader The class loader for the virtual server or the web application. There is a default class loader for the virtual server if you don’t specify one. Classes loaded by the virtual-server-level class loader are not dynamically reloaded. You can use the method to retrieve the class ServletContext.getAttribute...
  • Page 23: Init-Param

    The web-apps.xml File and Virtual Servers init-param Specifies an initialization parameter for the containing element. The attributes of depend on the object referenced by the containing element. init-param For example, if the containing element is and the session session-manager manager is , the attributes of are the initialization NESSessionManager...
  • Page 24: Param-Name

    The web-apps.xml File and Virtual Servers param-name The name of a parameter. Used within an element. init-param Subelements: none Attributes: none param-value The value of a parameter. Used within an element. init-param Subelements: none Attributes: none parameter-encoding Advises the web server on how to decode parameters from forms. Subelements: none Attributes: Allowed values are auto (the default), none, or a specific encoding...
  • Page 25 The web-apps.xml File and Virtual Servers (Default) Tries to figure out the proper encoding auto from, in order, 1) the charset if it is set in the Content-Type header, 2) the parameterEncoding attribute (see “ServletRequest.setAttribute,” on page 75 then 3) a hidden form field defined in form-hint-field.
  • Page 26: Response-Buffer

    The web-apps.xml File and Virtual Servers response-buffer Configures the initial and default size of the HTTP servlet’s response buffer. A servlet can reconfigure its response buffer size using the method of setBufferSize object. ServletResponse Subelements: none Attributes: Forces the stream to flush the data if the specified number of flush-timeout seconds has elapsed since the last flush.
  • Page 27: Session-Cookie

    The web-apps.xml File and Virtual Servers session-cookie Sets parameters for the session cookie. Subelements: none Attributes: If this attribute is present, its value is tagged onto the cookie. domain There is no default value. If set to true, the server sends the secure attribute in the is-secure session cookie if the request came in a secure connection.
  • Page 28: Tempdir

    The web-apps.xml File and Virtual Servers tempdir A temporary directory used by the web application. Subelements: none Attributes: The temporary directory. The top-level element in the file. Subelements other than web-apps.xml web-app set defaults for all web applications. Subelements: auth-native class-loader form-login-session jsp-servlet...
  • Page 29: Deploying A Web Application Using Wdeploy

    Deploying a Web Application using wdeploy Deploying a Web Application using wdeploy Before you can deploy a web application manually, you must make sure that the server_root directory is in your path and that the /bin/https/httpsadmin/bin environment variable is set to your server_root directory. NES_SERVER_HOME You can use the utility at the command line to deploy a WAR file into a...
  • Page 30 Deploying a Web Application using wdeploy When you execute the command, two things happen: wdeploy deploy • A web application with the given gets added to the uri_path directory file. web-apps.xml • The .WAR file gets extracted at the target directory For example: wdeploy deploy -u /hello -i server.netscape.com -v example.com...
  • Page 31: Web Application Examples

    Web Application Examples uri_path The same one you used to deploy the application. This is also the context path. index_page (optional) The page in the application that end users are meant to access first. For example: http://example.com:80/hello/index.jsp http://example.com/hello/ Web Application Examples Enterprise Server 6.1 comes with a set of example web applications.
  • Page 32 Web Application Examples Netscape Enterprise Server Programmer’s Guide to Servlets • April 2002 (Draft)
  • Page 33: Chapter 3 Using Servlets

    Chapter 3 Using Servlets This chapter discusses how to enable and configure servlets in Netscape Enterprise Server 6.1. The sections in this chapter are: • What Does the Server Need to Run Servlets? • Using the User Interface • Enabling Servlets •...
  • Page 34: Using The User Interface

    Using the User Interface Using the User Interface For information about using the user interface to specify settings for servlets, see the following topics in the online help. This page is located in the Enterprise Server Administration Server on the Global Settings tab.
  • Page 35: The Shtml Tag

    The <SERVLET> SHTML Tag The <SERVLET> SHTML Tag Enterprise Server 6.1 supports the tag as introduced by Java Web <SERVLET> Server. This tag allows you to embed servlet output in an SHTML file. No configuration changes are necessary to enable this behavior. If SSI and servlets are both enabled, the tag is enabled.
  • Page 36: Servlet Output

    Servlet Output You would also need to include the following in your file: web.xml <servlet> <servlet-name> pparams </servlet-name> <servlet-class> PrintPackage.PrintParams </servlet-class> </servlet> <servlet-mapping> <servlet-name> pparams </servlet-name> <url-pattern> /PrintParams </url-pattern> </servlet-mapping> You must also include any servlet initialization parameters in the file.
  • Page 37: Configuring Jvm

    Configuring JVM Configuring JVM If necessary, you can configure parameters for JVM either by using the Java>Configure JVM Attributes page in the Server Manager interface, or by editing . For more information about JVM settings, see Appendix C, “JVM jvm12.conf Configuration.”...
  • Page 38 Maximizing Servlet Performance You can set the stack space using the directive in the StackSize magnus.conf file. For more information, see the Netscape Enterprise Server NSAPI Programmer’s Guide. • The session ID generator, which is used for servlet sessions, employs cryptographically strong unique random number generation algorithms.
  • Page 39: Chapter 4 Using Javaserver

    Chapter 4 Using JavaServer Pages This chapter discusses how to enable and configure JavaServer Pages (JSPs) in Netscape Enterprise Server 6.1. The sections in this chapter are: • What Does the Server Need to Run JSP? • Configuring JRE/JDK Paths •...
  • Page 40 Java version 1.4.0_00 Classic VM NT 4.0 Windows Java version 1.4.0_00 Classic VM 2000 RedHat® Java version 1.4.0_00 Classic VM Linux 6.2 Check the Netscape Enterprise Server Installation and Migration Guide and the latest release notes for updates on required JDK versions.
  • Page 41: Configuring Jre/Jdk Paths

    Configuring JRE/JDK Paths You can specify the path to the JDK in either of the following ways: • You can specify the path during the server installation process. When you install Enterprise Server 6.1, one of the dialog boxes in the installation process asks if you want to use a custom Java Development Kit (JDK), and if so, you can specify the path to it.
  • Page 42 Configuring JRE/JDK Paths • JDK Runtime Libpath Enter the runtime library path for the JDK. • JDK Runtime Classpath The class path includes the paths to the directories and jar files needed to run the servlet engine, the servlet examples, and any other paths needed by servlets that you add.
  • Page 43: Using The User Interface

    Using the User Interface • On Windows NT/Windows 2000: Add the path to the Java libraries to the setting in extrapath magnus.conf Edit the variables in the registry NSES_JDK NSES_JRE . If the server is HKEY_LOCAL_MACHINE/SOFTWARE/Netscape/Enterprise/6.1/ enabled to use the JDK, both these variables are needed. If the server is to use the JRE, only the variable should be set.
  • Page 44: Enabling Jsps

    Enabling JSPs • The Java Web Apps Settings Page Enabling JSPs To enable JSPs, follow these steps: Enable servlets. Select the Java tab in the Server manager, then select the Enable/Disable Servlets/JSP tab. Check the Enable Java Globally box to enable servlets for the entire server.
  • Page 45: The Jsp Command-Line Compiler

    The JSP Command-Line Compiler When the server serves a JSP page, it creates a and a file associated .java .class with the JSP and stores them in the JSP class cache under the directory. ClassCache The cache has a file containing a version number that the server uses to Version determine the structure of the directories and files in the caches.
  • Page 46 The JSP Command-Line Compiler for the command are: options jspc Enables quiet mode (same as -v0). Only fatal error messages are displayed. Enables verbose mode. The level is optional; the default is 2. -v[level] Possible level values are: • 0 - fatal error messages only •...
  • Page 47 The JSP Command-Line Compiler -uriroot dir Specifies the root directory against which URI files are resolved. Applies only to explicitly declared JSP files. If this option is not specified, all parent directories of the first JSP page are searched for a WEB-INF subdirectory. The closest directory to the JSP page that has one is used.
  • Page 48: Package Names Generated By The Jsp Compiler

    The JSP Command-Line Compiler Package Names Generated by the JSP Compiler When a JSP is compiled, a package is created for it. The package name starts with and has each pathname component of the JSP prefixed with an underscore. _jsps For example, the generated package name for /myjsps/hello.jsp _jsps._myjsps...
  • Page 49: Other Jsp Initialization Parameters

    JSP Tag Libraries and Standard Portable Tags Other JSP Initialization Parameters You can include the following initialization parameters under the jsp-servlet element in your file. The JSP compiler uses the default values for web-apps.xml parameters that are not included in the file. If set to true (the default), keeps the generated Java files.
  • Page 50 JSP Tag Libraries and Standard Portable Tags Netscape Enterprise Server Programmer’s Guide to Servlets • April 2002 (Draft)
  • Page 51: Chapter 5 Debugging Servlets And Jsps

    Chapter 5 Debugging Servlets and JSPs This chapter gives guidelines for debugging servlets and JSPs in Netscape Enterprise Server 6.1. It includes the following sections: • Servlet Debugging • JSP Debugging • Generating a Stack Trace for Debugging • JPDA Options for Debugging Debugging servlets and JSPs requires that you edit the file as described jvm12.conf...
  • Page 52: Jsp Debugging

    JSP Debugging Set the following parameters in as appropriate: jvm12.conf jvm.enableDebug=1 java.compiler=NONE To send exceptions to the client in addition to the log file, set the following parameter. If the client is a browser, exceptions are displayed in the browser. jvm.trace=7 On some platforms, you may be required to specify the bootclasspath.
  • Page 53: Generating A Stack Trace For Debugging

    Generating a Stack Trace for Debugging To send exceptions to the client in addition to the log file, set the following parameter. If the client is a browser, exceptions are displayed in the browser. jvm.trace=7 Setting includes line numbers of the Java source code in the java.compiler=NONE verbose output of the log files.
  • Page 54: Jpda Options For Debugging

    JPDA Options for Debugging JPDA Options for Debugging A list of debugging options that you can include in the file if the JPDA jvm12.conf is installed is available here: http://java.sun.com/products/jpda/doc/conninv.html#Invocation Netscape Enterprise Server Programmer’s Guide to Servlets • April 2002 (Draft)
  • Page 55: Chapter 6 Session Managers

    Chapter 6 Session Managers Session objects maintain state and user identity across multiple page requests over the normally stateless HTTP protocol. A session persists for a specified time period, across more than one connection or page request from the user. A session usually corresponds to one user, who may visit a site many times.
  • Page 56: Specifying A Session Manager

    Specifying a Session Manager Netscape Enterprise Server 6.1 comes with these session managers for creating and managing sessions: • -- the default session manager, which can use a database NESSessionManager or a file store for persistent sessions, and can run in single-process or multi-process mode.
  • Page 57 Specifying a Session Manager <init-param> <param-name>reapInterval</param-name> <param-value>600</param-value> </init-param> </session-manager> For more information about the file, see Chapter 2, “Web web-apps.xml Applications.” • Use the Legacy Servlets>Configure Global Servlet Attributes page in the Server Manager interface. In the Session Manager field, specify the session manager, and, if appropriate, specify parameters for the session manager in the Session Manager Args field.
  • Page 58: Nessessionmanager

    NESSessionManager NESSessionManager is the default session manager. NESSessionManager works in both single process and multi-process mode. It can NESSessionManager be used for sharing session information across multiple processes possibly running on different machines. The directive in the file determines MaxProcs magnus.conf whether the server is running in single process mode or multi-process mode.
  • Page 59 NESSessionManager • - the number of cross-process locks to use for synchronizing access maxLocks to individual sessions across processes. The default value is 10. This default value is used if the value 0 is specified. This parameter is ignored in single-process mode.
  • Page 60 NESSessionManager If the parameter is set to the class, session-data-store JdbcStore takes the following additional parameters: NESSessionManager • - the JDBC driver (the default is provider sun.jdbc.odbc.JdbcOdbcDriver For more information about the JDBC API, see the following web site: http://java.sun.com/products/jdbc/index.html NOTE class does not recognize JDBC driver classes JdbcStore...
  • Page 61: Enabling Nessessionmanager

    NESSessionManager Each type of operation on the database that handles session information (looking up, inserting, updating, and deleting) is performed by a corresponding dedicated connection. Each of these connections has a precompiled SQL statement for higher performance. The following parameters allow you to customize the number of dedicated connections that perform each of the operations.
  • Page 62: Source Code For Nessessionmanager

    NESSessionManager session-data-dir <param-name> </param-name> /net/example.com/session <param-value> s</param-value> </init-param> </session-manager> For more information about the file, see Chapter 2, “Web web-apps.xml Applications.” • Use the Legacy Servlets>Configure Global Servlet Attributes page in the Server Manager interface. In the Session Manager field specify: netscape com.
  • Page 63: Mmapsessionmanager (Unix Only)

    MMapSessionManager (UNIX Only) MMapSessionManager (UNIX Only) This is a persistent memory map (mmap) file based session manager that works in both single process and multi-process mode. directive in the file determines whether the server is MaxProcs magnus.conf running in single process mode or multi-process mode. For more information, see the Netscape Enterprise Server NSAPI Programmer’s Guide.
  • Page 64: Enabling Mmapsessionmanager

    MMapSessionManager (UNIX Only) Enabling MMapSessionManager You may want to enable to change its default parameters. MMapSessionManager You can also enable for a particular context if the server is MMapSessionManager running in single process mode. To enable Enterprise Server to use , do any of the following: MMapSessionManager •...
  • Page 65: Deleting Sessiondata Version Files

    Deprecated Session Managers Deleting SessionData Version Files If the server uses the session manager, it stores persistent MMapSessionManager session information in the directory. This cache has a file SessionData Version containing a version number that the server uses to determine the structure of the directories and files in the caches.
  • Page 66 Deprecated Session Managers Parameters class takes the following parameters: SimpleSessionManager • - the maximum number of sessions maintained by the session maxSessions manager at any given time. The session manager refuses to create any more new sessions if there are already number of sessions present at maxSessions that time.
  • Page 67: Jdbcsessionmanager

    Deprecated Session Managers • Edit the file in the directory server_id . This will contexts.properties /config apply to the default virtual server only. Add a line specifying a value for context_name and a context. .sessionmgr line specifying the parameters for the session manager: context.global.sessionmgr=com.netscape.server.http.session.SimpleSe ssionManager context.global.sessionmgr.initArgs=maxSessions=20,timeOut=300,reapI...
  • Page 68 Deprecated Session Managers is specified in , it overrides this session-timeout web.xml timeOut parameter value. For details, see “session-timeout,” on page 15. • - the JDBC driver (the default is provider sun.jdbc.odbc.JdbcOdbcDriver For more information about the JDBC API, see the following web site: http://java.sun.com/products/jdbc/index.html NOTE class does not recognize JDBC driver classes...
  • Page 69 Deprecated Session Managers The following parameters allow you to customize the number of dedicated connections that perform each of the operations. • - the number of connections that perform lookup operations (the lookupPool default is 4 connections). • - the number of connections that perform insert operations (the insertPool default is 4 connections).
  • Page 70: Load Balancing, Session Failover, And Session Ids

    Load Balancing, Session Failover, and Session IDs context.global.sessionmgr=com.netscape.server.http.session.JdbcSess ionManager context.global.sessionmgr.initArgs=timeOut=1200,username=mysession, password=mypassword You can change the global context or define a new context and assign specific servlets to it. For more information, see Chapter 8, “Legacy Servlet and JSP Configuration.” This session manager can only store objects that implement java.io.Serializable Load Balancing, Session Failover, and Session Enterprise Server 6.1 supports server farm (or cluster) configurations with...
  • Page 71 Load Balancing, Session Failover, and Session IDs NOTE Enterprise Server session managers generate session IDs with a maximum length of 108 ASCII characters. Chapter 6 Session Managers...
  • Page 72 Load Balancing, Session Failover, and Session IDs Netscape Enterprise Server Programmer’s Guide to Servlets • April 2002 (Draft)
  • Page 73: Chapter 7 Api Clarifications

    Chapter 7 API Clarifications This chapter clarifies ways in which the Servlet 2.3 API specification is implemented in Netscape Enterprise Server 6.1 in the following sections: • Clarification of HttpSession Scope • Clarifications for Using Methods • Other Useful Information Clarification of HttpSession Scope The Servlet 2.3 API Specification is open to interpretation in regard to the scope of HttpSession objects.
  • Page 74: Clarifications For Using Methods

    Clarifications for Using Methods • Make sure that the session attributes are loaded by the virtual-server-level class loader. Add any common beans and so on that are going to be used as session attributes to the classpath there. <vs> <class-loader classpath="/myapps/sessionattrs.jar" /> </vs>...
  • Page 75: Servletcontext.getattribute

    Clarifications for Using Methods Clarification Servlets may create additional threads to handle their service logic. However, the API functions exposed by these objects must be accessed by either the request handling thread or one of the threads the servlet created, but not by both simultaneously.
  • Page 76 Clarifications for Using Methods Clarification When your form fields contain non-UTF-8 characters, you must do one of the following, or the values extracted by the method are zeros or are getParameter undefined: • Set the attribute of the element to (the default) parameter-encoding auto...
  • Page 77: Servletresponse.getoutputstream And Getwriter

    Clarifications for Using Methods ServletResponse.getOutputStream and getWriter public ServletOutputStream getOutputStream() throws java.io.IOException Returns a suitable for writing binary data in the response. ServletOutputStream The servlet container does not encode the binary data. Either this method or may be called to write the body, not both. getWriter public java.io.PrintWriter getWriter() throws java.io.IOException Returns a...
  • Page 78 Clarifications for Using Methods The request object passed to the target object will have its request URL path and other path parameters adjusted to reflect the target URL path of the target object. You cannot use this method if a object or ServletOutputStream PrintWriter...
  • Page 79: Other Useful Information

    Other Useful Information Other Useful Information This section contains information about the following topics: • Database Connection Pooling • Fetching the Client Certificate Database Connection Pooling Database connection pooling enhances the performance of servlet or JSP database interactions. There are several JDBC 2.0 compatible drivers that support connection pooling, for example Oracle8i™...
  • Page 80 Other Useful Information Netscape Enterprise Server Programmer’s Guide to Servlets • April 2002 (Draft)
  • Page 81: Chapter 8 Legacy Servlet And Jsp Configuration

    Chapter 8 Legacy Servlet and JSP Configuration This chapter describes legacy configuration procedures and files, which are provided for backward compatibility with iPlanet Web Server 4.x, in these sections: • The Default Virtual Server • Enabling Servlets and JSP • Making JSPs Available to Clients •...
  • Page 82: Enabling Servlets And Jsp

    Enabling Servlets and JSP Enabling Servlets and JSP To enable and disable servlets and JSPs, use the Java>Enable/Disable Servlets/JSP page in the Server Manager interface. By default, regardless of whether servlets are enabled or disabled, the file contains objects with names such as , and obj.conf servlet...
  • Page 83: Configuring Global Servlet Attributes

    Configuring Servlets in the Default Virtual Server In detail, to serve servlets in the default virtual server as in iPlanet Web Server 4.x, do the following steps: Configuring Global Servlet Attributes Registering Servlet Directories Registering Individual Servlets if Needed Specifying Servlet Virtual Paths if Desired Specifying Servlet Contexts if Desired Configuring Global Servlet Attributes You can specify the following optional servlet attributes:...
  • Page 84 Configuring Servlets in the Default Virtual Server For example, if the servlet is in the subdirectory of SimpleServlet.class servlet the server’s document root directory (the default servlet directory), you can invoke the servlet by pointing the web browser to: your_server http:// /servlet/SimpleServlet Enterprise Server expects all files in a registered servlet directory to be servlets.
  • Page 85: Registering Individual Servlets

    Configuring Servlets in the Default Virtual Server Registering Individual Servlets The Enterprise Server treats any file in a registered servlet directory as a servlet. There is no need to register individual servlets that reside in these directories unless any of the following criteria apply: •...
  • Page 86: Specifying Servlet Virtual Paths

    Configuring Servlets in the Default Virtual Server The following code shows an example of the configuration information for the same servlet in servlets.properties servlet.BuyNowServlet.classpath=D:/netscape/server4/docs/servlet /buy;D:/netscape/server4/docs/myclasses servlet.BuyNowServlet.code=BuyNow1A servlet.BuyNowServlet.initArgs=arg1=45,arg2=online,arg3="quick shopping Note that you can specify multiple values as the servlet classpath if needed. Specifying Servlet Virtual Paths If you register a servlet individually instead of putting it in a servlet directory, you must define a servlet virtual path for it.
  • Page 87 Configuring Servlets in the Default Virtual Server Virtual Servlet Path Example This example shows how to specify that the logical URL http://poppy.example.com/plans/plan1 invokes the servlet defined in server_root /docs/plans/releaseA/planP2Version1A.class. Specify the servlet identifier, class file, and class path. In the Legacy Servlets>Configure Servlet Attributes page in the interface, do the following: In the Servlet Name field, enter an identifier for the servlet, such as plan1A...
  • Page 88: Specifying Servlet Contexts

    Using the User Interface Specify the virtual path for the servlet. In the Legacy Servlets>Configure Servlet Virtual Path Translations page, do the following: In the Virtual Path field, enter the virtual path name. Note that the server name is implied as a prefix, so in this case you would only need to enter to specify the virtual path /plans/plan1 http://poppy.example.com/plans/plan1...
  • Page 89: Legacy Configuration Files

    Legacy Configuration Files These pages are located in the Server Manager on the Java tab. • The Enable/Disable Servlets/JSP Page • The Configure JVM Attributes Page • The Delete Version Files Page These pages are located in the Server Manager on the Legacy Servlets tab. •...
  • Page 90: Servlets.properties

    Legacy Configuration Files servlets.properties file defines global servlet settings and the list of servlets.properties servlets in the system, for the default virtual server only. An example of a global servlet setting is which servlet to run when the Enterprise Server starts up. The file also specifies configuration servlets.properties information for individual servlets.
  • Page 91: Rules.properties

    Legacy Configuration Files rules.properties file defines servlet virtual path translations, for the default rules.properties virtual server only. For example, you could set up a mapping so that the URL pointing to invokes the servlet named in the /mytest2 demo1 file. You can specify virtual paths for your servlets either servlets.properties by setting parameters in the Legacy Servlets>Configure Servlet Virtual Path Translation page of the Server Manager interface or by specifying the paths in the...
  • Page 92: Contexts.properties

    Legacy Configuration Files # a heavy peformance penalty ################################# rules ################################ /mytest1=tracker /mytest2=demo1 Using Regular Expressions in rules.properties Enterprise Server supports regular expressions in the file to rules.properties run a given servlet when the incoming URL matches with a regular expression. However, the example given in the file header is incorrect: # Example: # /simple=SimpleServlet\n...
  • Page 93 Legacy Configuration Files NOTE All JSPs belong to the default global context. You cannot define custom contexts for JSPs. However, you can change the properties of the global context to affect JSPs. If the context for a servlet is not defined, the servlet belongs to the global context. You can use the same servlet in multiple contexts.
  • Page 94 Legacy Configuration Files # context.<context_name>.uri=contex_uri_base - additional URI prefix which servces as a context base # context.<context_name>.authdb=name - authentication database # context.<context_name>.classpath=name - global classpath for this context # context.<context_name>.signleClassLoader=(true|false) - tells the servlet engine whether to use a single class loader for all servlets in the context # context.<context_name>.serverName=name - server instance name # context.<context_name>.contentTypeIgnoreFromSSI=(true|false) - ignore...
  • Page 95 Legacy Configuration Files isModifiedCheckAggressive When you modify a packaged servlet, the new version is not reloaded automatically unless you have done one of the following: • Set the property to , for example: isModifiedCheckAggressive true context.global.isModifiedCheckAggressive=true • Used the extension when invoking the servlet, for example: .class your_server http://...
  • Page 96: Legacy Examples

    Legacy Examples If a servlet uses the method to retrieve values in ServletRequest.getParameter form fields having non-UTF-8 characters, the property must parameterEncoding be set to (the default) or in the file. auto responseCT contexts.properties Otherwise, the values extracted by the method are zeros or are getParameter undefined.
  • Page 97: Maximizing Legacy Servlet Performance

    Maximizing Legacy Servlet Performance • -- Contains a JSP application that was an SSJS application in jsp.10/hangman iPlanet Web Server 4.x. For more information about converting SSJS applications to JSPs, see Appendix B, “Converting SSJS Applications.” • -- Contains example makefiles for servlets. These are common makefiles make containing rules that are included by all other makefiles.
  • Page 98 Maximizing Legacy Servlet Performance Netscape Enterprise Server Programmer’s Guide to Servlets • April 2002 (Draft)
  • Page 99: Appendix A Servlet Settings In Magnus.conf And Obj.conf

    Appendix A Servlet Settings in magnus.conf and obj.conf The Netscape Enterprise Server 6.1 Administration Server automatically modifies files to load the servlet engine if servlets are magnus.conf obj.conf enabled. Whenever you make changes to servlet settings by using the Server Manager interface, the system automatically updates these files appropriately.
  • Page 100: Objects In Obj.conf

    Objects in obj.conf for UNIX, the directives are the same except for the following parameter: server_root shlib=" /bin/https/lib/libNSServletPlugin.so" takes an optional parameter, , which specifies the NSServletEarlyInit cache_dir location of a temporary cache directory for JSP classes. By default, the directory is named and goes under your server root directory.
  • Page 101 Objects in obj.conf <Object name="default"> NameTrans fn=assign-name name=foo from=*.foo ...other directives... </Object> <Object name="foo"> ObjectType fn=force-type type=magnus-internal/servlet Service fn="NSServletService" servlet="wasp" </Object> For another way to direct files of a specific type to a specific servlet, see the description of the element in the file, which is servlet-mapping...
  • Page 102: Directives For Registered Servlet Directories

    Directives for Registered Servlet Directories Directives for Registered Servlet Directories The information in this section applies to legacy (iPlanet Web Server NOTE 4.x) servlets and is deprecated. For each registered servlet directory, the default object in has a obj.conf directive that assigns the name to all requests to access NameTrans ServletByExt...
  • Page 103: Appendix B Converting Ssjs Applications

    Appendix B Converting SSJS Applications This appendix contains information about converting Server-Side JavaScript™ applications to JSPs. It has the following sections: • Differences Between JavaScript and Java • JavaScript to Java Class Conversions • Conversion Steps • Example Conversion Differences Between JavaScript and Java Before you can convert SSJS applications to JSPs, you must understand the differences between JavaScript and Java.
  • Page 104 Differences Between JavaScript and Java Java is a class-based programming language designed for fast execution and type safety. Type safety means, for instance, that you can’t cast a Java integer into an object reference or access private memory by corrupting Java bytecodes. Java’s class-based model means that programs consist exclusively of classes and their methods.
  • Page 105: Javascript To Java Class Conversions

    JavaScript to Java Class Conversions JavaScript to Java Class Conversions The objects used in an SSJS application must be converted to classes in Java. Table B-2 can help you convert these objects. Table B-2 JavaScript and Java basic classes SSJS Class Java Class Comments A Java session is not as automatic as an...
  • Page 106: Conversion Steps

    Conversion Steps Conversion Steps When converting applications, follow these steps: Go over the structure of the application to see if there are helper classes that provide functionality between pages. Convert these helper classes first so that they are ready to use in your pages. (The example contains a helper hangman class, called...
  • Page 107: Example Conversion

    Example Conversion Example Conversion example, which was a Server-Side JavaScript example in the 4.1 hangman version of iPlanet Web Server, have been converted to a JavaServer Pages example in Enterprise Server 6.0. You can find the converted example under the following directory: server_root /plugins/servlets/examples/legacy/jsp.10/hangman...
  • Page 108 Example Conversion Netscape Enterprise Server Programmer’s Guide to Servlets • April 2002 (Draft)
  • Page 109: Appendix C Jvm Configuration

    Appendix C2.3 JVM Configuration The Java Virtual Machine (JVM) works by default without any additional configuration if properly set up. However, if you need to specify settings for the JVM, such as additional classpath information, you can configure the JVM properties for Netscape Enterprise Server via the Administrator interface.
  • Page 110: The Jvm12.Conf File

    The jvm12.conf File The jvm12.conf File You can also configure JVM parameters by editing the configuration jvm12.conf file, which resides under the server’s directory. config For example, to disable JIT, you can add the following line to jvm12.conf java.compiler=NONE Here is an example file.
  • Page 111: Using Jvm Environment Variables

    Using JVM Environment Variables Using JVM Environment Variables If you define JVM environment variables using the setting in the jvm.option file or the Administration Server, servlets do not recognize them. Just jvm12.conf use the plain name value format for environment variables. When you are running a stand-alone command line java program, use the following option to pass system properties into the java program: java -Dorg.omg.CORBA.ORBClass=com.inprise.vbroker.orb.ORB myprogram...
  • Page 112: Jvm12.Conf Parameter Reference

    jvm12.conf Parameter Reference jvm12.conf Parameter Reference The JVM parameters you can set in the file are listed in Table C-1. jvm12.conf jvm12.conf settings Table C-1 Setting Allowed Values Default Value Description The minimum heap size jvm.minHeapSize 1048576 (1 MB) allocated to Java. For Solaris, change this value to 3145278 (3 MB).
  • Page 113 jvm12.conf Parameter Reference Table C-1 jvm12.conf settings Setting Allowed Values Default Value Description Allows you to set vendor JVM jvm.option options. The following options are ignored, because there are equivalents to these settings: -D, -Xnoclassgc, -Xdebug, -Xms, -Xmx, -verbose Specifies the profiler. If you use jvm.profiler the optimizeit profiler from Intuitive Systems, you must also...
  • Page 114 jvm12.conf Parameter Reference Table C-1 jvm12.conf settings Setting Allowed Values Default Value Description 0 (off), 1 (on) Setting the value of this jvm.stickyAttach parameter to 1 causes threads to remember that they are attached to the JVM. This speeds up request processing by eliminating AttachCurrentThread and DetachCurrentThread calls.
  • Page 115 jvm12.conf Parameter Reference Table C-1 jvm12.conf settings Setting Allowed Values Default Value Description 0 (off), 1 (on) Enables or disables verbose JSP nes.jsp.enabledebug compilation tracing. For more information about remote debugging, see Chapter 5, “Debugging Servlets and JSPs.” 0 (off), 1 (on) Specifies whether to include the jvm.include.CLASSPATH CLASSPATH environment...
  • Page 116 jvm12.conf Parameter Reference Netscape Enterprise Server Programmer’s Guide to Servlets • April 2002 (Draft)
  • Page 117: Appendix D Remote Servlet Profiling

    Appendix D Remote Servlet Profiling You can use a profiler to perform remote profiling on the Netscape Enterprise Server to discover bottlenecks in server-side performance. This appendix describes two profilers: • The Optimizeit! Profiler • The HPROF Profiler The Optimizeit! Profiler You can purchase the Optimizeit!™...
  • Page 118: The Hprof Profiler

    The HPROF Profiler Also, update the system variables to include the PATH NSES_CLASSPATH profiler’s own jar files and dll files. NOTE If any of the configuration options are missing or incorrect, the profiler may experience problems that affect the performance of the Enterprise Server.
  • Page 119 The HPROF Profiler To use HPROF profiling on UNIX, follow these steps: To enable HPROF profiling, edit the file as shown here: jvm12.conf jvm.printErrors=2 jvm.profiler=hprof jvm.option=-Xrunhprof:options #jvm.option=-Xrs must be commented out java.compiler=NONE Suggested options for using Enterprise Server with HPROF are: jvm.option=-Xrunhprof:file=/tmp/hprof.txt,heap=all,format=a jvm.option=-Xrunhprof:file=/tmp/hprof.txt,cpu=samples,format=a The syntax of HPROF is as follows:...
  • Page 120 The HPROF Profiler You must also change a line in the Enterprise Server start script. The start script file is server_root server_id . Change the following line: /https- /start PRODUCT_BIN=uxwdog to this: PRODUCT_BIN=ns-httpd Start the server by running the start script. Since the server runs in the foreground (the change in step 2), the command prompt returns only after the server has been stopped.
  • Page 121 The HPROF Profiler To capture more HPROF profiles, repeat steps 6 and 7. To stop the Web Server, run the stop script from another window. % ./stop Undo the changes in steps 1 and 2 to return your Enterprise Server to its original configuration.
  • Page 122 The HPROF Profiler Netscape Enterprise Server Programmer’s Guide to Servlets • April 2002 (Draft)
  • Page 123: Index

    Index class attribute 27 Class Manager 34, 43 about this book 7 ClassCache directory 44, 49 accessTimeColumn class-loader element 22 parameter for JdbcSessionManager 68 classpath parameter for NESSessionManager 60 for JDK 42 API clarifications 73 for JVM 115 API reference for legacy servlets 85 JavaBeans 13 classpath attribute 22...
  • Page 124 debugging SSJS to JSP conversion 107 JSPs 52 web applications 31 servlets remotely 51 exceptions, sending to the client 52, 53 default context 18 default virtual server 81 delegate attribute 22 deletePool parameter for JdbcSessionManager 69 file extensions parameter for NESSessionManager 61 .class 84 deleting .jsp 82, 102...
  • Page 125 Internationalization 24, 75, 95 JSP 12 accessing Java 13 Intuitive Systems API reference 13 web site 117 cache directory 44, 65 isModifiedCheckAggressive context property 95 command-line compiler 45 is-secure attribute 27 compiling 45 converting SSJS applications to 103 debugging 52 enabling 44 directives 102 enabling legacy 82...
  • Page 126 jvm.trace parameter 114 multiple legacy servlet directories 84 jvm.verboseMode parameter 112 jvm12.conf file 37, 110 parameter reference 112 nes.jsp.enabledebug parameter 115 nes.jsp.forkjavac parameter 115 NES_SERVER_HOME environment variable 29, 45 keepgenerated parameter 49 NESHttpSession source code 62 NESHttpSessionManager 62 NESSessionManager 58 enabling 61 parameters 58 largeFile parameter 49...
  • Page 127 password parameter for JdbcSessionManager 68 scratchdir parameter 49 parameter for NESSessionManager 60 security-constraint element 17 path Server Manager 34, 43 to JRE or JDK 41 for legacy servlets and JSPs 88 path to JRE or JDK 41 server.xml file 18 persistent session manger 58, 63, 67 Server-Side JavaScript pooling of database connections 79...
  • Page 128 remote profiling 117 source code session managers 55 NESHttpSession 62 sessions 55 NESSessionManager 62 specifying legacy virtual paths 86 specifying startup, legacy 83 JDK or JRE 41 using 11, 33 legacy servlet directories 83 using a single class loader for legacy 96 legacy virtual servlet paths 86 using Server Manager 34 path translations for legacy servlets 86...
  • Page 129 updatePool clarifications 17 parameter for JdbcSessionManager 69 web-app element 28 parameter for NESSessionManager 61 web-apps examples directory 31 uri attribute 28 web-apps.xml file 18 element reference 21 parameter for JdbcSessionManager 68 example 20 parameter for NESSessionManager 60 webapps_enable variable 18 use-cookies attribute 27 webapps_file variable 19 use-precompiled parameter 49...
  • Page 130 Netscape Enterprise Server Programmer’s Guide to Servlets • April 2002 (Draft)

This manual is also suitable for:

Enterprise server 6.1

Table of Contents