org.apache.ignite.startup.servlet

## Class ServletStartup

- java.lang.Object
- - javax.servlet.GenericServlet
  - - javax.servlet.http.HttpServlet
    - - org.apache.ignite.startup.servlet.ServletStartup

- All Implemented Interfaces:
    Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

      public class ServletStartup
      extends javax.servlet.http.HttpServlet

  This class defines servlet-based Ignite startup. This startup can be used to start Ignite inside any web container as servlet.

  This startup must be defined in `web.xml` file.

       <servlet>
           <servlet-name>Ignite</servlet-name>
           <servlet-class>org.apache.ignite.startup.servlet.ServletStartup</servlet-class>
           <init-param>
               <param-name>cfgFilePath</param-name>
               <param-value>config/default-config.xml</param-value>
           </init-param>
           <load-on-startup>1</load-on-startup>
       </servlet>

  Servlet-based startup may be used in any web container like Tomcat, Jetty and etc. Depending on the way this startup is deployed the Ignite instance can be accessed by either all web applications or by only one. See web container class loading architecture:

  - http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html
  - http://docs.codehaus.org/display/JETTY/Classloading

  ## Tomcat

  There are two ways to start Ignite on Tomcat.
  - Ignite started when web container starts and Ignite instance is accessible only to all web applications.
    1. Add Ignite libraries in Tomcat common loader. Add in file `$TOMCAT_HOME/conf/catalina.properties` for property `shared.loader` the following `$IGNITE_HOME/ignite.jar,$IGNITE_HOME/libs/*.jar` (replace `$IGNITE_HOME` with absolute path).
    2. Configure startup in `$TOMCAT_HOME/conf/web.xml`

                    <servlet>
                        <servlet-name>Ignite</servlet-name>
                        <servlet-class>org.apache.ignite.startup.servlet.ServletStartup</servlet-class>
                        <init-param>
                            <param-name>cfgFilePath</param-name>
                            <param-value>config/default-config.xml</param-value>
                        </init-param>
                        <load-on-startup>1</load-on-startup>
                    </servlet>

  - Ignite started from WAR-file and Ignite instance is accessible only to that web application. Difference with approach described above is that `web.xml` file and all libraries should be added in WAR file without changes in Tomcat configuration files.

  ## Jetty

  Below is Java code example with Jetty API:

       Server service = new Server();

       service.addListener("localhost:8090");

       ServletHttpContext ctx = (ServletHttpContext)service.getContext("/");

       ServletHolder servlet = ctx.addServlet("Ignite", "/IgniteStartup",
            "org.apache.ignite.startup.servlet.ServletStartup");

       servlet.setInitParameter("cfgFilePath", "config/default-config.xml");

       servlet.setInitOrder(1);

       servlet.start();

       service.start();

  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServletStartup()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `destroy()`
    `void` | `init()`
    `String` | `toString()`

    - ### Methods inherited from class javax.servlet.http.HttpServlet

      `doDelete, doGet, 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, wait, wait, wait`

- - ### Constructor Detail

    - #### ServletStartup

          public ServletStartup()

  - ### Method Detail

    - #### init

          public void init()
                    throws javax.servlet.ServletException

      Overrides:
        `init` in class `javax.servlet.GenericServlet`
      Throws:
        `javax.servlet.ServletException`

    - #### destroy

          public void destroy()

      Specified by:
        `destroy` in interface `javax.servlet.Servlet`
      Overrides:
        `destroy` in class `javax.servlet.GenericServlet`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021