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 interface published by and available from JavaSoft. For more information about servlets, including more very good reasons why you should use them, please see the JavaSoft site.

vqServer implements version 1.01 of JavaSoft's servlet specification and API with a few limitations.

vqServer
Register (free!)
Support

Contents

Aliases
CGI scripts

Samples
Internal servlets
Calling servlets
Parameters
Classes & Instances
Security
Limitations

Sample servlets

Two sample servlets with source code are included with vqServer:

  • hello: This very basic servlet produces a web page which displays a Hello world message. Type http://localhost/test in your web browser's Address box to see it work. The source code is in website/servlets/hello/hello.java.
  • info: This servlet produces a web page which displays some diagnostic information about the web server, the servlet's initialisation parameters and the request which invoked the servlet. Type http://localhost/info in your web browser's Address box to see it work. The source code is in website/servlets/info/info.java.
vqServer
Contents
Servlets

Aliases
CGI scripts

Internal servlets

Some of vqServer's functions are provided by special internal servlets which have access to the inner workings of vqServer. These are:

  • vq.server.admin: The control centre servlet.
  • vq.server.userreg: Permits user self-registration.
  • vq.server.userlogin: Enables use of custom login pages.
  • vq.server.userpwd: Allows registered users to change their passwords.
  • vq.server.userlogout: Facilitates logout.

The vq.server.userxxx servlets are discussed on the Security extras page.

vqServer
Contents
Servlets

Aliases
CGI scripts

Calling servlets

Servlets are invoked by typing the appropriate alias in the Address box of a web browser or by clicking on a link on a web page (which sends an alias to the web server). vqServer expects the real name corresponding to the alias to match servletdir/package.classname (see the Aliases page). Note:

  • The real name should not end in .class.
  • vqServer expects to find classname.class in the servletdir/package subdirectory of your website directory.
  • If the servlet author did not specify a package name the real name should be servletdir/package/classname.
  • vqServer looks for classes referenced by the servlet in website/servletdir first and then in your CLASSPATH.
  • If the real name does not include servletdir/ vqServer expects to find package/classname.class in your CLASSPATH. This is how the special vqServer internal servlets are called.
vqServer
Contents
Servlets

Aliases
CGI scripts

Servlet initialisation parameters

You 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 servlets

vqServer checks each servlet's .class file before calling the servlet. If the .class file has changed since the servlet was last called vqServer calls the servlet's destroy() method and reloads and re-initialises the servlet.

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.

vqServer
Contents
Servlets

Aliases
CGI scripts

Classes and instances

You can have more than one instance of the same servlet, each with different initialisation parameters, by using different aliases to refer to the servlet. However different instances of the same servlet do not share static class data in vqServer.

vqServer
Contents
Servlets

Aliases
CGI scripts

Security considerations

vqServer 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.

vqServer
Contents
Servlets

Aliases
CGI scripts

Limitations

The following limitations apply to the vqServer version 1.03 implementation of JavaSoft's servlet API version 1.01.

  • Interface javax.servlet.ServletContext
    • getAttribute() always returns null.
    • getServlet() can only find servlets which have already been initialised.
    • getServletNames() only returns the names of initialised servlets.
    • getServlets() only returns initialised servlets.
  • Interface javax.servlet.ServletResponse
    • getCharacterEncoding() always returns text/plain.
  • Interface javax.servlet.SingleThreadModel: Not implemented.
  • Interface javax.servlet.http.HttpServletRequest
    • getPathInfo() and getpathTranslated() return nonsense; vqServer's alias and servlet specification paradigm doesn't allow for pathinfo.
    • getSession() always returns null.
    • getRequestedSessionId() always returns null.
    • isRequestedSessionIdValid() always returns false.
    • isRequestedSessionIdFromCookie() always returns false.
    • isRequestedSessionIdFromUrl() always returns false.
  • Interface javax.servlet.http.HttpServletResponse
    • encodeRedirectUrl() returns the URL unmodified.
    • encodeUrl() returns the URL unmodified.
  • Interface javax.servlet.http.HttpSession is not implemented.
  • Interface javax.servlet.http.HttpSessionBindingListener is not implemented.
  • Interface javax.servlet.http.HttpSessionContext is not implemented.


vqServer version 1.03. Copyright © 1997-98 vqSoft and Steve Shering. Last updated 13 May 1998.

vqServer
Contents
Servlets

Aliases
CGI scripts