|
Techniques for sending WAP Push messages in batch and from database
Introduction Openwave WAP Push Library provides Java APIs that allow developers to send WAP Pushes to any WAP 1.2.1 compliant device. This technical note and companion servlet application describe how to manipulate a MySQL database using select, insert and update operations, and send WAP Pushes in batch to registered subscribers. The sample application allows mobile phone users to register to receive offers from a ficticious online store that sells CDs and DVDs. The administrator of this store can send alerts to all subscribers when special offers and/or news becomes available by using a simple HTML form. Download servletApplication.zip The application is made up of three Java classes: registerWAP.java, sendPush.java, push.java, an HTML front end for sending alerts: alert.html, and two MySQL tables: user and alertText. The "user" table contains the following columns: subscriberID, host (gateway/up.link) name and user name. The alertText table contains a single column: alert text. Note: this sample application is designed to send a WAP Push service indication. For details on how to send WAP Push in other content types, such as Service Load, or Cache Operation, please refer to WAP Push Developer Guide for more information. Let's take a look at the Java classes that make up the backbone of this application:
String subno = request.getHeader("x-up-subno");
String host = request.getHeader("x-up-uplink");
String name = request.getParameter("first");
Step 2: make a database connection and insert subscriber ID, host name and user name to user table. Note that the driver and connection are based on mysql as the back end. This can be replaced with the appropriate JDBC driver for the for the database of your choice.
Class.forName("org.gjt.mm.mysql.Driver");
String url = "jdbc:mysql://localhost:3306/copDB";
Connection con = DriverManager.getConnection (url, "", "");
Statement stmt = con.createStatement ();
stmt.executeUpdate("insert into user values('"+subno+"', '"+host+"','"+name+"')");
Step 3: send the confirmation in WML format back to the user.
alert.html provides an interface for the administrator to send WAP Push to all subscribers. It will allows the administrator to select the type of alter to be sent (Music or DVD), and this will be used for the alert title. It also allows the user to input text to be used in the WML deck that will be refered to when a user recieves and views the WAP Push. When the adminstrator submits the form, sendPush.java is called passing these data with post method.
sendPush sends a WAP Push (service indication) to all subscribers who have registered in the database. The flow of the application is as follows:
push.java is pointed by SI URI. It makes a database connection and retrieves the alert text from alertText table. Then returns the alert text to the client device. |