How do I load the page for a jad file into a servlet?

I have a java me application and now I want to host this application on a server. I want to write a download page with a servlet. I mean, when the custom keys in the url of the servlet and get into this servlet, my jad file will send to the phone (the user doesn't need to click to load the button or link. After the page loads, the servlet will automatically send the jad file to the requested mobile.).

I tried with this code.

> File exportFile = new File("C:\\Voice.jad");
> response.setContentType("text/vnd.sun.j2me.app-descriptor");
> response.setContentLength((int)
> exportFile.length()); 
> response.addHeader("Content-Disposition",
> "attachment; filename=" +
> exportFile.getName()); 
> OutputStream os= response.getOutputStream(); 
> InputStream is = new FileInputStream("C:\\Voice.jad"); 
> while (is.available() > 0)  { char c =
> (char) is.read(); 
>     os.write(c); }    
>     os.flush(); 
>     is.close();

      

and I tried to download the app from Nokia Series 40th 5rd edition emulator. It shows information about the jad file and tries to install. But on the way to install it said that the jar file does not exist.

I don't know how to move on. Please give me information or samples. How can I write a download page for a java me application into a servlet?

Thank you, Regards

0


source to share


2 answers


you have to add a bunch of other lines that usually go in a jad file;)

in this example below the jad and jar files are in the same directory. if they are not in the same directory, you must specify the MIDlet-Jar URL, either the relative path to the jad file or the absolute path to your jar file. I mean it should be a complete url - http://yourserver.com/some/path/your.jar



MIDlet-1: BiteTravel, i3.png, main.MainMidlet
MIDlet-Icon: i1.png
MIDlet-Jar-Size: 109855 //this is very important -- jar size must match this number!
MIDlet-Jar-URL: BiteTravelBite.jar
MIDlet-Name: BiteTravel
MIDlet-Vendor: Bite
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-2.0

      

+1


source


I guess the problem is with the content of the jad file - the path to the jar file should be invalid.



Besides, phones are often quite picky about the jad file format - line order, newline character, etc.

0


source







All Articles