Developing WAP applications using Java technology

Source: Internet
Author: User
Tags date current time tomcat
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.