BBJSP Servlet Overview


In BBj 16.0 and higher, the BBJSP framework provides a new type of Servlet that comes with some advantages over the legacy BBjServlet implementation that has subsequently been deprecated.

In situations when you want to take complete control over processing the requests sent to some specific URL, you can write your own servlet do to so. BBJSP Servlets differ from regular BBj Servlets in several ways which are described in more detail below.

What is a Servlet:

A BBJSP Servlet is a BBj class which responds to a particular type of network request—most commonly an HTTP request—and generates the response. The servlet should be mapped to a specific URL within the context and each request received will be sent to your program for processing.

Implementing your servlet

BBJSP Servlet must be implemented as a custom class as in the example below, implementing the following method.

METHOD PUBLIC void service(BBjspServletContext context!)

Deploying a servlet:

Once you have written the basic stub for your servlet you should configure and deploy it. Use one of the following methods to deploy your servlet.

BBJSP Servlet vs BBjServlet

BBj has for a long time allowed you to write Web Servlets, but the introduction of the BBJSP framework brought with it the need for a new way to create and deploy servlets. A BBJSP Servlet has a closer relationship to the underlying Java servlet and, as a result, allows you to keep connections open for delivering things like RSS feeds or streaming data, something that has until now been impossible in a BBjServlet.

A BBJSP Servlet is not the same as a BBjServlet, and there will be a level of migration involved in moving across. BBJSP Servlets use different classes to represent the elements of the HTTP protocol: BBjspWebRequest, BBjspWebResponse, and BBjspWebSession. Although similar to their BBj Servlet counterparts, they are different and not directly interchangeable. A BBJSP Servlet also allows for more concurrent processes, which enables the BBJSP servlet engine to handle heavier loads.


This is a simple servlet that returns simple HTML content.



    REM ===
    REM === You must implement this method as it is the main execution point.
    REM ===
    METHOD PUBLIC void service(BBjspServletContext context!)
        declare BBjspWebRequest request!
        declare BBjspWebResponse response!
        declare BBjspSessionData data!
        request! = context!.getRequest()
        response! = context!.getResponse()
        data! = context!.getBBjspSession()

        s! = response!.getOutputStream()

See Also


BBJSP Servlet

BBJSP Servlet Overview