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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get data from a java applet from the client

Status
Not open for further replies.

vlakas1981

Programmer
Dec 11, 2002
40
GR
Hello all,

i'm not sure if this is the correct place to post this, but here it goes:

i need to get data from a java applet that is running on the client machine and get it to my php form.
the code to do this cannot be implemented in the applet, only sth like an "include" can be.
what i'm thinking is to have a javascript in my php page that calls a dll to interact with the applet.
however after some search on the net i found out that java application to dll calls are possible through jni, but not for java applets.
any ideas??

TIA
 
What you are proposing is seems to be extremely overcomplicated.

Do you really want to have to write a C++ interface (ie the dll) so that it can communicate with the applet ? And then use javascript to call this dll to populate your php form !!!???

There must be an easier way - why don't you tell us a little more about what you are trying to achieve, and ,maybe we can come up with a simpler solution ?
 
i know it is overcomplicated!! i have spent some time and this is the solution that i think i should use-the dll won't be anything special. however this is the problem:
i have an applet that is used to interact with a card reader. the applet sends data to the server from which it is downloaded. i need to be able to send and receive data to this applet.
i know this applet interacts with the card's dll on the client-so why not interact with my dll as well?
i use the data that i get from the applet for authentication and i need to send data to the card for digital signing.
my thoughts are that since php runs on the server, i need to do some javascript that calls the dll, since the javascript will run on the client.
do you see an alternative to this??
please tell me if you need more info.

thanks
 
vlakas1981,

If I understand you correctly what you want to do is very simple. JavaScript has access to the applet just as it has access to anything else in the DOM. Therefore you can access the applet and request your data. Netscape pioneered a technique to allow the applet to communicate back to the JavaScript (LiveConnect). This is relatively simple as well. You just need some additional classes in your applet. I've included some ULR(s) to an appropriate tutorial.

Download LiveConnect:

use the win30.zip in side the downloaded zip. (JSObject is in it).

Tutorials:


Good luck,
Tadpaul
 
If you just need data from your applet posted to your form this is no problem. Just post it to your form :)

Example:


// Send data
URL url = new URL(postURL);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();

// Get the response
InputStream is = conn.getInputStream();

BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
String totalLines = "";
while ((line = rd.readLine()) != null) {
totalLines += line + "\n";
}
rd.close();
wr.close();

postURL is the url of your php file.
data is the data you want to post.

the data may be in the format you want. E.g. if it's ID's you may want data to be "IDS=1,2,3,4,5,6,7,7,8" etc.
 
thanks everyone for your answers,

it seems that i haven't pointed out a couple of things:
1. the applet i want to contact doesn't run on my page, so i guess this liveconnect won't work (i took a look at the page and it only speaks about the same page)

2.the data i want to send in and out of the applet has to be transfered securely, so posting it raw to a page is not good enough.



keeps getting harder heh?
 
Use HTTPS then. Should work.

Alternatively post encrypted info. And decrypt it on the server.

- bjorn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top