Article Title: WAP development entry-Build a Development Environment
Author: mingjava
Last Updated: 15:34:35
Clicks: 56 "href =" http://www.j2medev.com/Article_Show.asp? ArticleID = 76 "target =" _ blank "> get started with WAP Development -- This article describes how to build an WAP development application, this article describes how to use Java to develop WAP applications.
We still use Tomcat as the Web server. If you are not familiar with how to use tomcat, see asklxf.
Last Updated: 18:34:59
How many clicks: 32 "href =" http://www.j2medev.com/Article_Show.asp? ArticleID = 78 "target =" _ blank "> Tomcat Getting Started Guide. We usually write WML scripts when developing WAP applications. In fact, we can use Java Servlet/JSP technology to develop WAP applications. I usually use the lomboz plug-in to write Servlet/jsp files in the eclipse environment. First look at the following waptest. jsp file and wapservlet. Java File
<? XML version = "1.0"?>
<! Doctype WML public "-// wapforum // dtd wml 1.1 // en"
Http://www.wapforum.org/DTD/wml_1.1.xml>
<%
Response. setcontenttype ("text/vnd. WAP. WML ");
Out. println ("<WML> ");
Out. println ("<Card Title =/" mobiledate/"> ");
Out. println ("<p align =/" center/"> ");
Out. println ("Date and Time Service <br/> ");
Out. println ("date is:" + new java. util. Date ());
Out. println ("</P> ");
Out. println ("</card> ");
Out. println ("</WML> ");
%>
Package com. j2medev. mingjava;
Import java. Io. ioexception;
Import java. Io. printwriter;
Import javax. servlet. servletexception;
Import javax. servlet. http. httpservlet;
Import javax. servlet. http. httpservletrequest;
Import javax. servlet. http. httpservletresponse;
Public class wapservlet extends httpservlet
{
Protected void doget (httpservletrequest request,
Httpservletresponse response) throws servletexception, ioexception
{
Response. setcontenttype ("text/vnd. WAP. WML ");
Printwriter out = response. getwriter ();
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 =/" mobiledate/"> ");
Out. println ("<p align =/" center/"> ");
Out. println ("Date and Time Service <br/> ");
Out. println ("date is:" + new java. util. Date ());
Out. println ("</P> ");
Out. println ("</card> ");
Out. println ("</WML> ");
}
Protected void dopost (httpservletrequest request,
Httpservletresponse response) throws servletexception, ioexception
{
Doget (request, response );
}
}
These two files implement the same functions and display the current time of the server. The content of our web. XML is as follows:
<? XML version = "1.0"?>
<! Doctype web-app public "-// Sun Microsystems, Inc. // DTD web application 2.3 //" http://java.sun.com/dtd/web-app_2_3.dtd ">
<Web-app>
<Servlet>
<Servlet-Name> wapservlet </servlet-Name>
<Servlet-calss> com. j2medev. mingjava. wapservlet </servlet-class>
</Servlet>
<Servlet-mapping>
<Servlet-Name> wapservlet </servlet-Name>
<URL-pattern>/wapservlet </url-pattern>
</Servlet-mapping>
<Welcome-file-List>
<Welcome-File> index. jsp </welcome-File>
</Welcome-file-List>
<Error-page>
<Error-code> 404 </error-code>
<Location>/error. jsp </location>
</Error-page>
</Web-app>
With lomboz, we can easily publish this application to the webapps directory of Tomcat. Through winwap, we can directly access them through the following two URLs.
HTTP: /localhost: 8088/WAP/wapservlet
Http: // localhost: 8088/WAP/waptest. jsp