Program
We're still using Tomcat as a Web server, and if you're not familiar with how to use Tomcat, please refer to the relevant information. Usually when we develop WAP applications it is a handwritten WML script, in fact we can develop WAP applications with the help of Java servlet/jsp technology. I usually write servlet/jsp files in the Eclipse environment using the Lomboz plugin. First look at the waptest.jsp and Wapservlet.java files below
>
! 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 (" ");
Out.println (" Out.println ("
Out.println ("Date and Time Service
");
Out.println ("Date is:" + new Java.util.Date ());
Out.println ("
");
Out.println ("");
Out.println ("");
%>
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 (" ");
OUT.PRINTLN ("! DOCTYPE WML public\ "-//wapforum//dtd WML 1.1//en\");
Out.println ("\"http://www.wapforum.org/dtd/wml_1.1.xml\">");
Out.println (" ");
Out.println (" Out.println ("
Out.println ("Date and Time Service
");
Out.println ("Date is:" + new Java.util.Date ());
Out.println ("
");
Out.println ("");
Out.println ("");
}
protected void DoPost (HttpServletRequest request,
HttpServletResponse response) throws Servletexception, IOException
{
Doget (Request,response);
}
}
The two files implement the same functionality, displaying the server's current time. The contents of our Web.xml are as follows:
>
! DOCTYPE Web-app Public "-//sun Microsystems, INC.//DTD Web Application 2.3//en" "http://java.sun.com/dtd/web-app_2_ 3.dtd">
Wapservlet
Com.j2medev.mingjava.WapServlet
Wapservlet
/wapservlet
index.jsp
404
/error.jsp
Using Lomboz we can easily publish this application to the WebApps directory of Tomcat, through winwap we can access them directly through the following two URLs
http://localhost:8088/wap/wapseRvlet
http://localhost:8088/wap/waptest.jsp