Main: Whitepaper FAQ Examples JavaDoc Classloader Performance
Protomatter Software v1.1.8

com.protomatter.syslog.xml
Class SyslogInitServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.protomatter.syslog.xml.SyslogInitServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class SyslogInitServlet
extends javax.servlet.http.HttpServlet

A servlet that configures Syslog when its init() method is called. It should be configured in a WebApp by adding the following declaration to the web.xml file for the WebApp:

    <servlet>
      <servlet-name>SyslogInitServlet</servlet-name>
      <description>Syslog Initialization Servlet</description>
      <servlet-class>com.protomatter.syslog.xml.SyslogInitServlet</servlet-class>
      <init-param>
        <param-name>config.xml</param-name>
        <param-value>/path/to/syslog.xml</param-value>
      </init-param>
      <init-param>
        <param-name>show.config.on.get</param-name>
        <param-value>false</param-value>
      </init-param>
      <init-param>
        <param-name>load.config.as.resource</param-name>
        <param-value>false</param-value>
      </init-param>
      <init-param>
        <param-name>Syslog.xml.parser</param-name>
        <param-value>org.apache.xerces.parsers.SAXParser</param-value>
      </init-param>
      <init-param>
        <param-name>Syslog.classloader.warning</param-name>
        <param-value>true</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
      <servlet-name>SyslogInitServlet</servlet-name>
      <url-pattern>/SyslogInitServlet</url-pattern>
    </servlet-mapping>
  

The config.xml init param is requred and should point to the XML configuration file for Syslog.

If the optional show.config.on.get init param is set to true (the default is false), then when the servlet is hit with a GET request, it will return the current Syslog configuration. Care should be taken when using this option since the syslog configuration file may contain database passwords, etc. It is a good idea to use declarative security to protect this servlet if you are allowing it to display the configuration file.

If the optional load.config.as.resource init param is set to true (the default is false), then when the servlet initializes, it will try and find the configuration file as a resource using the classloader that loaded the servlet. This is a useful option if you are using this servlet to allow you to use a different Syslog instance for each EAR in a J2EE server. For instance, if you set the value of the config.xml parameter to "syslog-config.xml", and then set load.config.as.resource to "true", then you can put a file called "syslog-config.xml" in the base of the EAR directory, and the servlet will find it. This is a nice option to use if you don't like to have hard-coded paths in the web.xml file.

The optional Syslog.xml.parser init param can be used to set the class name of the XML parser used to read the XML configuration file. It is possible that a confused JAXP registry can cause problems. You should set this property to "org.apache.xerces.parsers.SAXParser" or something similar. Note that this has the exact same effect as setting the same property as a system property (using the "-D" option to the JVM). It is preferable to use that property in the web.xml file instead of the system property because you can then have the ability to use different XML parsers for different EAR files.

The optional Syslog.classloader.warning init param can be used to turn off the classloader warning that is issued if Syslog is loaded with a ClassLoader other than the system one. The default value for this property is true, meaning that the warning should be displayed. Note that this has the exact same effect as setting the same property as a system property (using the "-D" option to the JVM). Some people prefer to use that property in the web.xml file instead of the system property because they don't like to have to set system properties. Please read this document regarding classloader issues with Syslog.

The <servlet-mapping> tag above is optional. If it is not specified, the servlet will still initialize syslog when the WebApp comes up, but the servlet will not be visible to web browsers. This is generally a good thing.

See Also:
Serialized Form

Constructor Summary
SyslogInitServlet()
          Default constructor.
 
Method Summary
 void destroy()
          Showdown syslog.
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
           
 void init(javax.servlet.ServletConfig config)
          Initialize syslog.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyslogInitServlet

public SyslogInitServlet()
Default constructor.
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initialize syslog.
Overrides:
init in class javax.servlet.GenericServlet

destroy

public void destroy()
Showdown syslog.
Overrides:
destroy in class javax.servlet.GenericServlet

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse resp)
           throws javax.servlet.ServletException,
                  java.io.IOException
Overrides:
doGet in class javax.servlet.http.HttpServlet

Protomatter Software v1.1.8
Copyright 1998-2002 Nate Sammons

Protomatter Software v1.1.8 http://protomatter.sourceforge.net/1.1.8