Class SRUServerServlet

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

    public final class SRUServerServlet
    extends javax.servlet.http.HttpServlet
    A Servlet implementation, which provides an environment for running a SRUServer in a Servlet container. Your search engine must use SRUSearchEngineBase as base class.

    Add the following to the web.xml of your web applications web.xml to define a SRU server. Of course, the value of the Servlet initialization parameter "eu.clarin.sru.server.utils.sruServerSearchEngineClass" must be adapted to match the name of your search engine implementation. Furthermore, you can choose different url-pattern, to match your needs.

    For example, if your implementation of SRUSearchEngineBase is "com.acme.MySearchEngine" and you want to map the Servlet to the URI "/sru" the following snippet in your "web.xml" should accomplish the task:

     <servlet>
       <servlet-name>SRUServerServlet</servlet-name>
       <servlet-class>eu.clarin.sru.server.utils.SRUServerServlet</servlet-class>
       <init-param>
         <param-name>eu.clarin.sru.server.utils.sruServerSearchEngineClass</param-name>
         <param-value>com.acme.MySearchEngine</param-value>
       </init-param>
     </servlet>
     <servlet-mapping>
       <servlet-name>SRUServerServlet</servlet-name>
       <url-pattern>/sru</url-pattern>
     </servlet-mapping>
     
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()
      Destroy the SRU server Servlet.
      protected void doGet​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Handle a HTTP get request.
      protected void doPost​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Handle a HTTP post request.
      void init()
      Initialize the SRU server Servlet.
      • Methods inherited from class javax.servlet.http.HttpServlet

        doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
      • Methods inherited from class javax.servlet.GenericServlet

        getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
    • Field Detail

      • SRU_SERVER_CONFIG_LOCATION_PARAM

        public static final String SRU_SERVER_CONFIG_LOCATION_PARAM
        Servlet initialization parameter name for the location of the SRU server configuration.
        See Also:
        Constant Field Values
      • SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM

        public static final String SRU_SERVER_SEARCH_ENGINE_CLASS_PARAM
        Servlet initialization parameter name for the class that implements the SRU search engine.
        See Also:
        Constant Field Values
      • SRU_SERVER_CONFIG_LOCATION_DEFAULT

        public static final String SRU_SERVER_CONFIG_LOCATION_DEFAULT
        Default value for the location of the SRU server configuration.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SRUServerServlet

        public SRUServerServlet()
    • Method Detail

      • init

        public void init()
                  throws javax.servlet.ServletException
        Initialize the SRU server Servlet.
        Overrides:
        init in class javax.servlet.GenericServlet
        Throws:
        javax.servlet.ServletException
        See Also:
        GenericServlet.init()
      • destroy

        public void destroy()
        Destroy the SRU server Servlet.
        Specified by:
        destroy in interface javax.servlet.Servlet
        Overrides:
        destroy in class javax.servlet.GenericServlet
        See Also:
        GenericServlet.destroy()
      • doGet

        protected void doGet​(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws javax.servlet.ServletException,
                             IOException
        Handle a HTTP get request.
        Overrides:
        doGet in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        IOException
        See Also:
        HttpServlet.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
      • doPost

        protected void doPost​(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws javax.servlet.ServletException,
                              IOException
        Handle a HTTP post request.
        Overrides:
        doPost in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        IOException
        See Also:
        HttpServlet.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)