I want to setup a Blackberry OTA downloader using Servlets. How do I set the URL for .jad
and .cod
files? I have set the conten开发者_如何学Got type for both files. How do I send both files to the client when I receive a request from the client? Do I need to create two servlets or is one enough?
You don't necessarily need a servlet for this. A servlet is only useful if those files are dynamically generated or are not directly public accessible (i.e. those files are not in public webcontent).
The simplest way would be to put those files in the public webcontent (there where you would usually place the JSP/HTML files) and configure the appropriate mime mapping in your servletcontainer's or webapp's web.xml
file.
<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 by e.g. http://example.com/file.jad and http://example.com/file.cod.
精彩评论