Barracuda Application Server C/C++ Reference
NO
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)
{
MyPage* o = (MyPage*)page;
o->myData++;
HttpResponse_printf(response,
"<html><body>"
"Number of visits: %d"
"</body></html>",
myData);
}
MyPage_constructor(MyPage* o, const char* name)
{
HttpPage_constructor(&o->page, MyPage_service, name);
o->myData = 0;
}
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.
 
const char * getName () const
 Returns the page name.
 
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.
 
bool isLinked ()
 Returns true if this page node is installed into a parent directory.
 
int unlink ()
 Unlinks/removes the page from the parent directory.
 
HttpRequest
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:819
HttpPage
An HttpPage, which is typically created by the CSP compiler, is similar to a Java servlet.
Definition: HttpServer.h:2272
HttpResponse
This object is used when sending response messages back to the client.
Definition: HttpServer.h:1194