Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
HttpPage Struct Reference

Detailed Description

An HttpPage, which is typically created by the CSP compiler, is similar to a Java servlet.

Please see our introduction whitepaper for an introduction to server side scripting using the CSP compiler. See the device control whitepaper for an example of how to manually sub-class the HttpPage class.

The page service function cannot be a virtual C++ function since the code must be compatible with C. You must create a "static C++" callback method, which means that the method has no "this" pointer. The "this" pointer is passed into the static method as the first parameter in the callback function. The "static" callback function in the above code simply typecasts the HttpPage object to a MyPage object and calls the private service method, which has a "this" pointer.

Typical C usage:

struct MyPage
{
HttpPage page;
int myData;
};
void MyPage_service(HttpPage* page,
HttpRequest* request,
HttpResponse* response)
{
struct MyPage* o = (struct MyPage*)page;
if(!request) return; // This example uses caller-owned page storage.
o->myData++;
"<html><body>"
"Number of visits: %d"
"</body></html>",
o->myData);
}
void MyPage_constructor(struct MyPage* o, const char* name)
{
HttpPage_constructor(&o->page, MyPage_service, name);
o->myData = 0;
}
void BA_API HttpPage_constructor(HttpPage *o, HttpPage_Service service, const char *name)
The HttpPage constructor.
BA_API int HttpResponse_printf(HttpResponse *o, const char *fmt,...)
printf is used for sending formatted data to the client.
An HttpPage, which is typically created by the CSP compiler, is similar to a Java servlet.
Definition: HttpServer.h:2656
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:950
This object is used when sending response messages back to the client.
Definition: HttpServer.h:1379
See also
HttpDir

#include <HttpServer.h>

Public Member Functions

 HttpPage (HttpPage_Service service, const char *name)
 The HttpPage constructor. More...
 
 ~HttpPage ()
 The HttpPage destructor unlinks the page from the parent directory. More...
 
const char * getName () const
 Returns the page name. More...
 
void service (HttpRequest *request, HttpResponse *response)
 The virtual service function (C callback function) is normally run by the parent directory when delegating the request to the page service method. More...
 
bool isLinked ()
 Returns true if this page node is installed into a parent directory. More...
 
int unlink ()
 Unlinks/removes the page from the parent directory. More...
 

Member Function Documentation

◆ getName()

const char * HttpPage::getName ( ) const

Returns the page name.