Where to deploy the jar/class file for calling a java class from ssjs

R

Rajesh

Hi,
I am using iplanet webserver 4.1. I want to call a java class from
ssjs file. But I am not getting the result. I have created a java class
file and put it in the folder <Server>\Netscape\Server4\bin\https\jar
folder. But I am not sure whether it is the right location to put the
class file. Also I would like to know how to put the class file in jar
format. The Java file and the ssjs file code given below.

Java part
package pdfbase;
import netscape.javascript.*;

public class Testcase {


public Testcase(){}

public int getValue()
{
return 1;
}

}

Javascript part
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">


<SERVER>
write('<HTML>');
write('<HEAD>');
write('<TITLE>Call 3 Java</TITLE>');

write('</HEAD>');
write('<BODY>');
write('<form name=form1>');
write('<h3>Javascript calling java</h3><br>');
var sObj = new Packages.pdfbase.Testcase();
var iVal = sObj.getValue();
write('<b>'+iVal+'</b>');
write('</form>');
write('</BODY>');
write('</HTML>');
</SERVER>
 
T

Thomas 'PointedEars' Lahn

David said:

Read again. The OP wants to call a Java class from JavaScript which
is generally entirely possible and IMNSHO quite on-topic here since
the required features have been and still are part of the JavaScript
language. Look into Netscape LiveConnect for a start.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Rajesh said:
I am using iplanet webserver 4.1. I want to call a java class from
ssjs file. But I am not getting the result. I have created a java class
file and put it in the folder <Server>\Netscape\Server4\bin\https\jar
folder. But I am not sure whether it is the right location to put the
class file.

Should be explained in the server documentation, but as the file is
currently not in JAR/ZIP format, most likely it is wrong in ...\jar.
Also I would like to know how to put the class file in jar format.

AFAIK .jar is but a ZIPped version containing the .class file.
Ask about this in a Java newsgroup.
The Java file and the ssjs file code given below.

Java part
package pdfbase;
import netscape.javascript.*;

public class Testcase {


public Testcase(){}

public int getValue()
{
return 1;
}

}

Javascript part
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">

The proper DOCTYPE declaration for HTML 3.2 is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

HTML 3.2 is somewhat outdated (but not obsolete),
you should declare HTML 4.01 instead:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<SERVER>
write('<HTML>');
write('<HEAD>');
write('<TITLE>Call 3 Java</TITLE>');

write('</HEAD>');
write('<BODY>');
write('<form name=form1>');
write('<h3>Javascript calling java</h3><br>');

Up to here you don't need the write() method and the code needs
not to be enclosed in the SERVER element. It is static content.
var sObj = new Packages.pdfbase.Testcase();

Try outputting the string-converted value of `sObj' and use exception
handling. Former Netscape DevEdge content is currently temporarily
available at

var iVal = sObj.getValue();

See above.
write('<b>'+iVal+'</b>');

Should always work if the above worked. If the script engine
is ECMAScript 3 compliant, you may want to change this to the
(here) slightly more efficient

write([' said:
write('</form>');
write('</BODY>');
write('</HTML>');

See above. Use the SERVER element only where it is required.
</SERVER>


HTH

PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top