public abstract class WebSocketServlet extends HttpServlet
To use this servlet, you will be required to register your websockets with the WebSocketServerFactory so that it can create your websockets under the
appropriate conditions.
The most basic implementation would be as follows.
package my.example;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jetty.websocket.WebSocket;
import org.eclipse.jetty.websocket.server.WebSocketServlet;
public class MyEchoServlet extends WebSocketServlet
{
@Override
public void registerWebSockets(WebSocketServerFactory factory)
{
factory.register(MyEchoSocket.class);
}
}
Note: that only request that conforms to a "WebSocket: Upgrade" handshake request will trigger the WebSocketServerFactory handling of creating
WebSockets.
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.
| Constructor and Description |
|---|
WebSocketServlet() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
configure(WebSocketServerFactory factory) |
void |
destroy() |
void |
init() |
protected void |
service(HttpServletRequest request,
HttpServletResponse response) |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, servicegetInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, logpublic void destroy()
destroy in interface Servletdestroy in class GenericServletpublic void init()
throws ServletException
init in class GenericServletServletExceptionGenericServlet.init()public abstract void configure(WebSocketServerFactory factory)
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
service in class HttpServletServletExceptionIOExceptionHttpServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.