• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1013
  • Last Modified:

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

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
garyshi
Asked:
garyshi
  • 3
  • 3
1 Solution
 
victorliCommented:
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
 
garyshiAuthor Commented:
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
 
garyshiAuthor Commented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
victorliCommented:
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
 
victorliCommented:
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
 
garyshiAuthor Commented:
Hi Victorli,
Thank you. I have got it. Yes, it is same as normal servlet configuration.
Cheers
Gary
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now