By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,501 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,501 IT Pros & Developers. It's quick & easy.

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

P: n/a
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>

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Rajesh wrote:
I am using iplanet webserver 4.1. I want to call a java class from


http://jibbering.com/faq/#FAQ2_2

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #2

P: n/a
David Dorward wrote:
Rajesh wrote:
I am using iplanet webserver 4.1. I want to call a java class from


http://jibbering.com/faq/#FAQ2_2


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
--
Die Amerikaner haben ihre Ausgaben zur Bekämpfung der Armut in der Welt
gerade auf 1,7 Milliarden Dollar reduziert. Das ist nicht einmal so viel,
wie sie in zwei Tagen fürs Militär ausgeben.
-- Eugen Drewermann, dt. Theologe, Februar 2003
Jul 23 '05 #3

P: n/a
Rajesh wrote:
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

<http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Guide:LiveConnect_Overview:Jav aScript_to_Java_Communication>
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(['<b>', iVal, '</b>'].join(""));
write('</form>');
write('</BODY>');
write('</HTML>');
See above. Use the SERVER element only where it is required.
</SERVER>

HTH

PointedEars
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.