Class WebSocketServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.eclipse.jetty.websocket.servlet.WebSocketServlet
-
- All Implemented Interfaces:
Serializable
,Servlet
,ServletConfig
@Deprecated(since="2021-05-27") public abstract class WebSocketServlet extends HttpServlet
Deprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.Abstract Servlet used to bridge the Servlet API to the WebSocket API.To use this servlet, you will be required to register your websockets with the
WebSocketServletFactory
so that it can create your websockets under the appropriate conditions.The most basic implementation would be as follows.
package my.example; import org.eclipse.jetty.websocket.servlet.WebSocketServlet; import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory; public class MyEchoServlet extends WebSocketServlet { @Override public void configure(WebSocketServletFactory factory) { // set a 10 second idle timeout factory.getPolicy().setIdleTimeout(10000); // register my socket factory.register(MyEchoSocket.class); } }
Note: that only request that conforms to a "WebSocket: Upgrade" handshake request will trigger theWebSocketServletFactory
handling of creating WebSockets.
All other requests are treated as normal servlet requests.Configuration / Init-Parameters:
Note: If you use the@WebSocket
annotation, these configuration settings can be specified on a per WebSocket basis, vs a per Servlet basis.- maxIdleTime
- set the time in ms that a websocket may be idle before closing
- maxTextMessageSize
- set the size in UTF-8 bytes that a websocket may be accept as a Text Message before closing
- maxBinaryMessageSize
- set the size in bytes that a websocket may be accept as a Binary Message before closing
- inputBufferSize
- set the size in bytes of the buffer used to read raw bytes from the network layer
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description WebSocketServlet()
Deprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract void
configure(WebSocketServletFactory factory)
Deprecated.void
destroy()
Deprecated.Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.void
init()
Deprecated.A convenience method which can be overridden so that there's no need to callsuper.init(config)
.-
Methods inherited from class javax.servlet.http.HttpServlet
service
-
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
-
-
-
Method Detail
-
configure
public abstract void configure(WebSocketServletFactory factory)
Deprecated.
-
destroy
public void destroy()
Deprecated.Description copied from class:GenericServlet
Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. SeeServlet.destroy()
.- Specified by:
destroy
in interfaceServlet
- Overrides:
destroy
in classGenericServlet
-
init
public void init() throws ServletException
Deprecated.Description copied from class:GenericServlet
A convenience method which can be overridden so that there's no need to callsuper.init(config)
.Instead of overriding
GenericServlet.init(ServletConfig)
, simply override this method and it will be called byGenericServlet.init(ServletConfig config)
. TheServletConfig
object can still be retrieved viaGenericServlet.getServletConfig()
.- Overrides:
init
in classGenericServlet
- Throws:
ServletException
- if an exception occurs that interrupts the servlet's normal operation- See Also:
GenericServlet.init()
-
-