Package com.oorian
Class OorianSseHandler
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
com.oorian.OorianSseHandler
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
@WebServlet(name="OorianSseHandler",
urlPatterns="/ooriansse/*",
asyncSupported=true)
public class OorianSseHandler
extends jakarta.servlet.http.HttpServlet
Servlet that handles Server-Sent Events (SSE) connections for Oorian web applications.
OorianSseHandler provides unidirectional server-to-client communication using the SSE protocol. Each HtmlPage can have an associated SSE connection that allows the server to push updates to the client in real-time.
Key Features:
- Automatic association with HtmlPage instances via page ID
- HTTP session awareness for security and state management
- Keep-alive heartbeat mechanism to prevent connection timeouts
- Thread-safe message sending
- Automatic reconnection support (built into SSE protocol)
- Weak references to prevent memory leaks
The SSE URL pattern is /ooriansse/{pageid} where pageid is the
unique identifier of the associated HtmlPage.
- Since:
- 2024
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Handles HTTP GET requests to establish SSE connections.Returns a short description of the servlet.Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, init, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
-
Constructor Details
-
OorianSseHandler
public OorianSseHandler()Constructs a new OorianSseHandler servlet instance.
-
-
Method Details
-
doGet
protected void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException Handles HTTP GET requests to establish SSE connections.Extracts the page ID from the URL path, retrieves the associated HtmlPage, and establishes an SSE connection for server-to-client push updates.
- Overrides:
doGetin classjakarta.servlet.http.HttpServlet- Parameters:
request- The HTTP servlet request.response- The HTTP servlet response.- Throws:
jakarta.servlet.ServletException- If a servlet-specific error occurs.IOException- If an I/O error occurs.
-
getServletInfo
Returns a short description of the servlet.- Specified by:
getServletInfoin interfacejakarta.servlet.Servlet- Overrides:
getServletInfoin classjakarta.servlet.GenericServlet- Returns:
- A string containing "Oorian SSE Handler".
-