vqServer Java servlets
Java servlets are a way to add extra functions and capabilities to web servers. They are an alternative to CGI scripts. However, servlets are more efficient and more powerful than CGI scripts. vqServer is a very efficient host for Java servlets because it is itself a Java application. Servlets run on the server (as opposed to Java applets which run in a browser). They are written in Java and conform to the servlet specification published by and available from Sun. For more information about servlets, including more very good reasons why you should use them, please see Sun's online documentation. vqServer version 1.9 implements version 2.0 of Sun's servlet specification and API (but see API notes below). |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Sample servletsThree sample servlets are included with vqServer:
|
![]() ![]() ![]() ![]() ![]() |
Internal servletsSome of vqServer's functions are provided by special internal servlets which have access to the inner workings of vqServer. These are:
The vq.server.UserXxx servlets are discussed on the special security features page. |
![]() ![]() ![]() ![]() ![]() |
Calling servlets and servlet aliasesThere are three ways to invoke servlets:
In all three cases, vqServer expects servlets to be specified by their alias (see the aliases page for more information about aliases):
Note that aliases always begins with /. By convention, servlet aliases begin with /servlet/, although they can in fact be anything you like. An alias can refer to a Java package. If so, the alias and its real name should end with a dot. In the default configuration supplied with vqServer, this method is used to alias the special internal servlets. It's almost impossible for vqServer to check such aliases (the package might be in an archive or on the CLASSPATH) so you'll have to carefully check any such aliases yourself. You can't use this method if the package is on the CLASSPATH and its name confilicts with the name of a subdirectory of website/. vqServer expects the real name resulting from the translation of a servlet's alias to match servletdir/package.classname (see the aliases page for information about alias translation). Note:
vqServer can also load servlets and their associated resources from .JAR or .ZIP archives. If a servlet is in a .JAR archive the real name resulting from the translation of its alias should match archivedir/archivename.jar/classname. Servlet class files cannot be in subdirectories within .JAR or .ZIP files unless the subdirectories represent package names. |
![]() ![]() ![]() ![]() ![]() |
Java libraries
Complex servlet-based applications increasingly rely on support classes
distributed in several .JAR or .ZIP files in addition to the
.JAR or .ZIP file that contains the actual servlet. You can
make the classes in these additional files available to servlets invoked
by vqServer without adding them to your CLASSPATH by adding them to
the list of Java libraries displayed by clicking on
Classes loaded from Java libraries:
Note: On Sun's Java platforms version 1.2 and above you can achieve the same result as adding .JAR or .ZIP files to vqServer's Java libraries using the JVM's extension mechanism (just copy the files to your jre/lib/ext/ directory). This is usually more efficient than using vqServer's Java libraries. Java libraries page
This page is displayed when you click on
The following is displayed for each library.
The |
![]() ![]() ![]() ![]() ![]() |
Servlet initialisation parametersYou can specify initialisation parameters for a servlet by clicking on Aliases in the control centre menu and then clicking on the icon in the parameters column next to the corresponding alias (see Alias parameters). You may want to create an alias specifically for each servlet for which you need to provide initialisation parameters. The data vqServer returns to servlets in response to the getParameterNames() and getParameter() methods of the ServletConfig interface is that which is in force at the time the method is invoked, not that which was in force when the servlet is initialised and can therefore change during the life of the servlet instance. Modifying and reloading servletsvqServer checks each servlet's .class file before calling the servlet (unless the servlet was loaded from a Java library or from your CLASSPATH). If the .class file has changed since the servlet was last called vqServer calls the servlet's destroy() method (and the destroy() method of any other servlets that were loaded from the same directory) and reloads and re-initialises the servlet. If the servlet was loaded from a .JAR or .ZIP archive, the servlet (and any other servlets loaded from the same archive) is destroyed if the archive has changed. You can force vqServer to call the destroy() method and unload all active servlets by clicking Other in the control centre menu and then clicking Stop all servlets. |
![]() ![]() ![]() ![]() ![]() |
Classes and instancesYou can have more than one instance of the same servlet, each with different initialisation parameters, by using different aliases which correspond to the same servlet class (in the same servlet directory). Different instances of the same servlet and other servlets and classes loaded from the same directory share static class data. Servlets cannot "see" servlets and classes loaded from other servlet directories (except for Java libraries and the system CLASSPATH). In other words, the directory from which a servlet is loaded defines its name space. The servlet CLASSPATHThe classes which a servlet can refer to are:
|
![]() ![]() ![]() ![]() ![]() |
Security considerationsvqServer doesn't impose any restrictions whatsoever on servlet activity. For example servlets can read, write and delete any file on your computer. So make sure that any servlets you deploy on your web site come from a reputable source or are thoroughly debugged. |
![]() ![]() ![]() ![]() ![]() |
API notesServlet writers should note the following concerning the vqServer implementation of the Sun servlet API:
vqServer version 1.9. Copyright © 1997-2000 Steve Shering and vqSoft. Last updated 17 June 2000. |
![]() ![]() ![]() ![]() ![]() |