?
Solved

How to set up an WAP web server using tomcat ??

Posted on 2003-03-23
6
Medium Priority
?
1,004 Views
Last Modified: 2013-11-24
Hi,
I have downloaded a wap browser emulator called WinWAP browser. Now I can browse the home page of this browser maker by URL below---http://wap.winwap.org/home.wml. It work fine.

I configure a tomcat web server and put some html and wml page under URL: http://localhost:8080/test/wml/index.html and http://localhost:8080/test/wml/first.wml. Now I can use IE5.0 to browe html index page and when I try to use this WinWAP browser to brose my wml page (first.wml)as above, I got error: not wml content and it show all wml sources code on the browser. How to configure tomcat web server so it can suppot wap/wml and I can use wap/wml browser to talk to this server??  When I browse http://wap.winwap.org/home.wml, I connect to internet using dial up modem. Now I have WAP browser and tomcat server at same machine, do I need to cnfigure connection ?? Do I need to consider GateWay and some thing else ?? Thanks for help.
GAry

I copy wml example code as my first.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">
      My First WML Example
    </p>
  </card>
</wml>
0
Comment
Question by:garyshi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 1

Accepted Solution

by:
victorli earned 200 total points
ID: 8192334
Find which web application the "first.wml" belongs to and  add the following to your web application's "web.xml" file,

 <mime-mapping>
    <extension>
      wml
    </extension>
    <mime-type>
      text/vnd.wap.wml
    </mime-type>
  </mime-mapping>

THis will let Tomcat to know that files with ".wml" are "text/vnd.wap.wml" content.
0
 

Author Comment

by:garyshi
ID: 8192619
Hi Victorli,
Thanks for your help. You are right. I have successfully done it. Could you tell me how to configure tomcat for servlet??
If I have a servlet for WAP browser called firstServlet and inside this servlet I need to add line below:
response.setContentType("text/vnd.wap.wml");
Thanks
gary

0
 

Author Comment

by:garyshi
ID: 8192628
Thanks Victorli,
If you know how to configure tomcat for servlet for WAP browser, please let me know. Your help will be appreciated.
Gary
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:victorli
ID: 8192923
Hi garyshi,

To set servlet for wap is exactly the same as the setting for web i.e. servelt configuration in web.xml such as url pattern, security etc are all the same. The only difference are the presentaion layer, in the server side you set the content type as "text/vnd.wap.wml" instead of "text/html", you use wml instead of html language. THen at the client side, it is up to the browser to understand these mime type.

Normally I use jsp pages to do the rendering. So look at the following servlet code automatically generated by Tomcat using my jsp pages.

      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/vnd.wap.wml; charset=ISO-8859-1");
      pageContext = _jspxFactory.getPageContext(this, request, response,
                     null, true, 8192, true);
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("<?xml version=\"1.0\"?>\n");
      out.write("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"\n\"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
      out.write("\n");
      out.write("\n\n");
      out.write("\n\n");
      out.write("<wml>\n  ");
      out.write("<card id=\"findaddress\" title=\"Address Finder\">\n    ");
      out.write("<do type=\"accept\">\n        ");
....

So you may need to do the following in your servlet:
      response.setContentType("text/vnd.wap.wml; charset=ISO-8859-1");
      out.write("<?xml version=\"1.0\"?>\n");
      out.write("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD
....
0
 
LVL 1

Expert Comment

by:victorli
ID: 8192970
Sorry I just checked some example in a book, we should use something like the following:

      response.setContentType("text/vnd.wap.wml"); //first line in the servlet.
      PrintWriter out = response.getWriter();
      out.println("<?xml version=\"1.0\"?>\n");
      out.println("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"\n\"http://www.wapforum.org/DTD/wml_1.1.xml\">\n");
      out.println("\n");
       ....

THe "out" object here is different from the "out" in the jsp. I am sure either way works.
0
 

Author Comment

by:garyshi
ID: 8196968
Hi Victorli,
Thank you. I have got it. Yes, it is same as normal servlet configuration.
Cheers
Gary
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question