Metawerx Java Hosting Small Logo

How to configure Tomcat for WAP/WML

When you access a web page using a normal browser such as Internet Explorer or FireFox, the web server tells your browser what kind of document it should expect. This is done by MIME types. The standard MIME type for a plain HTML document is text/html.

A WAP browser will only accept certain types of content, and these must be configured in the web server so that the correct MIME type is sent.

To configure Tomcat for sending WAP MIME content types, add the following to your <appName>/WEB-INF/web.xml file, between the <web-app> tags:

<!-- Mime type required for WAP/WML: Plain WML documents --> 
<mime-mapping> 
	<extension>wml</extension> 
	<mime-type>text/vnd.wap.wml</mime-type> 
</mime-mapping>

<!-- Mime type required for WAP/WML: WMLScripts --> 
<mime-mapping> 
	<extension>wmls</extension> 
	<mime-type>text/vnd.wap.wmlscript</mime-type> 
</mime-mapping>
<mime-mapping> 
	<extension>wmlscript</extension> <!-- Non-standard extension -->
	<mime-type>text/vnd.wap.wmlscript</mime-type> 
</mime-mapping>
<mime-mapping> 
	<extension>ws</extension> <!-- Non-standard extension -->
	<mime-type>text/vnd.wap.wmlscript</mime-type> 
</mime-mapping>

<!-- Mime type required for WAP/WML: Compiled WML documents --> 
<mime-mapping> 
	<extension>wmlc</extension> 
	<mime-type>application/vnd.wap.wmlc</mime-type> 
</mime-mapping>

<!-- Mime type required for WAP/WML: Compiled WML Scripts  --> 
<mime-mapping> 
	<extension>wmlsc</extension> 
	<mime-type>application/vnd.wap.wmlscriptc</mime-type> 
</mime-mapping>
<mime-mapping> 
	<extension>wsc</extension> <!-- Non-standard extension -->
	<mime-type>application/vnd.wap.wmlscriptc</mime-type> 
</mime-mapping>

<!-- Mime type required for WAP/WML: Wireless Bitmap Images --> 
<mime-mapping> 
	<extension>wbmp</extension> 
	<mime-type>image/vnd.wap.wbmp</mime-type> 
</mime-mapping>

<!-- Mime type required for WAP/WML 2.0: XHTML --> 
<mime-mapping> 
	<extension>xhtml</extension>
	<!--<mime-type>application/xhtml+xml</mime-type>--><!-- Correct MIME for XHTML -->
	<mime-type>application/vnd.wap.xhtml+xml</mime-type><!-- Required for Nokia Series 60 -->
</mime-mapping>

<!-- Mime type required for WAP/WML 2.0: CSS --> 
<mime-mapping> 
	<extension>css</extension> 
	<mime-type>text/css</mime-type> 
</mime-mapping>

<!-- Welcome-pages for WAP, in order of preference, add your own as necessary -->
<welcome-file-list>
	<welcome-file>index.wml</welcome-file>
	<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

Here is a complete, minimal example of a web.xml file for Tomcat 5.5 containing the above. If you are not familiar with web.xml at all, just save the following file as <appName>/WEB-INF/web.xml file to get started.

For example, on your local machine, <jakarta>/webapps/ROOT/WEB-INF/web.xml.

You can then make a file called <jakarta>/webapps/ROOT/index.wml which will show as the default page for your new WAP site.

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
	version="2.4">

	<display-name>My WAP App</display-name>
	<description>
		My WAP Application
	</description>

	<!-- Mime type required for WAP/WML: Plain WML documents --> 
	<mime-mapping> 
		<extension>wml</extension> 
		<mime-type>text/vnd.wap.wml</mime-type> 
	</mime-mapping>
	
	<!-- Mime type required for WAP/WML: WMLScripts --> 
	<mime-mapping> 
		<extension>wmls</extension> 
		<mime-type>text/vnd.wap.wmlscript</mime-type> 
	</mime-mapping>
	<mime-mapping> 
		<extension>wmlscript</extension> <!-- Non-standard extension -->
		<mime-type>text/vnd.wap.wmlscript</mime-type> 
	</mime-mapping>
	<mime-mapping> 
		<extension>ws</extension> <!-- Non-standard extension -->
		<mime-type>text/vnd.wap.wmlscript</mime-type> 
	</mime-mapping>
	
	<!-- Mime type required for WAP/WML: Compiled WML documents --> 
	<mime-mapping> 
		<extension>wmlc</extension> 
		<mime-type>application/vnd.wap.wmlc</mime-type> 
	</mime-mapping>
	
	<!-- Mime type required for WAP/WML: Compiled WML Scripts  --> 
	<mime-mapping> 
		<extension>wmlsc</extension> 
		<mime-type>application/vnd.wap.wmlscriptc</mime-type> 
	</mime-mapping>
	<mime-mapping> 
		<extension>wsc</extension> <!-- Non-standard extension -->
		<mime-type>application/vnd.wap.wmlscriptc</mime-type> 
	</mime-mapping>
	
	<!-- Mime type required for WAP/WML: Wireless Bitmap Images --> 
	<mime-mapping> 
		<extension>wbmp</extension> 
		<mime-type>image/vnd.wap.wbmp</mime-type> 
	</mime-mapping>
	
	<!-- Mime type required for WAP/WML 2.0: XHTML --> 
	<mime-mapping> 
		<extension>xhtml</extension> 
		<!--<mime-type>application/xhtml+xml</mime-type>--><!-- Correct MIME for XHTML -->
		<mime-type>application/vnd.wap.xhtml+xml</mime-type><!-- Required for Nokia Series 60 -->
	</mime-mapping>

	<!-- Mime type required for WAP/WML 2.0: CSS --> 
	<mime-mapping> 
		<extension>css</extension> 
		<mime-type>text/css</mime-type> 
	</mime-mapping>
	
	<!-- Welcome-pages for WAP, in order of preference, add your own as necessary -->
	<welcome-file-list>
		<welcome-file>index.wml</welcome-file>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>

</web-app>

More Information

navigation
metawerx specific
search
Share
tools
help

referring pages

Share