Operating System - OpenVMS
1819908 Members
2469 Online
109607 Solutions
New Discussion юеВ

Java Applet from VMS Web Server

 
SOLVED
Go to solution
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Here's the VMS (smg$) client.

What does a *working* Java example look like?

Cheers Richard Maher
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Last, but not least, the Macro external symbol definitions needed for a successful link of EMP_CLIENT.COB

800 lines of VMS COBOL? A *demonstrable* Java version is probably only 80 lines!

Can you do it?

Cheers Richard Maher
Bojan Nemec
Honored Contributor

Re: Java Applet from VMS Web Server

Richard,

The first problem is (was) that I have no RDB installed on my VMS. So I have rewrite yours example to work with RMS.

When I get some time I will try to write the java example.

Bojan
Bojan Nemec
Honored Contributor

Re: Java Applet from VMS Web Server

Richard,

There are the examples. They are yust this, examples! Need much more to do abbout error handling and similar things. But I have no more time :(

As first there is a class named EmpClient. This class is responsable for all the communication. It is good practice to separate communication and logic from the user interface, for this reason this class does only communication.

You have many options to create the user interface. One is to write it as an applet. In this case all UI will be managed by the applet. The second option is to write a mixed HTML,javascript and java applet(s) UI. And the third option is to mix both options.

I opted for the second option (HTML, javascript and applet).
The second class is EmpApplet. It is responsable to create an EmpClient object and interact with him.

The HTML page has a form with one text input and one select which has no options. When you type some text in the text input a javascript function is called which retrieve the data from the server and populate the select so the user can select one of the users.


Bojan
Bojan Nemec
Honored Contributor

Re: Java Applet from VMS Web Server

The attachment of the previous post is the EmpClient.java code. See the comment in initEmployeeRead method. You must implement one of the two solutions if you want test it. Without this if you type "b" the searching text will be "b"!

Attached to this post is the EmpApplet.java.

Bojan
Bojan Nemec
Honored Contributor

Re: Java Applet from VMS Web Server

And finaly the html code. You have two methods how to integrate the java applet in the HTML code. There is another one for IE but I have no Windows systems on hand (please search the web for solutions).

To test the applet save the java sources to a directory and compile them with javac. Then pack the resulting .class files in a jar named enp.jar. Modify the applet parameters host and port in the html page. Put the .jar,.class and the .html files in a directory served by an web server (in my case the directory was /test/ you can change it).

Hope it will work :)

Bojan
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Hi Bojan,

You're an absolute champion! But you're too quick for me; I was downloading Rdb 7.2 for you last night and when I woke up this morning you'd already finished your example. (I wanted to check with someone at Oracle, but as we're only prototyping a possible solution and not using Rdb for commercial or in-house systems (and even though you apparently don't have a metalink account, you were doing the work for me) I believe it fell under the scope of a valid Oracle Rdb temporary license; but, no matter, you've already done it.)

I'll have to do a lot of manual-reading to fully digest your code (and what is "this" all about?) But it looks great and uses the Init() and Destroy() methods. I do notice that you don't explicitly declare a seperate thread (as in Brian Reiter's previous example eg: Private Volatile Thread, tcpthread, implements runnable etc.) Is this "onchange" and "onkeyup" sort of AST driven? Competition for context?

I was completely surprised that the Cobol ACCEPT didn't consume the CRLF :-( or put one on the DISPLAY for that matter? I was only using Accept/Display as they looked easy to the casual observer and you were initially focused on the readline() method so I thought it was "best-fit". I much prefer the far greater control of the slightly more difficult $qios! The strategy I normally employ for TCP/IP record-bounryless streams is:- read 2-byte header and that record-type will tell you how many more bytes to read. (If it's an "error" message then 3 more ASCII decimal bytes are read to tell you how many more bytes in the error message. (I like the integer.parseinit() stuff) I'd go for BufferedInputStream as well but I'd have to see an example of mark() and available() first, and then what's Java 1.0 or 1.1)

I presume you can declare a Record Structure or some sort of Variant in Java so you can dequeue N bytes from the socket into an Employee Record and then process the individual fields later?

Anyway, that's my Java 101 excersise and reading for this week.

I really do appreciate the help/advice and examples you're giving me on this!

Thanks again!

Cheers Richard Maher

PS. I too like the html->javascript->JavaApplet school of thinking! (Just not sure when explicit threading is required?)

PPS. I'll provide a revised $qio server soon.
Bojan Nemec
Honored Contributor

Re: Java Applet from VMS Web Server

Richard,

First, sorry to be to cryptic in my post abbout RDB. At the time I wrote the post I have just rewrite your example using RMS.

Abbout a separate thread. Maybe it will be better to create a separate thread, in my example the connection is closed when you leave the page (this can be also browser dependend).

The "onchange" and "onkeyup" are events. They are a sort of "ASTs". The "onkeyup" is fired when you release a keystroke on the keyboard and "onchange" is fired when you leave the input and the text was changed. In this example you can ommit the "onchange" event.

Cobol ACCEPT/DISPLAY is good for very simple cases. For more complex communication use $QIO or C binding functions.

Java has no Record Structure (such as known in other languages) but you can store the data in a string or an array of bytes or characters and extract the individual fields later. Or you can create a class and set the properties on fly.

This example was my first attempt to write a html->javascript->JavaApplet. But I opted for this aproach to learn something new ;)

Attached is the modified COBOL example which uses RMS. The file was created with a simple FDL (indexed, 1 key which is also the whole record) and popoulated with a text editor and convert/fdl.

Bojan
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Hi Bojan,

> Abbout a separate thread. Maybe it will be
> better to create a separate thread, in my
> example the connection is closed when you
> leave the page (this can be also browser
> dependend).

I can't stress enough that this is absolutely pivotal/critical/show-stopper functionality for what a lot of people would intend doing!

I have read the documentation for the init(), start(), stop(), destroy() applet methods and if you tell me that in real life that's all crap (or browser dependent) then I'm in big trouble :-(

Are you saying that this is *only* a problem if you're not using a seperate thread?

In your example why is the connection lost when you change pages? Is your client.close()code being called by the destroy() method or is something else closing the socket???

Are you saying that Browser X calls "destroy()" whenever it damn well feels like it?

I'm really, really concerned about this! Please come back with some soothing words :-)

If you say "seperate threads are ok" then that's fine.

> Java has no Record Structure (such as known
> in other languages) but you can store the
> data in a string or an array of bytes or
> characters and extract the individual fields
> later. Or you can create a class and set
> properties on fly.

Again, I will read the manuals but will no crappy null terminators, presumably Java has fixed-lenth strings such as Byte[19] for a 20 byte string? If you set it to "ABC" does it space fill or null fill or doesn't work?

> This example was my first attempt to
> write a html->javascript->JavaApplet.
> But I opted for this aproach to learn
> something new ;)

Then how can you justify the huge consultancy fees that I'm paying you :-)

The good news is, I reakon there are about 200 other people (like me) that are learning from this thread! (So go back and get it right :-)

Cheers Richard Maher
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Hi,

New version of the Rdb server program to use $QIOs instead of accept/display and handle variable length employee names. (And a couple of other things)

Bojan, where are you? I'm on the beach and my wee flippers are flailing madly in the air; I'm floundering :-( For Pete's sake have mercy!

Cheers Richard Maher

PS. RMS friendly version coming up.
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Oops! Here it is. . .
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Here's the new version of VMS Client emp_client.cob to go with the above java_emp.com . . .
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Finally, here's the RMS version of teh server (complete with test file creation)

Download it as Java_emp_rms.com and if you've been following the thread, it's about as self-explanatory as the command file.

Is there really no one in this newsgroup (or HP itself) that can write 200 crappy lines of Java that can talk to this server and put 'em up on their web site?

Do I have to ask in the UNIX or NT ITRC forums?

Regards Richard Maher

Bojan Nemec
Honored Contributor

Re: Java Applet from VMS Web Server

Richard,

Sorry but have no time to work on yours code.

I done some tests with different browsers:
Browser Platform Version Comment
Firefox Linux 1.5.0.8 calls destroy when change page
Netscape Linux 7.1 (very old version) calls destroy when change page
Konqueror Linux 3.0.3-13 (very old version) does not call destroy but the page does not work!
Opera Linux 6.1 (very old version) crash!
Explorer XP 6.0 calls destroy when change page, the page does not work due an javascript error
Opera XP 8.51 does not work due security

(hope this table can be read)

As you see, the destroy method is called in most cases. But you also see that you may have many problems to create an application which will run on an undefined browser.

Bojan
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Hi Bojan,

Thanks for the reply.

> Sorry but have no time to work on yours code.

It's hard to conceive of anything more important that you'd have to do :-)

> I done some tests with different browsers:
: : :
> As you see, the destroy method is called in
> most cases. But you also see that you may
> have many problems to create an application
> which will run on an undefined browser.

It certainly looks grim :-( Are we any the wiser as to exactly why the Destroy() method is being called prematurely and *completely* at odds with *all* the documentation?

Could it be to do with the lack of seperate thread (as discussed previously) and the default thread group being set to null when the page changes? Could it be a browser setting? Could it be SUN just having a laugh at everyone's expense in the docs?

Anyway, thanks very much for your browser table! Armed with these facts I'm off to tackle someone on why this is so. Any ideas for the appropriate newsgroup? comp.lang.java.WHAT? Any browser specific newsgroups that are active?

Cheers Richard Maher
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Hi all,

Just had an epiphany; if, indeed, Destroy()does go all pear-shaped as a browser-shutdown socket-close strategy, then how 'bout this: -

1) We don't use a Destroy() method for the applet at all
2) No explicit call exists to ever close the socket
3) The Init() method simply checks "if not Socket.isConnected()" before trying to connect to the server

At least two questions arise: -

1) Will the Socket *ever* get closed (even when the browser is closed) and the JVM collect the garbage, or will it simply leak resources until the client runs out of sockets or memory?

2) If the page and/or Applet is reloaded will the memory containing the Socket structure be reinitialized and a false negative be returned to isConnected even though the other socket is still there? Public/Private/Static/Session Variables?

Food for thought?

Cheers Richard Maher
Bojan Nemec
Honored Contributor

Re: Java Applet from VMS Web Server

Richard,

I get some time and an idea.

All modern browsers knows frames. You can create a multiframe page and use one frame to store the applet. This frame can be an invisible frame or a frame with a logo and other stuff which is in most cases on the top of every html page.

The other frame (or more than one) is used to display the html contents. This second frame can be changed, reloaded etc....The first frame will not be changed and the socket will not be closed.

Attached are all the sources. I supose that the new server works as the old one, so I tested with the old server. If this is not true the EmpClient.java must be modified.

[ Do I have to ask in the UNIX or NT ITRC forums? ]

Most VMS people is reluctant to use Java on VMS (I am one of them) because it eats resources and is slow on activation . I wrote many lines of code in Java but when the code have to run on VMS I go for other languages.

Bojan
Bojan Nemec
Honored Contributor

Re: Java Applet from VMS Web Server

Ups, forgot the attachment.

Sorry, Bojan
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Hi Bojan,

Once again, thanks for your many replies! I have finally decided to stop asking to be spoon-fed Applets, and have downloaded a JDK and will start trying to implement some of the examples that you (and others) have given me.

I like your suggestion about Frames for an application that wants to change much of the screen without losing context; I on the other hand was looking to preserve some sort of context while the user jumped to unrelated pages and or applications. The latter doesn't appear to be doable (and may be bad from a security point of view anyway, as it (potentially?) opens the socket to exploitation) but, in closing, let me ask you a straight-forward question or two :-)

Q1: Can you create a thread in an Applet and have that thread continue executing after a new page has been displayed. (If it's the usual "Only in browser X on a full-moon" then I'll take it as a "No", otherwise "Why can't that thread own a Socket?")

Q2: An easy one, are there standard GetUsername and GetPassword routines available to pop-up a dialogue box from an Java Applet and return the U&P from the user? I don't want any authentication just the data.

[Most VMS people is reluctant to use Java on VMS (I am one of them) because it eats resources and is slow on activation . I wrote many lines of code in Java but when the code have to run on VMS I go for other languages.]

Bojan, I (and I'm sure *many* others) are 110% behind you on this! But what we need is the best way of connecting the amazing Java front-end with the rock-solid, reliable ang high-performance VMS 3GL back-end. WSIT clearly isn't the solution, and AJAX is there for those who used to use ODBC stored procedures as a poor-man's-RPC, that is, the simple, or path-of-least-resistance, approach. All I want to do is give these hungry developers a simple example of html -> Javascript -> Applet(s) that talk to their VMS servers. And this is what you've already supplied in your previous posts to this thread.

If in my (Tier3's) case the user has to sign-on again if they change pages (and precipitate Socket closure and Applet cleanup then that's just bad luck.

Q3: In comp.lang.java.programmer I saw an example where someone was using Javascipt to dynamically create his Applet tags, so as to get around browser consistency issues. For example: -

On Firefox/Netscape the tag was
On Internet Explorere the tag was
For all others the generated tag was

Is this sort of strategy common place? Have you had to code like this?

[Attached are all the sources. I supose that the new server works as the old one, so I tested with the old server. If this is not true the EmpClient.java must be modified.]

Should behave the same but is much closer to a real-world example and includes RMS data file creation and proper $qio socket interface demo.

Thanks again.

Cheers Richard
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Hi Bojan,

Quick addendum: -

You had to copy the CLASS files as well as the .JAR files because you wrote "achieve" instead of "archive" and achieved little :-)

This "tough-it-out" or "stumble-on-with one-leg" stuff is just not for the faint hearted is it?

Anyway, I'm using IE with your second Applet tag version and am getting "Applet EmpApplet notinited" which has oodles of web references for it :-( Any ideas?

I've taken out the "MAY SCRIPT" as I couldn't find that on SUN's syntax pages.

I know you said that you don't have windows, but leaving bigotry aside, how hard can it be for you or, more importantly, others?

All newbie html-debugging tips welcome!

Cheers Richard Maher
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Hi Bojan,

You're rubbish :-) I posted this on comp.lang.java.programmer but just in case you haven't broken for Christmas here 'tis: -

JAR! . . .What is it good for?. . .Absolutely nothing :-)

Well not quite; actually I love JAR files, but why does the AppletViewer (W2K
SUN JDK "something", at least) insist on asking for the .CLASS file *as well
as* the .JAR file?

Is this *all* applet viewers? *all* html? or just something *my* code is
doing?

Also why are there no hits on "noclassdeffounderror" on SUN's website?

In the attached *very short* code snippet, the EmpApplet class is attempting
to invoke methods in the EmpClient class that has been built into the same
JAR file, but the only Typing that I can see (sorry not my code, but I'm
told this works on UNIX browsers) is: -

EmpClient client;

I'm guessing that this declares "client" as an instance of the EmpClient
class, but doesn't EmpClient have to be Imported or something? Either way,
EmpClient is not "inited" and the -debug gives me the noclassdeffounderror
and the browser makes no attempt to load EmpClient from the codebase.

So, how does one define a class? import?

Yes, I will google tomorrow but it's late and I'm old. . .

Regards Richard Maher

PS. Sorry for the school boy questions, but I honestly am RTFMing as well.

EmpClient Class
===========

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;


public class EmpClient {
public static final String HOSTCHARSET="ISO-8859-1";
public static final byte [] CRLF = {'\r','\n'};
private Socket socket;
private String host;
private int port;
private BufferedReader in;
private OutputStream out;

public class Message
{
String type;
String message;
Message (String type , String message)
{
this.type = type;
this.message = message;
}
public String getMessage()
{
return message;
}
public String getType()
{
return type;
}

}
EmpClient (String host , int port)
{
this.host = host;
this.port = port;
}

public void open () throws UnknownHostException, IOException
{
socket = new Socket (InetAddress.getByName(host) , port);
in = new BufferedReader (new InputStreamReader (socket.getInputStream() ,
HOSTCHARSET));
out = new BufferedOutputStream (socket.getOutputStream());
}

public void close () throws IOException
{
try {
sendMessage ("99","");
} catch (IOException e) {
// close in any situation!
}
socket.close();
}

public void sendMessage (String type , String message) throws IOException
{
byte [] msgtype = type.getBytes(HOSTCHARSET);
byte [] msg = message.getBytes(HOSTCHARSET);

out.write(msgtype);
out.write(msg);
out.write(CRLF);
out.flush();
}
public Message readMessage () throws IOException
{
String wholemsg = in.readLine();

String type = wholemsg.substring(0,2);
String msg = wholemsg.substring(2);
return new Message (type , msg);
}
public void initEmployeeRead (String employee) throws IOException
{
sendMessage ("20" , employee);
}
public String readNextEmployee () throws IOException
{
Message msg = readMessage ();
if (msg.getType().equals("21"))
return msg.getMessage().trim();
return null;
}
}

EmpApplet Class
============

import java.applet.Applet;
import java.io.IOException;


public class EmpApplet extends Applet {
EmpClient client;

public void init ()
{
String host = getParameter("HOST");
int port = Integer.parseInt(getParameter ("PORT"));
client = new EmpClient (host , port);
try {
client.open();
} catch (Exception e) {
client = null;
}
}
public String initEmployee (String employee)
{
try {
client.initEmployeeRead(employee);
return null;
} catch (IOException e) {
return e.getMessage();
}
}
public String nextEmployee ()
{
try {
return client.readNextEmployee();
} catch (IOException e) {
return null;
}
}
public void destroy() {
try {
client.close();
} catch (IOException e) {
}
super.destroy();
}
}

Bojan Nemec
Honored Contributor

Re: Java Applet from VMS Web Server

Richard,

Sorry but I was busy and have no time to work on yours example.
I will try to ansawer your questions:

Q1: Now I am to busy to experiment. But I will try when I get some time.

Q2: There are no standard routines (in Java they are called methods, because they belong to an object). But you can write some javascript code to obtain the username and password and then pass the values to the applet.

Q3: This is a wide used method to get around browser consistency issues. I am reluctant to use this methods and code the javascript for any known browser. So, I try to use javascript at minimum and try to write code which runs on all browsers (many testing on different browsers).

The "archieve" was a typo but all works ok for me (because I copied all the class files to the directory with copy *.* :-). If you modify the html code it works without classes.

Googling I discovered that some browsers need the MAYSCRIPT attribute to allow javascript to interact with the Applet. The parameters "mayscript" and "scriptable" do the same thing in the OBJECT element. (By the way, the APPLET element is deprecated in HTML 4.01). I tested without this attribute and Firefox on Linux and IE on Windows works with and without it.

Why JAR?
Java puts every single class in a separate file (.class). When you compile the EmpApplet.java (javac EmpApplet.java) you will see that you get EmpApplet.class, EmpClient.class and EmpClient$Message.class (if not do: javac EmpClient.java). The applet can run if it has all the class files. If some file is missing you get the ClassNotFoundException!
You can put all the class files in a directory and Java will load them when needed.
As an alternative Java can read JAR files. It is a ZIP file (you can see and extract files from it with unzip). So you can put all the class files in a JAR file and have only one file to distribute. This method is widely used in Java world. The command is:
jar -cf emp.jar *.class
which creates the emp.jar archive. You must be on the directory where the class files are.

So, if you get noclassdeffounderror, not all class files are visible.

[ EmpClient client; ]
[ So, how does one define a class? import? ]

In Java the classes must be imported with the import command. If they are in the same package (package command) they are imported by default. The example classes are all in the default package (no package) so they are all imported by default. Using the default package is discouraged and bad practice. I put the classes in this package because this is an example and to keep the code at minimum.

[ Anyway, I'm using IE with your second Applet tag version and am getting "Applet EmpApplet notinited" which has oodles of web references for it :-( Any ideas? ]
Some things to look at:

Is your browser Java enabled? See under tools->Internet Options->Advanced/Java (Sun) or Microsoft VM or similar.

Are the class files or jar file accessible by http. Yust try to type the whole path in the browser, the file must be downloaded to yours desktop.

If the class files or jar file is served by a VMS system (of course they must be ;-). Were they created on this system or if not were they copied as binary files? You can download the file with the browser and see if there are no differences betwen the original and the downloaded copy.

Was the class files compiled with a Java compiler which has a greather version than the Java which is used by the browser? javac -version to see the compiler version and tools->Sun Java Console in the browser (if you have Sun-s Java, for the Microsoft VM I dont knowh how to see the version). The version in the browser must be equal or greater than the javac version. It is a good idea to have an old Java SDK to compile Applets.

Attached are the revised html pages which were tested on Firefox (Linux) and IE (6.0 Windows). They works on both browsers.

Bojan
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Bojan, Bojan, Bojan, I'm dying here!

I know you've held my hand and spoon fed me and if I can't tie my own shoe laces by now then there's no help for me, but *please* look at what I have done and tell me what I'm doing wrong!

This is Windows 2000 5.00.2195 SP 4 and iexplore 6.0.2800.1106 SUN JDK 1.6.0 (Latest Not beta)

Javac EmpClient.java
Javac EmpApplet.java

/* Maybe I should use the -g switch for debug info as I no longer seem to be able to "stop at EmpApplet:1" in the Appletviewer anymore and the class and archive files seem smaller. */

Jar -cf emp.jar EmpApplet.class EmpClient.class EmpClient$Message.class

Jar -tf emp.jar

// Looks good 3115 bytes for emp.jar

FTP to VMS box 1.2.3.6 type=image

$set file/attr=(rfm:udf) emp.jar

*NOW* If I use the tag I get the classnotfound error and the reason is "socket error unexpected end of file" but I have sent 3115 bytes with your VMS COPY.

So I give up on the applet tag and move to the tag but I can't find a useful syntax diagram on the web and certainly not one with your "verbs/attributes".

In your version you say "
This is what I'm left with: -



<script type="text/javascript">
function empchanged (txt)
{
var selectRef = document.forms[0]["users"];
var optsRef = selectRef.options;
while (optsRef.length > 0)
{
selectRef.remove(optsRef[0]);
}
var val = txt.value;
if (val.length > 0)
{
document.EmpApplet.initEmployee (txt.value);

for (;;)
{
var emp = document.EmpApplet.nextEmployee ();
if (emp == null)
break;
selectRef.add (new Option (emp,emp) , null);
}
}
}
function setemp (sel)
{
document.forms[0]["employee"].value = sel.options[sel.selectedIndex].value;
}
</script>




width= "0" height= "0" >



















This code works with the AppletViewer and connects to my VMS name-lookup server (Which also proves that your mickey-mouse applet uploader is doing it's job) but won't work with the html as I get (depending on which html page I try) document.EmpApplet is null or not an object OR Object does not support this property or method AT document.EmpApplet.initEmployee(txt.value)

I *have* copied the latest and greatest Frames example and I get "null is null or not an object" at test.html aka "parent.frames.appletframe.document is null or not an object"

Bojan, I come to you cap in hand in all humility knowing full well that I am not paying you for this and you have much work to do but *FOR PETE'S SAKE* if this is how hard it is to get a "simple" applet working then no wonder everyone isn't doing it :-(

Please, please, please no frames, missionary position only code that I can compile and run on W2K. There is every possibility that I am an idiot and everyone else can do this, but on the other hand I submit to you that your code will simply not *compile* and run on W2K.

Who cares? You might say; we are *nix biggots and don't care about that blah blah blah, but have a heart will ya? I did give the casual observer a DCL command file that could be just (AT)ed. I'm not asking for that but just change your /test/ to a remote VMS connection or tell me "You're a dickhead and everyone knows that your dickie$path environmental variable must be pointing to /test/ for frame.html to pick up test and test1"

All my wings have been pulled off :-( please don't make me face that prick in comp.lang.java again!

Cheers Richard
Bojan Nemec
Honored Contributor

Re: Java Applet from VMS Web Server

Richard,

I was testing with an Apache web server and put all in a test directory.

Now I tested with my command procedure.
Put the command procedure, all html files and the jar file in a directory. Modify the jar file with : SET FILE/ATTRIBUTES=RFM=UDF EMP.JAR
(as you already did).
Modify the web server procedure with a:
$ SET DEFAULT directory_where_html_and_jar_is
(the procedure does not know anything about directories and works only with a file name, if you want to deal with directories then you must write some code in dcl to create the directory and file name).
Also you can populate the procedure with some write sys$output to see what is going on (in the log file).

The contents of my directory:
Directory SYS$SYSDEVICE:[ALBA.BOJAN.WWW]

APPLET.HTML;17 EMP.JAR;3 FRAME.HTML;10 TEST.HTML;28
TEST1.HTML;3 WWW.COM;18

The contents of the jar file:

$ jar -tf EMP.JAR
META-INF/
META-INF/MANIFEST.MF
EmpApplet.class
EmpClient.class
EmpClient$Message.class
Test.class


There is one class more (Test) which I used at the beginning to test the EmpClient class.
The code is in the attachment and is a command line interface to the EmpClient!

Attached are also two applet.html files which works with the small command procedure web server. I modified the size of the applet to 40x40, so you can open the java console from it when something goes wrong ;)

Please, for now use the html files from my previous post.

Point your browser to: http:VMSHOST:PORT/frame.html

where VMSHOST is the IP of yours VMS and PORT is the port of the web command procedure.

Bojan
Richard J Maher
Trusted Contributor

Re: Java Applet from VMS Web Server

Hi Bojan,

Thanks as always, and especially for the quick response!

I am going to try each of the three Applet Declaration html code options in turn and report back, but I stumbled at the first hurdle with compiling your test.java code: -

C:\Java\Bojan\Applets>javac test.java
test.java:6: invalid method declaration; return type required
main (String [] args)
^
1 error

Hopefully this means something to someone?

I have attached the log from one of the successful emp.jar http copies so that you can see that the 3115 bytes were sent. I had already added the t3$applets directory logical name and I stuck in a loop on the read just in case. As I have said, the archive file works with the "appletviewer -debug empclient.html" and inits the applet by forming a connection to my read-server. But nothing when using IE on Frame.html etc. (What do I enter after it says "VM Started"?

The only other thing I can see that I did differently from you is that I had my html files on the W2K box and was accessing them with either a "file" url or a double-click. I will copy the html files to the VMS box to live with the archive file (as I see you've just said "/" for the codebase) but would it make a difference if I put "http://1.2.3.4/"?

Anyway more to come. A working copy of test.java would be good so that we can narrow it down to either html or javascript.

Cheers Richard.