Knowledge base: Using Java Servlets and JSP

  1. Introduction
  2. Current Status on Positive Internet Servers
  3. Deploying Servlets
  4. Configuring Servlets
  1. Introduction

    Servlets are a server side method of using Java to perform common cgi like functions. Although best suited to quite complex environments they can make be used for simple applications such as login forms and formmail scripts.

    Back to top

  2. Current Status on Positive Internet Servers

    At the moment positive are moving towards standardising on the Tomcat servlet engine, due to this the guide will lean towards the use of servlets with the Tomcat engine. The other server in use is JServ, this was originally from a similar source tree to Tomcat however development of JServ ceased almost a year ago now and therefore does not support the newer iterations of the SerlvetAPI and JSP specifications.

    Back to top

  3. Deploying Servlets

    Tomcat
    You will have, if servlets have been activated, a directory called WEB-INF inside your public_html directory. Inside there are three points of interest:
    WEB-INF/classes All classes belong here. WEB-INF/lib Any jar files you are intending to use. WEB-INF/web.xml May or may not exist, contains preferences particular to your website. Normally servlets are callable via this style of url:

    http://yourdomain/servlet/name

    So a servlet placed here:

    WEB-INF/classes/com/yourdomain/site/Welcome.class

    Is callable via:

    http://yourdomain/servlet/com.yourdomain.site.Welcome

    JServ
    You will have, if servlets have been activated, a directory called servlets, inside your home directory. All classes and jar files belong here and apart from that follow the same rules as tomcat above. You will find however, due to legacy reasons, the calling url is of the following style: http://yourdomain/servlets/name Jar files placed inside the servlets directory will need to be explicitly added to your properties file which is the closest thing JServ has to web.xml. This will more that likely not be editable by you and you will therefore need to contact support.

    Back to top

  4. Configuring Servlets

    Tomcat Only
    Tomcat is locally configurable via the web.xml file, the specification of which is available here:
    Servlets Specification One configuration structure is worthy of special mention at the moment, the following structure:

    <servlet>
    <servlet-name>Cocoon</servlet-name>
    <servlet-class>org.apache.cocoon.Cocoon</servlet-class>
    <init-param>
    <param-name>properties</param-name>
    <param-value>.htcocoon-props</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <url-pattern>*.xml</url-pattern>
    <servlet-name>Cocoon</servlet-name>
    </servlet-mapping>

    Will need a corresponding entry in the apache configuration:

    JkMount /Cocoon/* ajp13

    Back to top