[CPPSERV]
[Documentation]
[Download]
[TODO]
[Contact]
[Bug tracker]
[News]
[RSS Feed]
[gitweb]
For API details, take a look at
DoxyGen-generated API documentation.
It is built nightly from
master git tree sources.
Check out quick install instructions from our SourceForge.net space.
Writing servlets
Once you got servlet engine installed, writing servlets is fairly easy.
- Create a class derived from cserv::Servlet
- Add EXPORT_SERVLET(YourServletClassName here) in your source file that defines servlet functions
- Compile your servlet as shared library and link it with -lcserv
- Add your servlet to configuration file:
<servlet name="MyServlet" dso="path/to/MyServlet.so"/>
Writing C++ Server Pages
CSP is a mixture of C++ code and mark-up language (i.e. HTML, XHTML, XML - whatever you like),
that is translated into pure C++ code, and then compiled into CPPSERV servlet, just like any
other.
Steps to get your CSP page going are simple:
- Write your CSP page. Take a look at the simple example
- Translate it into C++:
cxxsp_compile Simple.csp Simple.cpp
- Compile it into servlet:
g++ -shared -lservlet -o Simple.so Simple.cpp
- Add your servlet to configuration file, as usual, perhaps giving
it a name with .csp in the end:
<servlet name="Simple.csp" dso="Simple.so"/>
CSP based store application from samples package contains a script and
set of good Makefile rules to generate servlets and CPPSERV config file
from CSP's.
Web server <-> application server communication
Communication protocol between web server and application server is fairly simple:
- Web server receives HTTP request
- Web server connects to the servlet engine
- Web server sends Servlet name, which it figures out through its own mapping system,
followed by newline character
- Web server sends request line, followed by newline character
- Web server sends request headers, followed by empty line
- Web server sends request body
- Web server shuts down writing side of its socket
- Web server reads servlet output and processes it, just like it would
do with any CGI script
Note: engine and servlet need to be compiled by same GCC version.
Note: written and tested with GCC-3.3.x, and probably will not work with anything earlier
then 3.x. Test results are welcome though.
You are visitor # 44231 since Apr 15, 2005.
