Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php vs. applet chalenge

Status
Not open for further replies.

itucakov

Programmer
Sep 7, 2001
6
CA
I am working on a project and I would like to do something but
I am not sure if it is possible.
Suppose I have a netscape browser with php file loaded
in it. Now, this php file contains a link to some file.
Now, I have a separate browser where I have an applet
loaded. This applet can plot the data in the file that the
php file link points to.
Is there a way for me to design a button in the php page
that would take that file and automatically load it in the applet
in my other browser. Or even, if the applet is not open,
open it in a separate browser and load the file.
I am using RMI for data transfer so is there a way to incorporate
that in the data transfer as well?
Basically, my questoin is: is it possible to make calls (that would
usally be called and manipulated in the applet) from a different
place (web browser) such as a php file? ANd how is that done.
Not only that, is it possible to do java related stuff, from a php file?
Any suggeston or comment or question would mean lots.
Thanks
Ivan
 
Well, I'm not sure I understand completely what you want to do, but PHP can do server-side calling of Java objects, so I guess that one way or another, what you want is possible.

You have to compile PHP with Java support, though, which is not in by default.

Then, as I think I understand your needs, you can have a PHP page that takes a certain input call, which is then directed to the PHP-Java connectivity. Then from there, Java takes over, and communicates from a server-side routine to the applet in the browser. Sounds like it would take a bit of work, though.

Actually, theoretically, you don't even need PHP to be Java-enabled. You can create a small stand-alone Java program on the server that just takes command-line arguments before connecting to the applet, and then you can just have PHP do a system() call on it.
 
Thanks.
THe second option seems more simple. However, how would the stand-alone Java program know where the applet is (since it is in a netsape web browser) and also whether it has been already loaded or not. BEcause, if it has been loaded, then the program should know that, find the applet and load a file into it. If not, then it should open the applet in a web browser (how would this be done?) and then load the file into it. Is this possible?
Ivan
 
Yes, it's possible, since when the browser establishes a connection, you will have the browser's IP address. The client-side applet can actually initiate the call, so the server-side applet is just listening on a certain port, waiting for user {john doe} to initiate.

Java has a very rich library of network programming APIs that I know almost nothing about, so you should probably ask some questions in the Java forum.

On another note, actually, there are ways to accomplish this without any Java at all, just plain HTML, Javascript, PHP and client-server sessions, but it's a bit of a work-around. Let me know if you are interested.
 
It's posible to have a live conection between a html page (with javascript) and a php program?
 
It's not truly "live" in the sense that it doesn't establish a socket for two-way communications, but it kind of allows you to emulate it, especially in allowing the server to respond with up-to-date data in response to Javascript events, wihtout refreshng the page.

There are a couple of ways to do this: One is to have a hidden frame, which uses a refresh meta tag, which refreshes every coupld of seconds, which can pass Javascript variables to PHP, and PHP variables to Javascript, using standard URL query string stuff. The other way is a little more arcane, and I will send you to a thread in another forum where we discussed it:
If you have any trouble understanding the concept, let me know. I'm not saying either of these methods is great, but at least they let you stretch the normal boundaries of web client-server communication.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top