- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: Java Applet from VMS Web Server
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-25-2006 10:39 AM - last edited on тАО04-11-2017 01:35 AM by Vajith V
тАО10-25-2006 10:39 AM - last edited on тАО04-11-2017 01:35 AM by Vajith V
Hi,
Does anyone have an example of the commands involved in creating and storing a small Java Applet on a VMS system?
I want to be able to activate the Applet from a page in a Web Broswer and link back to the same (or other) VMS server via a TCP/IP socket.
Pointers to the "specific" documentation will also be very welcome.
Below is a bit more detail copied from my post in comp.os.vms.
Regards Richard Maher
1) It looks like you have to create a Java Applet for the Socket stuff. This
seems secure and kosher and de rigueur for everyone outside of the VMS "chip
on each shoulder" brigade. See: -
http://java.sun.com/sfaq/#socket
2) This from some Java Socket discussion page on what the Applet(s) should
contain: -
Creating a client
To talk to a server, open a socket to the machine and port:
Socket s = new Socket("mastercard.com", 303); // port 303
When this returns, you can get input/output streams:
OutputStream out = s.getOutputStream();
PrintStream pout = new PrintStream(out);
pout.println("hi from java client");
pout.close();
s.close();
The client's input stream is pulling from the server's output stream and
vice versa.
3) See the following link for a COBOL example of an INETd server listening
on port# 303. The truly amazing bit about this example is that it shows a
VMS server participating in a ACID proof 2PC with a transaction started on a
W2K server! But let's ignore that for the moment and concentrate on the
simple message passing mechanism. What could be easier than this: -
https://community.hpe.com/t5/General-Feedback-and-Suggestions/New-Forum-Locations-by-ITRC-Tree/td-p/4802433
Please look at my COBOL code in this thread as an example of how easy it
would be to fire-up your existing COBOL functionality from a Web client.
I don't think I'm going out on a limb here to ask "What could be easier?".
Many people here are all pushing their own barrows with
Python/CGI/OSU/Apache but, if you find that (for whatever reason) you are
unable to locate the skill level in this, or any other forum, to show you
how to build a simple Java applet then I guess that you'll have to resort to
your clients support contract :-( I'm available for free to help you out
with any trouble on the VMS side
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-25-2006 07:20 PM
тАО10-25-2006 07:20 PM
SolutionHow much detail do you want?
From my experience you'll need to build the applet code and convert it into a java archive (.JAR) file. Under VMS this is a case of starting the Java environment and running the commands:
javac class.java
jar cvf class.jar class.java
Something like eclipse could be used on a PC as this provides far better debugging support for java.
Once you have the applet it should be just a case of embedding it within the HTML page:
And making sure its in the location reference by the HTML.
In our code we pass the port number to the applet so that it can talk back to the applications.
According to the docs. the applet should only try to talk back to the host WebServer.
cheers
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-25-2006 07:34 PM
тАО10-25-2006 07:34 PM
Re: Java Applet from VMS Web Server
Write your applet and copy the class files or a jar file containing all classes in a directory served by a Web server. Create a html file with an
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2006 12:24 AM
тАО10-26-2006 12:24 AM
Re: Java Applet from VMS Web Server
Thanks for the replies!
> How much detail do you want?
Ideally Brian, I will give you the spec of a simple server that will take a Surname from a Web page via a TCP/IP socket and retrieve all Employees from the mf_personnel.employees table and Send them back on the very same socket to populate the web page with the list of matching employees.
Would you be interested? Should I go ahead and code the VMS server side now? I'll give you numerous beers :-)
> In our code we pass the port number
> to the applet so that it can talk back
> to the applications.
So are you already doing this in production? Are the pages and applets publicly accessible?
> According to the docs. the applet should
> only try to talk back to the host
> WebServer.
Then Bojan said: -
> The Java Applet security forbids opening
> sockets to another server! So you can
> open a socket only to the server from
> which the applet was downloaded.
From the following at the Sun website that I referenced: -
[How can an applet open a network connection to a computer on the internet?
Applets are not allowed to open network connections to any computer, except for the host that provided the .class files. This is either the host where the html page came from, or the host specified in the codebase parameter in the applet tag, with codebase taking precendence.]
Can the host "specified in the codebase parameter" not be different to the host from which the Applet was downloaded?
Thanks for the tutorial reference. I've got some reading to do.
I especially liked the Initialize and Destroy methods!!! Absolutely designed for opening a socket and tearing it down!
Why isn't everyone doing this? IPsec is around the corner but VPNs and intranets have been here for years.
> Abbout "What could be easier?"
I concede fully that your example is easier. The contrast I was attempting to draw was with CGI scripting, Web Services etc etc.
In my AUXS example I now have a working socket that can be PEEKed but yours is about as easy as you can get.
In real life the server will be a AST multi-threaded Listener that will allocate work to a farm of Execution Server processes. Please see attached document for what we've been doing from PCs for years but would now like to do from a Web Browser.
Thanks again!
Cheers Richard Maher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2006 01:01 AM - last edited on тАО04-11-2017 01:37 AM by Vajith V
тАО10-26-2006 01:01 AM - last edited on тАО04-11-2017 01:37 AM by Vajith V
Re: Java Applet from VMS Web Server
Do you want to stick to Java, or another way is possible ?
Have you seen at http://www.vmspython.org/doku.php
all the stuff about Webware for Python ?
It may be compared to Ruby on Rails, using Python instead of Ruby, and lighter.
Watch the video installation
http://www.vmspython.org/doku.php
and see how easy it is to have some basic forms
Have a look at Cheetah - The Python-Powered Template Engine
and the demonstrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2006 01:14 AM
тАО10-26-2006 01:14 AM
Re: Java Applet from VMS Web Server
If you goal is an AST-based server, there is likely no need to have separate worker processes to do the name lookups. For RMS, these can also be AST based.
If you are using a database system that does not interact well with multiple AST threads, then a single worker thread for the database (which then hands things back to the AST based code) will likely do the trick.
In short, before going to the effort of implementing worker processes, I would carefully check if they really help. In many cases, the transaction volume just does not justify the effort.
- Bob Gezelter, http://www.rlgsc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2006 01:32 AM
тАО10-26-2006 01:32 AM
Re: Java Applet from VMS Web Server
I wish it was publicly available, we've been trying to get our client(s) past the prototype phase (they're government based and as such have far too many commitees and consultants in the mix).
Have you considered plain CGI scripting via a WebServer? We use WASD and a mix of DCL and VMS executables (Pascal based) to dip into the system and recover and format reports etc for our prototype system.
In our case the Applet is used to display an overview of the system status, the sole purpose of which is to let remote engineers know at a glance of something external to the system is broken.
FWIW I've attached a very much cut down and canabalised version of the applet. It creates a thread to look after reads on the socket. Its easy enough to do in Java (although editing and compiling java under VMS is a pain :) )
cheers
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2006 01:52 AM
тАО10-26-2006 01:52 AM
Re: Java Applet from VMS Web Server
Hope it works out at your site.
Cheers Richard Maher.
PS. CGI is insulating tape and fencing-wire! It is to middleware what ODBC Store-Procedures were to Remote Procedure Calls. Still we're all doing Web-Services now anyway (not) catch-up :-)
Good luck with those WS-AT transactions BTW.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2006 02:18 AM - last edited on тАО04-11-2017 01:39 AM by Vajith V
тАО10-26-2006 02:18 AM - last edited on тАО04-11-2017 01:39 AM by Vajith V
Re: Java Applet from VMS Web Server
Richard,
[Can the host "specified in the codebase parameter" not be different to the host from which the Applet was downloaded?]
No, the Applet is downloaded from the host specified in codebase.
I have just try to point the codebase to another server. This works. So the host from which the applet is downloaded can be a different host from which the html was downloaded.
You can owercome this problem with two solutions:
1) Create an intermediate TCPIP service on the host which is serving the Applet. This service is then responsable to contact other servers and relay the data flow from the Applet to the server and vice versa.
2) You can modify the Applet security or create a so called "signed Applet". See this nice (and short) tutorial:
www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2006 11:01 AM
тАО10-26-2006 11:01 AM
Re: Java Applet from VMS Web Server
Thanks for the reply.
[I have just try to point the codebase to another server. This works. So the host from which the applet is downloaded can be a different host from which the html was downloaded.]
Excellent! So if I understand you correctly, Any (socket) connect from the applet has to go to where the original html page was downloaded from *or* where the applet is downloaded from (if different).
Is that correct?
If so, what protocol, does the original html server use when accessing the codebase server to download the applet? More straight html on 8080? I'd just like to know what infrastructure is reqd on the "Applet Hosting or Codebase" server.
(Or does the client Web Browser seek the applet from the codebase directly and not via the original html hosting server?)
Not knowing what exactly the "codebase parameter" is I was rather hoping that I could have had a html server, html page, and Java applet on a UNIX server but be able to point the codebase to my VMS server for Socket connection rules. Can you please confirm that I have understood you correctly and that this is *not* possible?
I do appreciate that you have given me alternatives such as Applet signing.
But let me also check that this works: UNIX Server, hosting html Web-Page with codebase pointing to a VMS (presumably html Web?) server hosting the Applet which can subsequently socket connect back to the VMS server from the Applet running in the context of the clients browser?
Thanks again!
Cheers Richard Maher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-26-2006 06:48 PM
тАО10-26-2006 06:48 PM
Re: Java Applet from VMS Web Server
[Excellent! So if I understand you correctly, Any (socket) connect from the applet has to go to where the original html page was downloaded from *or* where the applet is downloaded from (if different).]
That is correct.
The protocol is http so you need a http server on the VMS system. The codebase parameter is an URI which is the base path to the served directory where the classes or jar are located . The browser will download the classes to the local cache and run the applets.
My test was done with the html page served by a Linux system and the Applet was served on a 7.3-2 VMS with SWS (Apache) server. The test was with a sample hello world applet which has not socket connect, but I think that this will run.
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2006 01:19 PM
тАО10-27-2006 01:19 PM
Re: Java Applet from VMS Web Server
Thanks for persisting with this! Please stay with me as a couple more questions and I think I'm done.
[The protocol is http so you need a http server on the VMS system.]
Please correct me if I'm wrong, but a quick flick thru the SUN website sugested that "a" protocol was http but another quite valid protocol was ftp. Would it be possible for you to try it out?
And if you specified the applet url as something like "ftp://1.2.3.4:303/blah" then, conceivably, you could have a slimmed-down, lightweight, super-duper applet-downloader on port 303. That get's by talking only Restaurant-FTP.
So, questions: -
Q1: Can FTP be used as the protocol to download an applet from a server (in this instance) that is different to the original http server that delivered the driving web page? In which case, that second server has absolutely no *need* to be running a web server at all?
Q2: Where does the "get applet file" (ftp or http) request come from? (a) The http server that hosted the original webpage? or (b) the clients web browser itself?
I believe this to be quite important and can see a lot of security plusses in the answer being "a" but have a gut feeling it's going to be "b". Please advise.
Q3: I know I've used up a bit of your time Bojan, but if you could go as far as testing the Socket and Connect methods it would absolutely make my day!!! I do pay beer as well as points :-)
Q4: Given that an applet does *not* call out to any platform specific plug-ins, would it not be *possible* to develop your applets on any JDK environment/machine of your choice, archive them up into a .JAR file and finally, just copy them to the VMS server location that the Web clients will download them from. That is, such .JAR files are architecture neutral aren't they? If you prefer the UNIX or Windows versions as your development environment then go crazy, and just deploy them to the VMS box when compiled/archived. No JDK required on VMS?
Ok, those are the questions and I love Bojan's answers because he doesn't rabbit on about firewall considerations or how IPsec isn't here (*just*) yet, or the relative performance of each method/protocol. I know he's thinking about it and so am I, but he answers the question that I have asked. If there are others that would like to reply but can't restrain themselves to this philosophy then I am more than willing to listen to your pontificating *BUT ONLY AFTER* you have answered my questions.
This thread is being viewed by, and is helping, a lot of people so please show it some respect.
Cheers Richard Maher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-01-2006 07:41 PM
тАО11-01-2006 07:41 PM
Re: Java Applet from VMS Web Server
Sorry for a late ansawer but I was on short vacancies.
Q1: Ok, ftp is also supported. I changed my previous test htmlcode to:
codebase="ftp://bojan:PASSWORD@1.2.3.4"
put the jar file in my sys$login directory, the html was served by a Linux machine and all works ok.
Q2: shortly "b". The applet code is downloaded by the browser.
Q3: I will try to find a hour or two to write a simple applet. But I thonk that willwork as is described.
Q4: Absolutly right. My test was developed on a Linux desktop and only the jar was transfered to the VMS box. The beauty of JAVA code is that is platform independent.
Just a word abbout using ftp or http. Ftp protocol is quite complicated so harder to implement. You can implement a very simple http server in some lines of code.
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-01-2006 09:55 PM
тАО11-01-2006 09:55 PM
Re: Java Applet from VMS Web Server
> Sorry for a late ansawer but I was on
> short vacancies.
No problem! I owe you several beers already and I wish I could post more points.
> Q1: Ok, ftp is also supported.
This is great news for those you don't want or need a VMS web server and its baggage on their application server boxes. Just the applets!
(Obviously, in the interim before my wonder "Applet Loader" arrives :-)
> Q2: shortly "b".
Oh well. Thought as much.
> Q3: I will try to find a hour or two to
> write a simple applet. But I thonk that
> willwork as is described.
I would really appreciate it if you could, Bojan! It would mean a lot to me and I'm sure many others. I do have an "Ideal" (yet still small) example in mind, but anything at all will be welcomed with open arms!
> Q4: Absolutly right. My test was developed
> on a Linux desktop and only the jar was
> transfered to the VMS box. The beauty of
> JAVA code is that is platform independent
You gotta love that!
> Just a word abbout using ftp or http.
> Ftp protocol is quite complicated so
> harder to implement. You can implement
> a very simple http server in some lines
> of code.
Interesting (and timely!) advice. I would've thought that FTP would have been the far easier and function-poor/light-weight protocol. The "TIP://" protocol has to be about as clear and straight-forward as it gets, but I will focus on http next.
Thanks again.
Cheers Richard Maher
PS, For those following this there is also a prralel thread going on in comp.os.vms that you may be interested in. Over there Arne is helping me as much as Bojan is here. His latest reply is below: -
"Arne Vajh├Г┬╕j"
Richard Maher wrote:
>>> But if you want the applet to do everything, then why uses HTML form
>>> fields at all and not just fields inside the Applet ?
>> :
>>> The easiest way to keep state would probably be to keep the same
>>> same web page and the same applet during the entire session.
>> :
>>> But the more you write the more I think you should use
>>> one big applet and only use the HTML for "application start".
>> :
>>> But if you don't want to submit the HTML form, then I think it
>>> is better to make the fields, buttons etc. in the applet.
>> :
>>> But you could do the same in pure Java applet.
>> Ok, ok, ok, okay. Has everyone got that?
>>
>> Option 1 (And I agree, the "preferred" option)
>> The Applet is the master of the universe!
>>
>> Use the WWW as not much more than an Application Port Mapper that uses your
>> company's Web Page to "pimp" the required application via a Java Applet. I
>> love it! I see this strategy as the future of Web interaction with VMS (if
>> not all platforms) and is a marvellous stepping stone if you later choose to
>> move to Java Web Start and full-blown applications, JVM downloads and so on.
>> Get your hands on a *good* Java coder(s) now 'cos this is what you'll be
>> doing in the next 6-12 months!
It is certainly a valid approach.
I belive that several chat programs has been implemented this way.
I dont't think your app will be a chat, but a chat has the same
requirement to use sockets directly (so that the server can push
to the client instead of the the client polling via HTTP requests).
>>> JavaScript can call some Java code that uses them though
>> :
>>> JavaScript can call methods in the Java applet that can use
>>> the socket.
>> :
>>> JavaScript---(call)---Java applet---(socket)---server app
>> You bewdy!!!
>>
>> Option 2 (And possibly the softer less
>> challenging/distressingly-unfamiliar/safe option)
>> The Half-Way House
>> Can you please (pretty please!) show me an example of a Javascript calling a
>> method in a Java Applet? This is what I want to to in the short term.
I have never used it myself.
But here are some links:
http://www.rgagnon.com/javadetails/java-0170.html
http://www.javaworld.com/javaworld/jw-06-2004/jw-0621-talk.html
>> PS. Look, I tried hard but I have to mention AJAX again. It is the
>> asynchronous nature of watching a field being entered and sending the
>> interim results down the socket and displaying the results in a seperate
>> thread-like fashion that I'm led to believe is only doable (GIVEN OPTION 2's
>> CONSTRAINTS) by using AJAX. If you, in fact, don't need AJAX for this and
>> Arne is willing to take the time to show an example of pure
>> html->javascript->applet-method that can provide similar functionality then
>> please do.
You only need the AJ part.
You don't want the AX part.
The AJ part is doing something via JavaScript client side when the user
does something.
The AX part is about communicating with the server via HTTP and XML.
Java applet and sockets replace the AX part.
Arne
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2006 02:38 AM
тАО11-02-2006 02:38 AM
Re: Java Applet from VMS Web Server
I found some time to write a very simple applet which gets some text from VMS service and display the text. It work as predicted.
Once more the Linux system was the html server and VMS served the class and jar file.
By the way, I see that the applet class must be in a separate file!
The server on VMS was Apache.
The next thing I have try is to work without Apache just to explain how simple is the http protocol.
For this I write a small dummy web server in a command procedure and set it as a tcpip service in VMS. The server is realy dummy and the files must be set as UDF to work properly but in a program it will not be dificult to read a file and send it as is.
Here is the code.
First the applet:
import java.applet.Applet;
import java.awt.Graphics;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Socket;
public class HelloWorld extends Applet {
String text = "No text";
public void init ()
{
String addr = getParameter("ADDR");
int port = Integer.parseInt(getParameter ("PORT"));
try
{
Socket socket = new Socket (addr , port);
BufferedReader in = new BufferedReader (new InputStreamReader (socket.getInputStream()));
text = in.readLine();
socket.close();
} catch (Exception e)
{
e.printStackTrace();
}
}
public String[][] getParameterInfo() {
String[][] info = {
// Parameter Name Kind of Value Description
{"ADDR", "String", "address"},
{"PORT", "int", "port"}
};
return info;
}
public void paint(Graphics g) {
g.drawRect(0, 0,
getSize().width - 1,
getSize().height - 1);
g.drawString("Hello world! " + text, 5, 15);
}
}
Now the html:
codebase="http://1.2.3.4:4444/"
archive="HelloWorld.jar"
width="800" height="600">
The service installed on port 4445:
$ open/read/write net sys$net
$ write net "Hello from VMS!"
And the web server installed on port 4444:
$ open/read/write net sys$net
$ read net httpcmd /time=10/error=end
$ method = f$element (0 , " " , httpcmd)
$ path = f$element (1 , " " , httpcmd)
$ show sym/all
$ if "GET".eqs.method
$ then
$ filename = f$element (1 , "/" , path)
$ if f$search(filename).nes.""
$ then
$ type = "application/octet-stream"
$ if f$parse(filename,,,"TYPE").eqs.".HTML" then type="text/html"
$ write net f$fao("HTTP/1.0 200 OK!/")
$ write net f$fao("Content-Type: ''type'!/")
$ len = (f$file(filename , "EOF") - 1) * 512 + f$file(filename,"FFB")
$ write net f$fao("Content-Length: ''len'!/!/")
$ copy 'filename' net
$ exit
$ endif
$ endif
$ write net f$fao("HTTP/1.0 404 not found!/!/")
$ exit
The web server must have limit more than 1 to work properly!(I spent a hour to find that this causes errors!).
This is a very simple example but it works and explains how can be things made.
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2006 02:59 AM
тАО11-02-2006 02:59 AM
Re: Java Applet from VMS Web Server
Forgot to check the Retain format.
So I have put all the examples in a txt file.
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2006 09:45 AM
тАО11-02-2006 09:45 AM
Re: Java Applet from VMS Web Server
> Forgot to check the Retain format.
> So I have put all the examples in a txt file.
Let me tell you that your text file format is not great either :-)
Any chance of another one with just ASCII?
Cheers Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-02-2006 06:16 PM
тАО11-02-2006 06:16 PM
Re: Java Applet from VMS Web Server
The attached file is just an ASCII file. I try to post it with the retain format checked.
Applet:
import java.applet.Applet;
import java.awt.Graphics;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Socket;
public class HelloWorld extends Applet {
String text = "No text";
public void init ()
{
String addr = getParameter("ADDR");
int port =Integer.parseInt(getParameter ("PORT"));
try
{
Socket socket = new Socket (addr , port);
BufferedReader in = new BufferedReader (new InputStreamReader (socket.getInputStream()));
text = in.readLine();
socket.close();
} catch (Exception e)
{
e.printStackTrace();
}
}
public String[][] getParameterInfo() {
String[][] info = {
// Parameter Name Kind of Value Description
{"ADDR", "String", "address"},
{"PORT", "int", "port"}
};
return info;
}
public void paint(Graphics g) {
g.drawRect(0, 0,
getSize().width - 1,
getSize().height - 1);
g.drawString("Hello world! " + text, 5, 15);
}
}
Html:
codebase="http://1.2.3.4:4444/"
archive="HelloWorld.jar"
width="800" height="600">
Service on port 4445:
$ open/read/write net sys$net
$ write net "Hello from VMS!"
Service on port 4444 acting as web server:
$ open/read/write net sys$net
$ read net httpcmd /time=10/error=end
$ method = f$element (0 , " " , httpcmd)
$ path = f$element (1 , " " , httpcmd)
$ show sym/all
$ if "GET".eqs.method
$ then
$ filename = f$element (1 , "/" , path)
$ if f$search(filename).nes.""
$ then
$ type = "application/octet-stream"
$ if f$parse (filename,,,"TYPE").eqs.".HTML" then type="text/html"
$ write net f$fao("HTTP/1.0 200 OK!/")
$ write net f$fao("Content-Type: ''type'!/")
$ len = (f$file(filename , "EOF") - 1) * 512 + f$file(filename,"FFB")
$ write net f$fao("Content-Length: ''len'!/!/")
$ copy 'filename' net
$ exit
$ endif
$ endif
$ write net f$fao("HTTP/1.0 404 not found!/!/")
$ exit
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2006 11:47 AM
тАО11-03-2006 11:47 AM
Re: Java Applet from VMS Web Server
Thanks very much for the example. This is just too easy for words!
Why do we still hear about rubbish CGI scripts and poorly performing servlets, when people like Bojan and Arne can show everyone how to effortlessly obtain full function, web-enabled user-interfaces to the reliability, performance, and functionality of their VMS servers?
And now Multinet IPsec is here, you message exchange can be also be effortlessly locked-down in an Internet environment.
It just doesn't get any better than this!
Cheers Richard Maher
PS. Very surprised how basic the http protocol is! Thanks for the eye-opener. Definitely worth bundling an Applet-Loader with Tier3.
PPS. I'm off to read my Java Programming book 'cos there doesn't appear to many around that are doing this? How bizarre!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2006 12:12 AM
тАО11-05-2006 12:12 AM
Re: Java Applet from VMS Web Server
Very quick one; what is the delimiter for Java "stream" I/O? I thought it would've been a
What do you send and what do yo expect to receive?
Cheers Richard Maher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2006 06:49 PM
тАО11-05-2006 06:49 PM
Re: Java Applet from VMS Web Server
Java Streams have no delimiters. They are just streams of bytes. In the example a BufferedReader was used and the readLine() method is defined as (copied from the Java API documentation):
"Read a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed."
The null character and null delimited strings are from the C/C++ environment but Java does not know nothing about such constructs.
The HTTP protocol has a
http://www.w3.org/Protocols/rfc1945/rfc1945
and
http://www.w3.org/Protocols/rfc2616/rfc2616.html
[ Why do we still hear about rubbish CGI scripts and poorly performing servlets, when people like Bojan and Arne can show everyone how to effortlessly obtain full function, web-enabled user-interfaces to the reliability, performance, and functionality of their VMS servers?]
The simple example is just that, a simple example! There are some problems to use such examples in real world. You have to deal with lot of log files when using a simple TCP/IP service. Every connection creates its oven process and the number of connections can be huge (When running the simple example, the browser will create 3 or 4 connections to the server).
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-05-2006 11:42 PM
тАО11-05-2006 11:42 PM
Re: Java Applet from VMS Web Server
> The simple example is just that, a simple example!
> There are some problems to use such examples in real world.
Having had over twenty years experience developing and supporting VMS applications in the "real world", spread over 4 countries in industries ranging from mining, retail and investment banking, commodities trading, and telecommunications customer management and billing systems, I can understand your reticence.
> You have to deal with lot of log files when using a simple
> TCP/IP service. Every connection creates its oven process
> and the number of connections can be huge (When running
> the simple example, the browser will create 3 or 4
> connections to the server).
Bojan, please, please take the 10mins reqd to look at the PDF attachment to the fourth post (and my second) to this thread! It's a little over 60 pages, but you could just focus in on Chpt 2 (the System Management chapter) which is only 12 pages long. I think you'll find that the VMS server issues and problems are well and truly covered! The only question here is the best way to get at these VMS servers from the browser.
Look, even without Tier3 and within the limitations of INETd, Java sockets are still a viable option in their own right because of the lovely Initialize and Destroy methods. When a web page is first displayed and the applets loaded, the one-time socket connection is performed. Now flick from page to page to tab to tab, and only when the browser is shutdown will the JVM call the Destroy method and activate the close socket code. If you're not getting your jollies over that then you're simply sick of life itself!
> Java Streams have no delimiters. They are just streams of bytes.
Once again, I am familiar with TCP/IP stream I/O and the message encapsulation possibilities (and restrictions) afforded by connectionless protocols like UDP. What I am unfamiliar with is the object-oriented contortions one must perform to call a simple send() and recv() routine via Java!
> In the example a BufferedReader was used and the readLine()
> method is defined as (copied from the Java API documentation):
>
> "Read a line of text. A line is considered to be terminated
> by any one of a line feed ('\n'), a carriage return ('\r'),
> or a carriage return followed immediately by a linefeed."
Presumably then, there is also a "readbytes()" method to the BufferedReader (Interface?) where I can say "Get me the two-byte header info and if it's a "22" message then read the next 40 bytes" and if I'd like to do something outrageous like "peek" a block of bytes before dequeuing them from the socket then I'd have to research another 100 pages of documentation? God forbid I'd ever want to send or receive the OOB character because the interface is just not surfaced by the Java inheritance of the metamorphosis! How 'bout a bloody "flags" *parameter* hey?
I'm just another unfashionable dinosaur I suppose.
> The null character and null delimited strings are from
> the C/C++ environment but Java does not know nothing
> about such constructs.
Hey nulls are anathema to me, but with (non-browser) PC interfaces, I'm used to hearing "Can't you stick a null in there?" :-(
Anyway, thanks again.
Cheers Richard.
PS. If you use a connection-oriented protocol like http/1.1 (which I won't :-) then I figure you can reduce connection attempts for your class and applet uploads by half.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2006 03:05 AM
тАО11-06-2006 03:05 AM
Re: Java Applet from VMS Web Server
My previous post was not intended as "do not use" but more than a warning to not simplify. I write some applications using this aproach and they works greatly.
[Once again, I am familiar with TCP/IP stream I/O and the message encapsulation possibilities (and restrictions) afforded by connectionless protocols like UDP. What I am unfamiliar with is the object-oriented contortions one must perform to call a simple send() and recv() routine via Java!]
This is only a meter to become familiar with Java and object oriented programming. If you are familiar with a object oriented language like C++ the learning time is measured in weeks or days. You will see that many things are much simplier in Java. You can look at the Java API documentation, to see how things works:
http://java.sun.com/j2se/1.5.0/docs/api/index.html
See the java.net package (left upper frame) and then search for the Socket or DatagramSocket class in the left bottom frame. You will see that you can retreive two streams from the socket. An output and an input stream. This streams are used to call the underlaying send() and recv() routines. See also InputStream and OutputStream in the java.io package. You will see that you can read and write bytes. Abbout the OOB character I am afraid that you are right. Writing is supported but reading is partialy supported (the so called inline OOB is quite unusable).
Or there is a trail about networking:
http://java.sun.com/docs/books/tutorial/networking/index.html
[I'm just another unfashionable dinosaur I suppose.]
This are words I hear many times about me. But at the end I can resolve problems that other "fashioned" guys cant. Knowing how things works is definetly a great plus. The experience meters!
Cheers Bojan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2006 03:10 AM
тАО11-06-2006 03:10 AM
Re: Java Applet from VMS Web Server
in the link. It should be:
http://java.sun.com/docs/books/tutorial/networking/index.html
or as plain text:
"http://java.sun.com/docs/books/tutorial/networking/index.html"
Bojan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2006 11:17 PM
тАО11-17-2006 11:17 PM
Re: Java Applet from VMS Web Server
Sorry for being so needy, but this request is aimed directly at you. Having said that, you've helped me more than enough already and I won't feel put out if you decline, so I'm throwing my plea for help open to the floor.
Please find attached all the COBOL, SQLMOD, and DCL needed to build a small (200 lines) INETd server example that will service "Employee Lookup" requests to port 3333.
The protocol is about as simple as you can get: -
1) The first two bytes of every message contains the message ID
2) The server will (hopefully) work with Java Stream i/o methods on the Socket so everything is CRLF terminated
3) A "20" message is a Surname Lookup request to which the server responds by sending back zero to N "21" messages followed by a "99" End-of-File message
4) Server shuts down on receipt of a "99" message or failure
I will attach a working VMS/SMG$ client example to fully illustrate what's going on, but what I (and the VMS world at large) *desperately* need is a HTML + Javascript + Java Applet example of a browser-hosted client!
I don't care what strategy you use to get your Applet up, but I do insist that you do use the automatic Init() and Destroy() methods for connecting and disconnecting from the Employee Lookup server. Ideally, upon receipt of some sort of "field-changed" event (I can only pray that you don't poll for this!) you will grab the characters that have been entered (via your seperate thread) and ask the VMS server for the matching employees from the personnel database.
So, can you do this? If it's a money thing then send me a quote and if it's reasonable then who knows. Call me crazy, but I'd've expect to be able to rock up to the VMS or Rdb web sites and try out just this sort of example :-( What'd be the point of that eh?
Anyway, here are some more useful tips for running the example: -
1) You should save the first text file as java_emp.com
2) You need Rdb and COBOL installed and "mf_personnel" should point to the ubiquitous Rdb example database
3) You *must* "$ucx set noservice java_emp_inetd" before running java_emp.com for the second and subsequent times.
4) Don't forget that the last_name column in the employees table has a Capital letter followed by lowercase characters
5) Change the cursor to use "like" instead of "starting with" to taste
Tips for building the VMS client example: -
1) Apart from anything else it shows COBOL building array descriptors and calling lib$vm_realloc so it's worth a look in its on right :-)
2) Save the next text file as emp_client.cob
3) Edit emp_client.cob and change rem_node_addr to your server's IP address which probably won't be 1.2.3.6
4) $cob/lis emp_client.cob
5) Save the third text file to emp_client_def.mar
6) $mac/lis emp_client_def
7) $link emp_client,emp_client_def
8) $Run emp_client
You will see that as you enter the initial characters for the employee surname ("S" is a good one to choose) a list of matching employee last_names are retrieved from the mf_personnel database and displayed. (If you press