Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Perl with Java applet

by Anonymous Monk
on Jun 06, 2005 at 12:00 UTC ( [id://463877]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am using Java applet in my website. My website is done using Perl, Perl is also used to connect to MySQL.

My java applet will need (username and data from database). How do I pass this string from perl to my java applet?

thanks

Replies are listed 'Best First'.
Re: Perl with Java applet
by dorward (Curate) on Jun 06, 2005 at 12:22 UTC

    There are a couple of ways to get information to a Java Applet. The simplest is through the HTML <param> element.

    Failing that you will most likely be looking at opening a new network connection from the Applet to the server. One approach could be through the use of a Perl SOAP server and a Java SOAP client.

Re: Perl with Java applet
by Ben Win Lue (Friar) on Jun 06, 2005 at 12:26 UTC
    Depends on your applet...
    Normally applets receive their parameters in the HTML-Code, that is calling them. The way the data is passed (e.g. Parameter names) should be specified in your applet.
      Could the applet passed the data back to Perl? I mean the data might be modified, so could the modified data pass back to perl and updated MySQL

        Passing data with param is strictly one way. To send data from the applet back to the server you'll need to start making HTTP requests from the applet (possibly via SOAP as I mentioned before), or running some other server software running whatever protocol you want.

Re: Perl with Java applet
by Zero_Flop (Pilgrim) on Jun 06, 2005 at 20:58 UTC
    Basicly there are two main ways. One is to pass the info in the HTML Parm as mentioned, the other way is to have the Applet pull a specific web page ( call a perl script, static file, or HTML ) that returns the informaiton you want. You can also encode the informaiton in the perl and decode it in the applet so it is not directly readable by someone monitoring the connection or going directly to the webpage.

    I do the second option for a little game I programmed. The Java applet that displayes the users status calls a perl CGI script on the server which returns the status then the applet POSTs the responce to a perl script which writes back to the db on the sever.

    Java can always write and read from the server it originates from, but it can only read and write locally if it is signed and the user accepts it.

    IF you are interested let me know and I can send you a link to an example. I don't want to post links to WIP which will live in PM archives.
      Yes Zero Flop, I am very intrested to see the example. Maybe you could send the link to my email ejaluum@yahoo.com .

      Thanks
Re: Perl with Java applet
by gregor42 (Parson) on Jun 07, 2005 at 15:33 UTC

    The advice given previously is complete enough that I won't address the solution(s) already given.

    Just as an aside however - since this isn't what you asked for - it's also possible to connect to the server you loaded the applet from with a socket-based connection. I know this can be made to a servlet on the server side, but I don't see why you coudn't connect to Perl code instead.

    That might afford you the most efficient conenction but adds nothing at all to security, compatibility, nor accessibility. It's just possible. To address those concerns you'd be better off providing a web service on the server & consuming it via the applet, as suggested above.



    Wait! This isn't a Parachute, this is a Backpack!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://463877]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (None)
    As of 2024-04-25 00:45 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found