Red5 Documentation

Red5 Pro Basic Java

Most developers can understand the nature of an Internet page address such as example dot com , slash help (i.e. This ‘path‘, ‘URL‘ or the ‘URI‘ of when opened in a browser causes the web server to send you the contents of some file on disk.

While the server is reading this file and before it sends it to you, there may be scripting which causes the server to process data. This could be anything that you experience on the web today that is even minor in complexity. The more advanced things the server may do are process credit card transactions, send and receive email, and literally everything else that cannot be done with JavaScript provided on the HTML page.

So how does Java do it?

Java servers — as with many other servers — begin this process by designating a specific directory on disk to be the base ‘path‘, ‘home‘, ‘root‘ , or ‘top-level‘ of the website (ie,


Red5 uses a directory named ‘webapps‘. Each folder in this directory represents a different ‘path‘, generally by the literal name.
A folder named ‘help‘ in the /webapps directory would resolve to this Internet address:

Defining and locating the files to be served from within the /webapps/help directory is where Java is different from other servers.

WEB-INF & web.xml

Inside an application directory under /webapps – eg, /webapps/help – there is another folder named ‘WEB-INF‘. The WEB-INF directory contains a file named web.xml which specifies exactly how a Internet ‘path’ is linked to files.

These are examples of ‘paths’ which would be defined as a mapping from the browser’s Internet request for a particular page, to the files containing Java code the server will execute.

Of course, Java will also serve static files from the application folder if they exist. Putting a stylesheet, js file, or image file right into the example ‘help’ directory for linking in web pages is easy:


The following describes the different type of ways to use Java to deliver content.


Java Server Page (JSP) files are ‘just-in-time’ compiled when a browser request is made for its path. They are accessed by the browser just like any other html document but use the .jsp extension (eg, and allow the browser page to run dynamic content.


By extending the HTTPServlet class provided in the Java SDK, you can link Java code execution to an Internet path. Through configuration of web.xml, you define the path to associated with the servlet which will respond to HTTP requests.

Jars and Class files

All other Java code is compiled before deploying it on the server, and typically the web path linked to specific classes at server start up.

There are two ways to deploy compiled Java code to a Java server:

  • JARs
  • Class files

First thing to know: Java files turn into Class files. ->(compiler creates new file)->operation.class


Java ARchive (JAR) are zip files full of compiled Java classes and any additional resource files. These can be found in two locations in relation to the current webapp application being accessed:

  1. At the same level of the /webapps directory containing all the potential Internet paths, is a /lib directory
  2. Inside the application’s /WEB-INF/lib directory

The Java server loads these resources into memory before it starts accepting Internet requests.

Class files

The second way to put Class files onto a Java server is to put them directly in a folder named ‘classes‘ in the application’s /WEB-INF directory. The web.xml file will declare Java classes as request handlers, and also declare the Internet paths that the request handlers are responsible for.

Red5 Server

The Red5 Java server has one additional file, red5-web.xml, which defines how Internet requests map to Java files too. It differs from the web.xml file in that it defines the Internet paths that start with the ‘RTMP‘ and ‘RTSP‘ protocols instead of ‘HTTP‘.


The RTMP protocol is widely used for communication with a Flash-based client.

The Flash Player API provides a different communication context than that of requesting information over HTTP. Typically, an HTTP request uses ‘slashes’ to point to and endpoint to access information using a request (eg, In using RTMP for requests, the service path uses dot-notation: service_name.service_method. Red5 uses red5-web.xml to map Java class objects with service names, and the public methods of that Java class object are the potential service methods the flash client can use.

Java based data objects are neatly passed to flash clients over RTMP, and then interpreted as Flash objects.


The RTSP prototocol is used by mobile (ie. iOS, Android) clients to connect to RED5.