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

Discussion in 'Javascript' started by Rajesh, May 1, 2005.

  1. Rajesh

    Rajesh Guest

    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>
    Rajesh, May 1, 2005
    #1
    1. Advertising

  2. 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
    David Dorward, May 1, 2005
    #2
    1. Advertising

  3. 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
    Thomas 'PointedEars' Lahn, May 11, 2005
    #3
  4. 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:JavaScript_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
    Thomas 'PointedEars' Lahn, May 11, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cyril
    Replies:
    2
    Views:
    3,820
    cyril
    Aug 25, 2004
  2. Arnold Peters
    Replies:
    0
    Views:
    544
    Arnold Peters
    Jan 5, 2005
  3. cyberco
    Replies:
    4
    Views:
    3,710
    Roedy Green
    Feb 14, 2006
  4. SteMc

    ssjs create file - I can't do it :(

    SteMc, Nov 29, 2006, in forum: Javascript
    Replies:
    2
    Views:
    80
    SteMc
    Nov 29, 2006
  5. Replies:
    0
    Views:
    66
Loading...

Share This Page