Home
| | Sitemap
||Page number :10
Programmer's Guide Nokia WAP Server API 1.1 page 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
previous || guide home || next
4.3.1 Server extension sample
The following sample illustrates how integration with existing billing information system can be implemented. The sample code shows how to create a server extension that implements the AccessLogWriter interface and maintains a persistent connection to a billing system. As discussed later [see 5.1], a servlet can initialise persistent connections during the initialisation of the servlet.
import javax.servlet.*; import com.nokia.wap.server.*; import com.bcomp.billing.*;
public class WapService extends GenericServlet, implements com.nokia.wap.server.extension.AccessLogWriter {
// My connection to on-line billing system BillingOnLine billSystem;
public void init(ServletConfig config) throws ServletException
{// create and open connection to actual system billSystem = new
BillingOnLine(config.getInitParameter("SysName"));
billSystem.loginAsRecordCreator(config.getInitParameter("BFo rmat"));
// Get WAPServer interface
ServletContext myCntx = config.getServletContext(); WapServer iServ=(WapServer)myCntx.getAttribute ("com.nokia.wap.server.WapServer");
// Register myself as AccessLogWriter iServ.registerExtensionService( "com.nokia.wap.server.extension.AccessLogWriter", this);
}
// AccessLogWriter methods
public void LogAccess(AccessLogEntry entry)
{if (entry.getWspStatusCode() == 0x20) {
Brecord br=billSystem.createRecord(entry.getUserid());
br.setSelector(GetServiceName(entry.getRequestedUrl())); billSystem.commit(br); } }
String GetServiceName(URL url) { return …; } }
Programmer's Guide Nokia WAP Server API 1.1 page 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
previous || guide home || next