Continued from Page 1
Using Perl As with PHP, in Perl too, you first need to send the correct MIME type to the
browser. Here’s how to do it.
print "Content-type: text/vnd.wap.wml\n\n";
print "<?xml version=\"1.0\"?>\n";
print "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML
1.1//EN\"\"http://www.wapforum.org/DTD/wml_1.1.xml\">\n\n";
….. Put your content here…..
Using Java servlets
Dynamic WML documents can be easily developed using Java servlets. Once you
know the WML syntax, building WAP applications using Java servlets can be an
easy task. Just set content type in your class and you can then send WAP tags.
The line
Response.setContentType("text/vnd.wap.wml");
defines the WAP MIME type to the browser. This is followed by
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MobileDate extends HttpServlet {
public void service (HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
To set the content type for your wireless data:
response.setContentType("text/vnd.wap.wml");
PrintWriter out = response.getWriter();
Now, you can write what you would like to display on the user’s screen:
out.println("<?xml version=\"1.0\"?>");
out.println("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML
1.1//EN\"");
out.println(" \"http://www.wapforum.org/DTD/wml_1.1.xml\">");
out.println("<wml>");
out.println("<card title=\"Hello\">");
out.println(" <p align=\"center\">");
out.println("java with wap<br/>");
out.println("</p>");
out.println("</card>");
out.println("</wml>");
}
}
WAP pages are organized as a deck of cards, each card being one display page.
There is a limit to the size of a deck of WAP cards (all that is between <wml>
and </wml>). The size depends on the WAP browser, and should not exceed
the following limits.
| Browser
|
Size
limit |
| UP.Browser 3.2 |
1,492 bytes |
| UP.Browser 4.x |
2,048 bytes |
| Ericsson R320 |
3,000 bytes (approx) |
| Ericsson R380 |
3,500 bytes (approx) |
| Ericsson MC218 |
8,000 bytes |
| Nokia 7110 |
1,397 bytes |
(To be continued next month)
Gaurav Bhatnagar is a WAP project leader at rkmdaes.com
|