Applet with Server sided webpage (asp, php)

Hi Guys
I have a quick question regarding the use of Applets..
Let's say i've made an applet which i can put on a webpage to pick a date..
What i want to do is have the applet post data to the server just like any normal web control (like a server-side asp.net control or a html textbox in php)
Is this possible?
Thanks
-Nonameo-

Nonameo,
You can use HttpURLConnection to communication between the applet and server side code(servlet, php, etc.).
On the applet do following:
// get input data for sending
String input = inputField.getText();
// send data to the servlet
URL urlServlet = new URL(getCodeBase(), "dir under your base");
URLConnection con = urlServlet.openConnection();
OutputStream outstream = con.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outstream);
oos.writeObject(input);
oos.flush();
oos.close();
On the server side you will be able to get the data posted by the applet.
Hope this helps.
Chris

Similar Messages

  • How do I communicate a Java Card applet with a server?

    I'm new to Java and Java Card and currently developing a smart card system. I'm not sure what to use on my applet or server, JCSystem or SecureConnection or something else?
    If I'm writing a server application, then how do I install it so that I can simulate it with cjre?
    Thanks in advance.
    p/s: Connection is using TSL.

    The flow is like this:
    Java Card --> POS terminal -> Server
    Yes. I'm using JC3.
    Here's what I've achieved so far using SocketConnection
    SocketConnection sc = (SocketConnection) Connector.open("socket://localhost:50007");
    InputStream is = sc.openInputStream();
    OutputStream os = sc.openOutputStream();
    os.write("Hello world!".getBytes());
    is.read(buffer);
    os.close();
    is.close();
    sc.close(); Edited by: andirady on Dec 4, 2012 11:59 PM

  • Can I manage custom builds of Apache and PHP with Server Admin?

    Okay, here's the deal: I have a shiny new Xserver Xeon with Leopard Server installed. I see that it comes with a number of programs that I'll need, preinstalled, but for various reasons (extensions and modules for PHP, Apache, and the like), I may need to roll my own builds of several of these programs and libraries. In this case, the main thing I'm concerned with is recompiling Apache and PHP.
    My question is, can I do this and still manage those tools from Server Admin? I'm not averse to doing it on the command line if need be, but I'd just as soon not have to, if I have Server Admin. So, what would I need to do to make sure that I can still use Server Admin with a custom PHP and Apache?

    My main interest is in using Wiki Server with the custom Apache and PHP builds. Since that's managed through Server Admin, I figured it would be best to try and integrate with the Apple tools.
    Apache I could maybe get by without a rebuild, but there are definitely PHP modules I need which the default build does not come with.

  • How to run server application on that talks to applet in embeded in webpage

    i have a client(applet) and server application that are designed to communicate via sockets. the applet will run from a webpage and i know how to publish that. but the problem is the server application. i have been told that it too should run on my host, but how can i specify that and how to find out whether or not my host allows such a thing.
    any clarifying reply would be highly appreciated.
    sam

    If thinking about a Java solution, look at JSP/Servlet technology. (i.e. http://jakarta.apache.org)
    In short, servlets a classes that run in a container accesible by HTTP.
    There is also J2EE, wich uses RMI to perform this task.

  • Is it possible to replace applet with JSP

    I m working for the extension of the a Chat Application which is Applet based...
    It is slow as the Applet loaded...
    Is it possible to replace the applet with th JSP....
    what r the pro and cons of it???
    Thanks in advance...

    sure it is possible.
    main difference is, that applet maintance a permanten connection to the server and therefor has a 'smaller' communication where as with servlets/jsp the client will have to communicate more information for each request.
    have a look at pushlets.com, a servlet based framework that keeps the connection to the client open (works with hidden frames and dhtml). very smart framework.

  • Java 7: Problems launching applets with jars on "file://" location

    Hi,
    We are experiencing a problem when updating our client's JRE from Java6 U 21 up to Java7 U 55.
    We have developed an Applet which is composed by several JAR files. Some of those JARs must be stored in local drive, and the JAR with the main Java class is stored on server.
    Let's supose we have a similar scenario like this:
    https://blahblahbah/bar.jar
    https://blahblahbah/test.html
    C:/foo.jar
    The code of test.html:
    <embed
      archive="file:///C:/foo.jar"
      cache_archive="bar.jar"
    />
    This code works fine on Java 6 and Applet is correctly loaded.
    However, with Java 7 a security exception is raised when trying to load JAR files from "file:///" location during Applet launch:
    java.lang.SecurityException: Permission denied: file:/C:/foo.jar
        at sun.plugin2.applet.Applet2Manager._loadJarFiles(Unknown Source)
    We have tried several tests using a java.policy file which grants all possible permisions:
    grant codeBase "file:/C:/foo.jar" {
        permission java.security.AllPermission;
    grant {
      permission java.security.AllPermission;
    We also tried to low Java's security level to "MEDIUM", with no success.
    We finally only managed to run the Applet if we explicity disable the "Next-Generation Plugin" with Internet Explorer 8. However, that's not a suitable solution, and still does not work with Mozilla family browsers.
    Eventhought with Mozilla browsers is still not working.
    Is there any restrictions in Java 7 that prevents to read jars from being loaded from local drive when launching Applets?
    Thanks in advance,

    Thank you baftos.
    I had read the whole message before posting mine. It's not the same problem. I'm able to run the sample signed applet always having the jar in the same location than the HTML page serving the applet via JNLP:
    <jar href="SignedAppletTest.jar" main="true"/>
    However, the security exception raises when trying to read that jar from local drive:
    <jar href="file://C:/SignedAppletTest.jar" main="true"/>
    ExitException[ 3]java.lang.SecurityException: Permission denied: file://C:/SignedAppletTest.jar
        at sun.plugin2.applet.JNLP2Manager.loadJarFiles(Unknown Source)
    I have even tried to decompile JNLP2Manager class, without seeing anything useful on that loadJarFiles method
    The only way I managed to avoid the problem is unchecking the New Generation Plugin and running the Applet with IE. Not a suitable solution for me at all..

  • Java Class not found when starting applet with ip address

    Hi @all,
    we use Application Server 10gR2 with Java 1.6.0_20 and we start the applet with an JNLP File.
    When I use the url http://lhhap03/forms/java the applet starts as it should. But when I change the entry to http://192.168.17.208/forms/java i get the error:
    Exception in thread "thread applet-oracle.forms.engine.Main-1" java.lang.NoClassDefFoundError: org/apache/regexp/RE
    Now I´m a little bit confused why i can´t use the ip address instead of the dns name from the server?
    Which config I have to change that i can get the access to jar libraries with the Ip - Address
    Best regards
    thomas

    Problem Solved, I put many environment variables  in the .bash_profile file, the CLASS_PATH will overwrite the weblogic server's classpath during startup.
    Remove them and restart server solved my problem.

  • Help with web form script. PHP, CGI, Perl???

    anyone willing to help with a web form script? I have a form built, but cant seem to figure out the scripting! Should I be using Perl, CGI, PHP... What do I need to enable? I am a complete novice when it comes to scripts. Looking for a little friendly help.

    Here is a simple bit of PHP to stick in the page your form posts to. You would need to edit the first three variables to your liking, and add the html you want to serve afterwards:
    <pre>
    <?php
    $emailFrom = '[email protected]';
    $emailTo = '[email protected]';
    $emailSubject = 'Subject';
    $date = date('l, \t\h\e dS \o\f F, Y \a\t g:i A');
    $browser = $HTTPSERVER_VARS['HTTP_USERAGENT'];
    $hostname = $HTTPSERVER_VARS['REMOTEADDR'];
    $message = "$date\n\nAddress: $hostname\nBrowser: $browser\n\n";
    foreach ($_POST as $key => $value) {
    $message .= $key . ": " . $value . "\n";
    $mailResult = mail($emailTo,$emailSubject,$message,"From: $emailFrom");
    ?>
    </pre>
    This script will grab the server's date and the submitter's address and browser type. It will then list the name and value of each form field you have put on your form.
    Also, this script expects your form method="post".
    Lastly, you can offer alternate text later on in your html page based on the success of the above script with a snippet like this:
    <pre><?php
    if ($mailResult) {
    echo "Your comments have been received thank you.";
    } else {
    echo "There was an error. Please try again or contact us using an alternate method.";
    ?></pre>

  • How to create an applet, with many squares inside?

    Hey,
    I'm having problems creating an applet. Heres the image I need to recreate. The drawing should scale, so that it reaches the full width and
    height of the applet.
    http://img503.imageshack.us/my.php?image=graphicsafx5.jpg
    I created a similar one (the code is below), but don't know how to modify it to create the image in the above link. Do I need a for loop? like for ( int i = 0; i < 10; ++i )
    import java.applet.Applet;
    import java.awt.*;
    public class AprilTest1 extends Applet
       public void paint(Graphics g)
            Graphics2D g2 = (Graphics2D)g;
            int width = getWidth();
            int height = getHeight();
            g2.setColor( Color.black );
            g2.fillRect( 0, 0, width, height);
            int pen_width = width/90 + 1;
            g2.setStroke(new BasicStroke(pen_width));
            g2.setColor( Color.white );
            g2.drawRect( width/4, height/4, width/2, height/2);
    }

    As CeciNEstPasUnProgrammeur said you do need a loop. You can probably make good use of the % operator inside your loop also.
    for(int i=0; i<NUMBER_OF_RECTANGLES; i++){
         if(i % 2 == 0) {
             //draw black rectangle
         } else {
             //draw white rectangle
    }Just think about what you need to do:
    -Start 1 rectangle at (0,0) and have its width and height as getWidth() and getHeight().
    -Pick an increment [this will be the 'width' of each rectangle]
    -Now for each rectangle you want to move your x and y points right and down by your increment. Moreover, you want to make your width and height smaller by your increment*2
    Essentially what I did is initialize 3 variables to 0 [say x, y, and z]. In your for loop use the % operator in an if-else block. If the loop is on an even number make a white rectangle, if the loop is on an odd number make a black rectangle. Set the x and y position to x+z and y+z respectivley. Set the height and width to getHeight()-(z*2) and getWidth()-(z*2) and then increment z by...lets say 10.
    This means on the first loop:
    x = 0
    y = 0
    width = getWidth()
    height = getHeight()
    Second loop:
    x = 10
    y = 10
    width = getWidth()-20 [10 to compensate for the shift, and 10 for the width]
    height = getHeight()-20
    Here is what I came up with - hope it helps.
    import java.applet.Applet;
    import java.awt.*;
    public class AprilTest1 extends Applet {
         private int x, y, z = 0;
         public void paint(Graphics g) {
              for(int i=0; i<10; i++){
                   if(i%2==1){
                      g.setColor( Color.white );
                      g.fillRect(x+z, y+z, getWidth()-(z*2), getHeight()-(z*2)); 
                   } else {
                      g.setColor( Color.black );
                      g.fillRect(x+z, y+z, getWidth()-(z*2), getHeight()-(z*2));
                   z += 10;
    }Any questions, feel free to ask :)

  • Signing Applets with javakey

    Hi All,
    I have an Intranet application that uses a signed applet to access files on the client. It all works fine using JDK1.3 or 1.4 and signing the Applet with keytool.
    I now need to support an older server that only has JDK1.1 available. Does anyone have any tips on how to sign my Applet with javakey?
    Also what JRE version should be installed on the clients?
    Thanks in advance.
    P.S. I have followed the example at http://java.sun.com/security/usingJavakey.html but not got it to work.

    try this..
    http://forums.java.sun.com/thread.jsp?forum=63&thread=132769

  • URGENT Help for applet with JAR file in Netscape

    I am having Applet with few classes
    Html is in /www directory
    and all class files are in /www/javaclassfiles
    I jared all javaclassfiles with following command
    c:\www\javaclassfiles>jar -cvf sample.jar TaxPaymentAppletForm.class *.class
    where sample.jar is my jar file and TaxPaymentAppletForm.class is the main applet class file.
    THEN I DELETED ALL CLASS FILES & KEPT ONLY SAMPLE.JAR FILE ON SERVER
    My html code is like below:
    <APPLET CODE="TaxPaymentAppletForm" ARCHIVE="sample.jar" CODEBASE="JavaClassFiles" WIDTH=460 HEIGHT=400></APPLET>
    The things are running on IE properly, but not on Netscape. Netscape is giving following error :
    java.io.IOException: <null>
    at netscape.net.URLConnection.connect(Compiled Code)
    at netscape.net.URLConnection.getInputStream(Compiled Code)
    * at netscape.applet.AppletClassLoader.grabArchiveFile(Compiled Code)
    at netscape.applet.AppletClassLoader.openArchive(Compiled Code)
    at netscape.applet.AppletClassLoader.openArchive(Compiled Code)
    at netscape.applet.AppletClassLoader.<init>(Compiled Code)
    at netscape.applet.AppletClassLoader.getClassLoader(Compiled Code)
    at netscape.applet.DerivedAppletFrame$LoadAppletEvent.dispatch(Compiled Code)
    at java.awt.EventDispatchThread$EventPump.dispatchEvents(Compiled Code)
    at java.awt.EventDispatchThread.run(Compiled Code)
    at netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(Compiled Code)
    # Unable to load archive http://nearbuy_server:90/iras/JavaClassFiles/sample.jar: java.io.IOException: <null>
    # Applet exception: class TaxPaymentAppletForm could not be loaded
    # Applet exception: class TaxPaymentAppletForm could not be loaded
    # Applet exception: class TaxPaymentAppletForm could not be loaded
    In netscape also it is sometimes running some times not, without any logical reson.
    Any help regarding this is appreciated
    manisha

    Following is the more detailed analysis when applet is running and when not
    On local server, it is running fine on both IE / Netscape
    When I transfered jar file to live server
    On IE it is running for the first time and then onwards not running, If I clear the catch then again applet is running.
    For second time it is giving following error :
    IOException Loading Archive: http://dev1.janusx-collections.com/iras/JavaClassFiles/AppletForm.jar
    java.io.IOException: dev1.janusx-collections.com:80//iras/JavaClassFiles/AppletForm.jar
    at com/ms/net/wininet/http/HttpInputStream.connect
    at com/ms/net/wininet/http/HttpInputStream.<init>
    at com/ms/net/wininet/http/HttpURLConnection.createInputStream
    at com/ms/net/wininet/WininetURLConnection.getInputStream
    at com/ms/vm/loader/JarArchiveSet.loadNextJar
    at com/ms/vm/loader/JarArchiveSet.getResourceBits
    at com/ms/vm/loader/JarArchiveSet.getClassData
    at com/ms/vm/loader/ResourceLoader.getClassData
    at com/ms/vm/loader/URLClassLoader.findClass
    at com/ms/vm/loader/URLClassLoader.loadClass
    at com/ms/vm/loader/URLClassLoader.loadClass
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.run
    at java/lang/Thread.run
    java.lang.ClassNotFoundException: TaxPaymentAppletForm
    at com/ms/vm/loader/URLClassLoader.loadClass
    at com/ms/vm/loader/URLClassLoader.loadClass
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.run
    at java/lang/Thread.run
    ON Netscape it is NOT running at all on from live server and error is as given in above first post.
    manisha

  • Java Applets with AWT

    Hi,
    I have the problem to display the applet with AWT. If I am running the same applet in the internal server it works fine.If I am running through the web its giving Class not found exception.That web server also is mapped into the same server.
    Here is the code.
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class NotHelloWorldApplet extends Applet
    public void init()
         try{
              setLayout(null);
              Label label1= new Label("Hello World!");
              label1.setSize(200,200);
              add(label1);
         }catch(Exception e){System.out.println(e);}
    <html><body>
    <applet
    code="NotHelloWorldApplet"
    codebase="."
    width=600 height=400
    >
    </applet>
    </body></html>
    can anyone help me please.
    Thanks

    Hello,
    Even I executed the program. Its works fine. I guess you must be having problem with the codebase. Just change the address in the codebase from current directory to the address where the class file is there and also change the permissions(set attributes to 755) of the class file. Hope this helps you.
    Regards,
    Sarada.

  • Sharing an applet with another dosn't function

    Hi all,
    i have a problem that i share an applet with another, but it dosn't function:
    i have two applet: epurse & bank   (bank is the master)
    for that i creat a class "bankInterface" that's inherit from sharable:
    package pack4;
    import javacard.framework.APDU;
    import javacard.framework.Shareable;
    public interface bankInterface extends Shareable {
      public void debit(APDU apdu);
    bank's declaration:
    public class bank extends Applet implements bankInterface {
    public Shareable getShareableInterfaceObject (AID clientAID, byte param){
      return ((bankInterface)this);  //or return this;
    public  void deselect(){
          pin.reset();
      public boolean select() {
           return super.select();
      public static void install(byte bArray[], short bOffset, byte bLength) throws ISOException {
           new bank();
    private bank() {
      register();
    public void process(APDU apdu) throws ISOException {
    public void debit(APDU apdu){
    //empty juste for testing
    }// end class 'bank'
    epurse's declaration:
    package pack4;
    import ...
    public class epurse extends Applet {
    byte[] AIDServer=new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x00, 0x00, 0x00};
    public bankInterface sio;
    private epurse() {
      sio=(bankInterface) JCSystem.getAppletShareableInterfaceObject(JCSystem.lookupAID(AIDServer, (short)0, (byte)AIDServer.length), (byte)0);
    //methods: install, select, deselect
    public void process(APDU apdu) throws ISOException {
    byte[] apduBuffer=apdu.getBuffer()
    if(apduBuffer[ISO7816.OFFSET_CLA] == (byte)0x80){
      switch(apduBuffer[ISO7816.OFFSET_INS]){
      case (byte)0x34:
      credit(apdu);break;
    else{ ...}
    }//end process
    private void credit(APDU apdu){
    apdu.setIncomingAndReceive();
    sio.debit(apdu); // if this line is commented, i get the sw1:90 sw2: 00; else i get sw1: 6f sw2: 00 (wrong length)
    }// end class epurse
    i don't know where's the problem?

    Hi,
    If you go through the SIO concepts of JavaCard its mentioned that when "getAppletShareableInterfaceObject" is called from the client the JCRE will call "getShareableInterfaceObject" method of server with clientAID but where as you are requesting for SIO in install method before registration where the clientAID doesnt exists so the call will fail and return "null" and further references to SIO object will fail to perform expected operations.
    So put request for SIO after registration of your client applet.
    BR,
    PPT

  • Applets and server scripts

    Hi,
    I'm trying to run a java applet with a web application I'm developing, but I'm having some trouble running it.
    I have a dll which generates html pages dynamically, and in one of the pages i want to call an applet, but I keep getting an error that the class cannot be found.
    running this on a personal webserver, I have my scripts in the "inetpub/scripts" directory, and I've tried putting my packages under the scripts sub directory, and in the wwwroot directory, as well as the inetput directory, but i still get the error.
    in the applet tag, I have <applet code=package.classname.class ...>
    i have also created the html page on its own, as a seperate html file, and the page works.. i only get the error when the .dll is generating the html page.
    any help would be much appreciated.
    thanks!
    dtudino.

    When you pull up one of you DLL pages in your browser, you get some URL like
    http://www.somedomain.com/somepath/Generated.html
    If your <applet> tag has no codebase parameter, it expects the applet to be in
    http://www.somedomain.com/somepath/package/classname.class
    There could be a couple of problems here. First, maybe your HTML generator has the directory security set so that nothing can be served directly from it.
    Try using the codebase parameter of the <Applet> tag
    <applet code="package.classname.class" codebase="http://www.somedomain.com/someotherpath" ...>
    I don't like to use absolute paths in <applet> tags, but it will work for debugging.
    Next, if you are using a jar file, you need to have an archive parameter in your <applet> tag.

  • How to get started on java applet client/server game?

    Hi,
    I've googled, but didn't find any useful information about creating java applet client/server game. I've followed the example of Client/Server Tic-Tac-Toe Using a Multithreaded Server in Java How to Program from Deitel, but I when I tried on Applet, my cliet doesn't communicate with the server at all. Any help to get started with Applet would be great. Thanks!

    well, i decided to put in portion of my codes to see if anyone can help me out. the problem I have here is the function excute() never gets called. here is my coding, see if you can help. Notice, I'm running this on Applet thru html page. This shouldn't be much different than running JFrame in term of coding right?
    Server.java
        public void init()
            runGame = Executors.newFixedThreadPool(2);
            gameLock = new ReentrantLock();
            otherPlayerConnected = gameLock.newCondition();
            otherPlayerTurn = gameLock.newCondition();
            players = new Player[2];
            currentPlayer = Player1;
            try
                server = new ServerSocket(12345, 2);
            catch (IOException ie)
                stop();
            message = "Server awaiting connections";
        public void execute()
           JOptionPane.showMessageDialog(null, "I'm about to execute!", "Testing", JOptionPane.PLAIN_MESSAGE);
            for(int i = 0; i < players.length; i++)
                try
                    players[i] = new Player(server.accept(), i);
                    runGame.execute(players);
    catch (IOException ie)
    stop();
    gameLock.lock();
    try
    players[Player1].setSuspended(false);
    otherPlayerConnected.signal();
    finally
    gameLock.unlock();
    Client.java
        public void init()
            startClient();
        public void startClient()
            try
                connection = new Socket(InetAddress.getByName(TienLenHost), 12345);
                input = new Scanner(connection.getInputStream());
                output = new Formatter(connection.getOutputStream());
            catch (IOException ie)
                stop();
            ExecutorService worker = Executors.newFixedThreadPool(1);
            worker.execute(this);
        }So after worker.execute(this), it should go to Server.java and run the function execute() right? But in my case, it doesn't. If you know how to fix this, please let me know. Thanks!

Maybe you are looking for

  • Need to remove gap at front of track

    I have a 1 track stereo recording, and there is a 10 second gap in front of the track (there was some junk sound there that I deleted). I need to export the track, with no 10 second gap in front. I can't just drag the track to eliminate the gap becau

  • Running Final Cut Studio 2 with only 512 MB

    I have 2 older mac mini's laying around and I would like to put them to work. I was thinking that they could log and capture and only do that. If they are logging, then the other computers are freed up to edit. The problem that I am having is that th

  • PDF Link Download Issue

    I have created an answer and have a column as a Link.When i try to download this report in PDF , i am getting the entire < a href > tag in the download . How to avoid that

  • Text starts to move  after selection

    my dynamic text starts moving from left to right after selection that content in text field ,please reply

  • BUS2205 - Tolerances are not considered when 2nd Invoice is created for PO

    Dear all, I have the following problem with invoice in SRM7.0 and standalone scenario. The following tolerances are set up: DA, DQ and PP PO 1234 - P1   50 ST   1,06 EUR  => 53 EUR - P2   60 ST   0,50 EUR  => 30 EUR INV 3001 - P1  40 ST  1,50 EUR  =>