The Java technology and WAP development topic has recently been opened up by the Java Development Network, which will focus on the integration of WAP development and Java technology. We will not open up new articles. If you publish WAP-related technologies, please refer to Java technology and WAP development topics.
WAP (Wireless Application Protocal) is an open protocol, which is different from Japan's I-MODE, which is closed. In fact, WAP is the combination of wireless networks and Internet networks. Originally, wireless networks primarily carry voice services, while Internet data services are already very mature. The application of data services in wireless networks promotes the formation of WAP. You can even think that WAP is a lightweight HTTP protocol tailored for wireless networks.
As a developer, we should understand the working principle and programming mode of WAP. If you have Web application development experience, it will be easier to understand. In fact, it is a B/S model. The browser here is not a traditional browser, but a user agent on the WAP device. It can also be understood as a WAP browser. The server is a general Web server. You can use IIS, Apache, or other Web servers, because HTML is not suitable for transmission on wireless devices with tight resources, we use the WML language on the server. In fact, when a user accesses the network through a wireless device, the request must first go through the WAP Gateway. The WAP gateway will encode and decode the data and then send the data request to the web server, the processed data is sent to the mobile phone after being decoded by the WAP Gateway. This is transparent to programmers. You only need to manage the server code. The following figure will help you understand this programming model. If you want to learn more about WAP, we recommend you read a book titled mobile internet and WAP technology. although not speaking deeply, it is clear.
Since our server can use a general web server, here I use tomcat5.0 as a Web server, first you need to download tomcat5.0 from the http://www.apache.org and install. Assume that the installation path is C: omcat 5.0. Set in Environment Variables
Catalina_home = C: omcat 5.0. Set java_home = C: j2sdk1.4.2 _ 03. Go to the catalina_home/bin directory and run startup to start Tomcat. The default port is 8080. Open the browser and enter http: // localhost: 8080 in the address. If you see the Tom Cat, the installation is successful. Tomcat supports WML. If not, modify catalina_home/CONF/Web. xml. Add the following content in the mime ing section:
<Mime-mapping>
<! -- WML source -->
<Extension> WML </extension>
<Mime-type> text/vnd. WAP. WML </mime-type>
</Mime-mapping>
<Mime-mapping>
<! -- Compiled WML -->
<Extension> wmlc </extension>
<Mime-type> application/vnd. WAP. wmlc </mime-type>
</Mime-mapping>
<Mime-mapping>
<! -- WML script source -->
<Extension> WMLS </extension>
<Mime-type> text/vnd. WAP. WMLScript </mime-type>
</Mime-mapping>
<Mime-mapping>
<! -- Compiled WML script -->
<Extension> wmlscriptc </extension>
<Mime-type> application/vnd. WAP. wmlscriptc </mime-type>
</Mime-mapping>
You can also add index. WML In welcome-list as the default access page.
<Welcome-file-List>
<Welcome-File> index. WML </welcome-File>
<Welcome-File> index.html </welcome-File>
<Welcome-File> index.htm </welcome-File>
<Welcome-File> index. jsp </welcome-File>
</Welcome-file-List>
In this way, the server can be used to develop WAP applications.
During program debugging, We need to debug the program on the WAP browser. I chose the winwap browser as the development and debugging tool, which is very convenient to use. First download the latest winwap 3.1pro version from the http://www.winwap.org, 30-day trial. The installation is the same as the installation of other applications. Next we will compile a simple WML file to test the advanced usage of WML and WML script in subsequent articles.
Index. WML
<? XML version =/"1.0/"?>
<! Doctype WML public/"-// wapforum // dtd wml 1.1 // en /"
/"Http://www.wapforum.org/DTD/wml_1.1.xml/">
<WML>
<Card id =/"myfirstcard/" Title =/"first card/">
<P align =/"center/">
Hello www.j2medev.com
</P>
</Card>
</WML>
Put this file under catalina_home/webapps/root/. After winwap is started, enter http: // yourip: yourport/index. WML in the address, and you will see hello www.j2medev.com in winwap.
If you have a mobile phone that is embedded with a WAP browser and can access the Internet, you can also test it. I used nokia6108 to test the success. I hope this building environment will be helpful to you.