You do not need a servlet for this. A servlet is only useful if these files are dynamically generated or not publicly accessible (i.e., these files are not in open webcontent).
The easiest way is to place these files in a public webcontent (where you usually place JSP / HTML files), and configure the appropriate mime mapping in the servletcontainer or webapp file web.xml.
<mime-mapping>
<extension>jad</extension>
<mime-type>text/vnd.sun.j2me.app-descriptor</mime-type>
</mime-mapping>
<mime-mapping>
<extension>cod</extension>
<mime-type>application/vnd.rim.cod</mime-type>
</mime-mapping>
Then the servletcontainer will automatically set the correct content type when the client requests the files directly, for example. http://example.com/file.jad and http://example.com/file.cod .
source
share