org.eclipse.jetty.websocket

## Class WebSocketServlet

- java.lang.Object
- - javax.servlet.GenericServlet
  - - javax.servlet.http.HttpServlet
    - - org.eclipse.jetty.websocket.WebSocketServlet

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

      public abstract class WebSocketServlet
      extends javax.servlet.http.HttpServlet
      implements WebSocketFactory.Acceptor

  Servlet to upgrade connections to WebSocket

  The request must have the correct upgrade headers, else it is handled as a normal servlet request.

  The initParameter "bufferSize" can be used to set the buffer size, which is also the max frame byte size (default 8192).

  The initParameter "maxIdleTime" can be used to set the time in ms that a websocket may be idle before closing.

  The initParameter "maxTextMessagesSize" can be used to set the size in characters that a websocket may be accept before closing.

  The initParameter "maxBinaryMessagesSize" can be used to set the size in bytes that a websocket may be accept before closing.

  The initParameter "minVersion" can be used to set the minimum protocol version accepted. Default is the RFC6455 version (13)
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `WebSocketServlet()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `checkOrigin(javax.servlet.http.HttpServletRequest request, String origin)` Checks the origin of an incoming WebSocket handshake request.
    `void` | `destroy()`
    `void` | `init()`
    `protected void` | `service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)`

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

      `doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, 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`

    - ### Methods inherited from interface org.eclipse.jetty.websocket.WebSocketFactory.Acceptor

      `doWebSocketConnect`

- - ### Constructor Detail

    - #### WebSocketServlet

          public WebSocketServlet()

  - ### Method Detail

    - #### init

          public void init()
                    throws javax.servlet.ServletException

      Overrides:
        `init` in class `javax.servlet.GenericServlet`
      Throws:
        `javax.servlet.ServletException`
      See Also:
        `GenericServlet.init()`

    - #### service

          protected void service(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
                          throws javax.servlet.ServletException,
                                 IOException

      Overrides:
        `service` in class `javax.servlet.http.HttpServlet`
      Throws:
        `javax.servlet.ServletException`
        `IOException`
      See Also:
        `HttpServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)`

    - #### checkOrigin

          public boolean checkOrigin(javax.servlet.http.HttpServletRequest request,
                            String origin)

      Description copied from interface: `WebSocketFactory.Acceptor`

      Checks the origin of an incoming WebSocket handshake request.

      Specified by:
        `checkOrigin` in interface `WebSocketFactory.Acceptor`
      Parameters:
        `request` - the incoming HTTP upgrade request
        `origin` - the origin URI
      Returns:
        boolean to indicate that the origin is acceptable.

    - #### destroy

          public void destroy()

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

Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.