How to run dynamically created jnlp?

Hi,

I'm learning how to run a dynamic jnlp file create by a cgi program.

I have a jnlp file, which can be executed by the <a href=....> in the

HTML file. Then my experiment is to write a perl script to print

exactly the same content as the jnlp file, and then the href is

re-directed to the cgi. But Then I got an error complaining

the first line:

Bad header = <?xml version="1.0+" .... ?>

Is there anything else I should add in the header?

Thanks.

[552 byte] By [jackChanga] at [2007-11-26 15:04:08]
# 1

To be more specific about my question, here is the perl script I used

to generate the jnlp file. What should I add to it?

Thanks.

#!/usr/bin/perl

use CGI;

###################################

## Read parameters

$query = new CGI;

$SecID= $query->param("SECID");

$PlayName = $query->param("PlayName");

$PlayFile = $query->param("PlayFile");

$PlayFrom = $query->param("PlayFrom");

$PlayTo= $query->param("PlayTo");

$CodeBase = $query->param("CodeBase");

###################################

# Generating jnlp

print "Content-Type: application/x-java-jnlp-file \n";

#print '<%page contentType="application/x-java-jnlp-file" %>'."\n";

print '<?xml version="1.0" encoding="utf-8"?>'."\n";

print "<jnlp spec=\"1.0+\" codebase= \"$CodeBase\" />\n";

print " <information> \n";

print "<title> $PlayName </title> ";

print "<vender> </vender> \n";

print "<description> </description>

print "<offline-allowed/>

print " </information> \n";

print " <security>\n";

print "<all-permissions> \n";

print " </security>\n";

print " <resource>\n";

print '<jar href="Java/Piano/MidiBox.jar" />'."\n";

print '<j2se version="1.2+"

href="http://java.sun.com/products/autodl/j2se"/> '."\n";

print " </resource>\n";

print ' <application-desc main-class="eng.midi.MidiBoxGUI">'."\n";

print "<argument>-px</argument> \n";

print "<argument>-Ud</argument> \n";

print "<argument>$PlayFile</argument> \n";

if ($PlayFrom)

{

print "<argument>-from $PlayFrom </argument> \n";

}

if ($playTo)

{

print "<argument>-to $PlayTo </argument> \n";

}

print " </application-desc> \n";

print "</jnlp> \n";

jackChanga at 2007-7-8 8:53:47 > top of Java-index,Desktop,Deploying...
# 2

> To be more specific about my question,

That was a good idea. The original question

was too vague for me to bother with.

>...here is the

> perl script I used

> to generate the jnlp file. What should I add to it?

1) The very first thing I suggest is that you make a

'static'* version of this exact file and validate it.

It appears invalid**, even to my casual inspection.

(* Simply fill in some 'typical' values for the actively

generated parts, but try to test as many of the

elements as you can.)

** There is no such element as 'vendEr' - but

validate it, rather than make random changes

and assume it is correct.

2) I don't know Perl, but the one snippet of

information I found, shows a slightly different

form the the content-type command.

http://juicystudio.com/article/content-negotiation.php#perl

- lower case 'c'

- no space between ':' and content-type

- followed by charset

- ends with two returns

AndrewThompson64a at 2007-7-8 8:53:47 > top of Java-index,Desktop,Deploying...
# 3

Hi, Andrew,

Thanks for your suggestion. Actually, the first experiment I had was

to read a working static jnlp file, and print it word by word to stdout

as a response. However, the client complains "Bad Header = <?xml.....". The previous Perl script is then written to show what has

been printed in my previous test (yes, I can see some typo now, but

since it is not at the header part, I think probably the script hasn't even

reach that part yet). So, my question is acutally that

even if I print a working jnlp file, the client side can't seem to interpret

it correctly. So, I think it might be something missing in the header.

About <vender>, I think it is valid but not required field. As for the

format of Contet-Type, I'll experiment more on your suggestions.

Thank you very much for replying my question.

jackChanga at 2007-7-8 8:53:47 > top of Java-index,Desktop,Deploying...
# 4

> About <vender>, I think it is valid ..

Rubbish!

http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/syntax.html#example

Do a find on that document for 'vender'

copy/paste that string and tell me -

which part mentions 'vender'?

Stop making random guesses and start

investigating this problem, one step

at a time, starting with the static JNLP file

that can be validated.

AndrewThompson64a at 2007-7-8 8:53:47 > top of Java-index,Desktop,Deploying...
# 5

Hi, Andrew,

Thanks. Now I know what you mean about <vendOr>. Yes, there was

a typo, but that wasn't in my first test since at first I simply echoed a

valid jnlp file. I did correct all the typos and tried again. I also tried all

the suggestions about the header part, and finally found that the extra

new line after Content-Type does the trick! :)

Thank you very much.

jackChanga at 2007-7-8 8:53:47 > top of Java-index,Desktop,Deploying...
# 6
> Thanks. Now I know what you mean about <vendOr>. Yay!>.. and finally found that the extra new line > after Content-Type does the trick! :)Double Yay! I am glad the problem is solved. :-)
AndrewThompson64a at 2007-7-8 8:53:47 > top of Java-index,Desktop,Deploying...