Java Server

Frequently Asked Questions (FAQ) (Beta)


Documentation

This is the Beta version of the Java Server FAQ. It has the following sections:

In later releases, you should expect that many of the answers now found here will be addressed in the main Java Server documentation.

See Known Bugs for a list of known bugs and their workarounds. Please review this list before reporting a bug.


Installation/Configuration:

  • I'm on Solaris; where's the package I install?

    There's no "package" to install at this time. We are using a two distribution formats, tar files, which works on all the platforms we support, and Win32 .exe files for Windows platforms. Packages only work on Solaris and other UNIXes derived from System V release 4 sources. Just "untar" the distribution and follow the installation instructions.

  • Why do I get a "Cannot locate java runtime" error when trying to start the server?

    Make sure of the following:

    1. You should have the JDK1.1 FCS candidate.
    2. Check to make sure that you have the following environment settings:
      • CLASSPATH contains {JDK location}\lib\classes.
      • JAVA_HOME = {JDK location}

  • I'm trying to compile a servlet, and my Java compiler can't find the java.servlet.Servlet class. What do I do?

    You need to modify the classpath used by your compiler so that it includes the Java Server lib/classes.zip file. With JavaSoft's JDK, you can do this either by modifying the CLASSPATH environment variable or by passing a suitable -classpath flag to the javac compiler invocation. Some other Java compilers have different requirements.

  • Why do I get java.lang.NoSuchMethodError: java.net.InetAddress ?

    Java Server requires JDK1.1 or later to run. Your CLASSPATH environment variable is pointing to earlier version of the JDK. If you're using JavaSoft's JDK, download the latest version of the JDK and add it to your CLASSPATH (instructions are included with the JDK). Otherwise, if you're not using JavaSoft's JDK, then get the upgrade which your product vendor should have made available by now.

  • How can I get the server to start automatically when the machine boots up?

    For the Solaris platform we currently provide an /etc/rc script, the server_root/etc/java-server.startup file; read this for installation instructions. Support for other platforms will be provided in one of our future releases.

  • In a Unix environment do I need to set my CLASSPATH variable?

    No. When running the Java Web Server in a Unix environment it is better to unset the CLASSPATH variable. The CLASSPATH variable is handled by the http daemon, httpd.


    Server:

    1. I can't bind to port less than 1024

      Make sure httpd is running as root. If you still see this problem when running as root, it might be a bug with the operating system. Solaris 2.5 has a bug which will not allow this to work. Upgrading to 2.5.1 or later will fix this problem.

    2. Does Java Server administration conform to JMAPI?

      A high level description of JMAPI is: "A Java Management API that provides a rich set of extensible Java objects and methods for building applets that can be used to manage an enterprise network over Internets."

      We are not writing a tool to manage an enterprise network. We are writing one that is a component that can be managed in such a framework. So our roadmap includes plans to fit our tool into existing system and network management tools as required by our customers. Tools using JMAPI, SNMP, and CMIP are all possible candidates for such integration.

      In addition we plan to integrate with existing operating system facilities as much as possible. For instance, while we provide our own user, group, and ACL management, our first release includes support for existing Unix users. Standard tools can be then used to administer security policies and we will work with those.

    3. What is an EventLog?

      This is the log file which servlets and server can use for messages of arbitrary format. Arbitrary format is also used by the Error Log. The Access Log uses the common log file format.

    4. Why do we use the properties format in administration?

      Properties are what Java applications (i.e HotJava) use for default administration. They are simply a series of name-value pairs. We do not anticipate administrators needing to manually modify most of the administration files, since we are currently working on web based administration tools.

    5. Why do users I've added disappear and users I've deleted reappear?

      When upgrading the JavaServer, the configuration files may be overwritten. To avoid this, the current workaround is to copy your current configuration files to a safe location during a Java Server upgrade. Copy the old/safe configuration files over the new ones once the upgrade is complete. This problem will be remedied in the future by a more robust installation procedure.


    Servlets

    1. What are servlets? What do they do?

      Servlets are objects which conform to a specific interface that can be plugged into a Java-based server. Servlets are similar to applets in that they are object bytecodes that can be dynamically loaded off the net, but differ from applets in that they are faceless objects (without any graphics). They serve as platform independent dynamically loadable pluggable helper bytecode objects on the server side. Servlets are a first step towards agents, but they differ from agents in that they need to be explicitly invoked on and moved.

    2. How are the servlets identified or located?

      Like applets, servlets are identified by a URL address:

        http://server_host/MyServlet.class

    3. How do I load servlets?

      Servlets can be loaded in two ways. One is by loading the html file that is mapped to a servlet name on the server side. The AdminApplet file maps the html name into a servlet name and the servlet name into a servlet class. The servlet class must be found in the CLASSPATH environment of the server. The second way to load a servlet is to specify the name of the servlet in the URL. For this the "/servlet/" identifier can be used, and the servlet invoker automatically loads the named servlet. For more information, see Servlet Loading and Invoking.

    4. What is a servlet invoker?

      A servlet invoker is a servlet that invokes the "service" method on a named servlet. If the servlet is not loaded in the server, then the invoker first loads the servlet (either from local disk or from the network) and the then invokes the "service" method. Also like applets, local servlets in the server can be identified by just the class name. In other words, if a servlet name is not absolute, it is treated as local.

    5. How are servlets invoked?

      Servlets can be invoked by a client in the following ways:

      • The client can ask for a document that is served by the servlet.

        The server gets a request for a document, looks up the configuration parameters, finds out that the document is not a static document residing on the disk, but a live document generated by a servlet object, and forwards the request to the servlet which services the request by generating the output. This method is the same as used by traditional web servers for invoking CGI scripts.

      • The client (browser) can also invoke the servlet directly by giving the URL of the servlet.

        The client invokes the servlet with a URL of the form:

        http://server_host/servlet/<servlet URL>

        where the <servlet URL> is a regular URL that points to the location of the servlet. The host where servlet resides might be different from the host where the server is running. In this case the servlet class will be dynamically downloaded to the server, instantiated and then run. The reason this invocation is useful is that it does not need any special understanding of servlets on the part of the browser.

      • The servlet can be invoked through server side includes.

        Any file ending with .shtml is a server parsed file. In .shtml, if a servlet tag or server-insert tag is present, then the server will run the servlet and insert the output generated by the servlet in the place of the insert tag.

      • The servlet by placing them in the servlets/ directory

        In Beta, servlets can be dropped in to the servlets/ directory relative to the root of the server. Servlets placed in this directory can be invoked using their class names as follows (assuming HelloWorld.class was placed in the server_root/servlets directory):

        
        http://server_host_name:8080/servlet/HelloWorld
        
        A class_file.initArgs file can be placed in the same directory for passing init args to the servlet in question. For example to pass two init args A=B and C=D to the HelloWorld servlet. A HelloWorld.initArgs file must be created in the extensions dir whose syntax would be:
        
        A=B
        C=B
        
        When Servlets are recompiled in this directory - the new version will be automatically loaded by the server.

    6. How do I pass arguments to the servlets?

      Arguments to the servlets can be passed at two levels.

      1. When a client is invoking the servlet, the client can pass the arguments as part of URL in form of name/value pairs in the query string portion of the URL. If a tag is used in the html language to invoke the servlet, the arguments can be passed through the param name construct:

        <servlet code="servlet_name" stock_symbol="SUNW">

      2. The server administrator/web-master can pass arguments to the servlet at the loading/intialization time by specifying the arguments as part of the server configuration.

    7. How long do servlets last?

      Once activated, servlets live on until the server lives or until the destroy method is called on the servlet by the server. The servlets with association in servlet aliases, unmapping the alias will destroy the servlet, and subsequent access to the servlet will reload the servlet.

    8. What servlets are currently part of the server?

      See the Core Servlets page, and the Servlet Examples page for information on some of the available servlets. Also look in the server_root/servlets directory of the release for more servlets.

    9. Why can't I compile a servlet?

      Make sure that your CLASSPATH is set to include the Java Server classes. This can be done at the command line (using java -classpath ....) or else in the environment variable.

    10. How do I set multiple properties?

      The following is the proper syntax:

        test.jpeg.initArgs=\
        video=vid/media/lion.c.4.jpeg,rate=4

    11. What is passed as ServletRequest for servlets invoked as server side include?

      SSIncludeServlet will clone its ServletRequest, and substitute the parameters embedded in the tag.


    Reference:

    1. Where can I find more information on Java?

      There are a number of sources for more information on the Java Programming Language. General information is available at the JavaSoft Web Site, including a Java tutorial, a free binary release of the Java Developers Kit, and extensive documentation. There are also a number of books available on Java - see your local technical bookstore for a selection.

    2. Where can I find more information on HTTP and other W3 Protocols?

      A good site for information on World Wide Web Protocols is available on the W3C Protocols page. This mainly has HTTP information, but also has links to information on other protocols.

    3. Where can I find more information on CGI?

      NCSA's Common Gateway Interface page is a good resource for CGI information. It includes information on how to use CGI with form output.


      Top
      java-server-feedback@java.sun.com