Search code examples
javahttpred5

Red5: how to handle HTTP?


Red5 is capable of serving HTTP requests. But how can I handle one in my application code ?


Solution

  • Yes, Red5 is capable of handling HTTP/HTTPS requests if you are using one of the Java EE plugins. The Tomcat-based plugin is the default Java EE container. For the second part of your question I assume you want to call one of the methods in your ApplicationAdapter class. To do that from a Servlet or JSP you simply need to access the ApplicationContext and from there get a reference to the ApplicationAdapter like so:
    JSP Example

    
    <%@ page import="org.springframework.web.context.support.WebApplicationContextUtils,
    org.springframework.context.ApplicationContext,
    my.package.MyApplication" %>
    <%
    ApplicationContext appCtx = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
    MyApplication app = (MyApplication) appCtx.getBean("web.handler");
    Object result = app.myMethod();
    System.out.println("Result: " + result);
    %>