Swing based applet communication with javascript

Hi
In my browser based application, the GUI has two part one contains the swing based applet and other is html based text area. Applet contains the list of text files.
My requirements is that if user double clicks on a file the, text area should display the name or path or content of file. I facing problem at very first level, how to capture the swing event in java script of browser?
Thanks in advance!!! :)

Hi
In my browser based application, the GUI has two part one contains the swing based applet and other is html based text area. Applet contains the list of text files.
My requirements is that if user double clicks on a file the, text area should display the name or path or content of file. I facing problem at very first level, how to capture the swing event in java script of browser?
Thanks in advance!!! :)

Similar Messages

  • Running the Swing based applet in html

    Hi
    I am getting problem while runing a swing based applet in html. If i am using eclips and run my file as java applet it is working fine.
    For testing purpose, my html and all jars are in the same folder where my applet class is reside.
    Also i am not getting any error in html..
    Please help

    http://java.sun.com/docs/books/tutorial/deployment/applet/index.html

  • Swing based applets don't run in browser !!!

    whenever i run a swing based applet from the browser (IE 5), the applet is not displayed in it - status bar shows that the class file was not found
    so please tell me the solution
    thanx in advance!

    You just have to download Sun JVM to run swing JApplet in your browser(IE).
    get it at the following address:
    Just follow the link, and download dialog will be appeared just save the file to you hard drive, and install the software.
    The file name will be : "j2re-1_4_1_02-windows-i586-i.exe"
    http://java.sun.com/webapps/download/AutoDL?BundleId=7544
    after successfull installation you'll find the new plugin
    "java2 v1.4.1_02 for<applets>"
    in Tools>InternetOptions>Advance
    you have to check it(if unchecked) to enable the JApplet to be loaded in your browser.
    Another new option you'll find in your Tools menu "Sun Java Console". From it you can find what exceptions are thrown while the applet is loaded

  • Call applet method with javascript

    my html - code:
    <APPLET NAME="Mail" ... ... ></APPLET>
    <form action="javascript:document.applets("Mail").test("Execute JAVA Applet Function")">
    <input type="submit" value="Execute Applet Function">
    </form>
    my applet code:
    public void test(String t)
    {System.out.println("executing test()");
    teststr = t;
    repaint();
    in the paint() method i draw the teststr with Graphics.drawString - but nothing happens...
    any suggestions?
    thx

    Directly calling a Java Applet's public method from within
    JavaScript is made possible by LiveConnect which is not implemented by Internet Explorer as of yet. LiveConnect is only available on Netscape navigator at this time.

  • Changing applet parameters with Javascript

    Is it possible to have an applet read a param value which has been changed with Javascript after the applet loads?
    I've tried changing the param value in this way, but the applet doesn't read the new value. It reads the default value in the HTML when the applet loads, and getParameter is in the main loop of the applet which runs and updates other (internal) values fine...

    Well that page says that param values can't be changed at run-time. Never mind though because I read some more and found out how to implement a method in the applet (which can be called from Javascript) that reads the host page's DOM, thereby achieving the same result.
    Thanks for the pointer.

  • Applet communication with struts servlet

    Hi
    I�ve seen a lot of examples where a Java applet communicates with a servlet.
    I�ve made a web application using Struts, and i would like to know if it is possible to use an applet (View) and send to Stuts some data, I mean, call an action like http://localhost:8080/ViewRoads.do.
    Is it possible? ,Where can I find some examples about?, could anyone explain how would it work?, any good book to read about?.
    Thank you.

    I'm sorry but don't you have a communication source code example between a servlet and an applet that does work ? I'm looking for one of these since Two days already.
    thanks

  • Applet communication with DLL

    Hi,
    Can an applet communicate with Microsoft DLL.
    I want to save the content of an applet to database at server side.
    Problem is there is no java envirnoment at server side (it has dlls).
    What is the best way to do this. The content of the applet has to be savea at sever side not at client.
    Thanx

    deepakshettyk,
    Two options that come to mind are:
    1) have the applet use JDBC to connect to its host server's database directly. Typically this entails having type4 JDBC drivers installed and available.
    2) have the applet itself connect back to its host server's webserver (IIS?), and have a server-side agent (ASP?) record data sent back to a database. See Marty Hall's book, 'Servlets & JSP', from Prentice Hall, for code examples.
    --A                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Doubt about applet communicating with the SIM

    Greetings,
    I have this doubt: I am developing a web site which contains a java applet. The web site is going to be available at some web server. The web site is going to be accessed by mobile phones. The idea is that, somehow, the applet communicates with the mobile phone and extract info from the SIM Card for authentication. I still wondering if it is possible and the possible drawbacks or alternatives.
    Thank you in advance,
    Fernando

    Hi,
    you definitely have to sign your applet to do that.
    Check in the forum "Security -> Signed applet". You'll find the information you need to sign an applet.
    For example check at: http://forum.java.sun.com/thread.jsp?forum=63&thread=174214

  • Problem in Signed Applet while communicating with Javascript

    Hi,
    I’m facing a problem with applet. Applet calls JavaScript methods and vice versa. Applet works fine with JRE 5 to JRE 6 up to build no 1.6.0._7 but it fails with build no 1.6.0_10.
    The problem description is given below:
    After embedding applet in my HTML page using <OBJECT> tag, I’ve to check either any problem during applet’s execution, I want to get the error reason by calling my defined method getErrorReason() in applet that returns the error reason, I call the getErrorReason() against the applet’s object in JavaScript immediately after embed applet code in my HTML page, a JavaScript errors occurs and my applet fails to perform its execution.
    JavaScript error: Object does not support this property.
    The error points to the HTML page area where I’m calling getErrorReason() against applet object.
    The above JavaScript error occurs after the successful completion of Applet’s init(). I’m facing this problem only in JRE 6 build 1.6.0_10-b33.
    Please suggest me any solution.
    Thanks in advance.
    Regards,
    Israr Ahmed

    We are using the HttpURLConnection. If I have to go down the stack to the Socket object, well I guess I have to re event the wheel so to speak.
    I have tried both Connection: close and Connection: Keep-Alive. Not at the same time :) but in different intrim releases of test applet.
    // Here is the current incarnation of how I am trying to connect.
    URL url = new URL(sURL);
    trace("attempting to connect to URL: " + sURL, DEBUG);
    connection = (HttpURLConnection)url.openConnection();
    connection.setDoOutput(true);
    connection.setDoInput( true );
    connection.setRequestMethod("POST");
    connection.setUseCaches( false );
    connection.setInstanceFollowRedirects( true );
    connection.setAllowUserInteraction( false );
    connection.setRequestProperty("Pragma", "no-cache");
    connection.setRequestProperty("Expires", "-1");
    connection.setRequestProperty("Connection", "Keep-Alive");
    connection.connect();
    // Now I write our form POST data and flush and close the output stream.
    BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
    bos.write(sForm.getBytes());
              bos.flush();
    bos.close();
    // Get the input and read
    bis = new BufferedInputStream(connection.getInputStream());
    trace( "reading input stream for action: " + sAction );
    byte[] responseBuffer = new byte[4096];
    int bytesRead = 0;
    while( (bytesRead = bis.read( responseBuffer, 0, responseBuffer.length )) != -1 )
    sbResponse.append( new String( responseBuffer, 0, bytesRead ));
    totalBytesRead += bytesRead;
    catch (Throwable e)
    e.printStackTrace();
    try
    m_connections.remove( sAction );
    connection.disconnect();
    catch ( Throwable t ) {}
    finally
    if ( bis != null )
    try
    bis.close();
    catch( Throwable t ) {}
    With the above code in place what I am now seeing, as opposed to a premature EOF exception, is blocking behavior on the read.

  • Problem in Applet while communicating with Javascript

    Hi,
    I’m facing a problem with applet. Applet calls JavaScript methods and vice versa. Applet works fine with JRE 5 to JRE 6 up to build no 1.6.0._7 but it fails with build no 1.6.0_10.
    The problem description is given below:
    After embedding applet in my HTML page using <OBJECT> tag, I’ve to check either any problem during applet’s execution, I want to get the error reason by calling my defined method getErrorReason() in applet that returns the error reason, I call the getErrorReason() against the applet’s object in JavaScript immediately after embed applet code in my HTML page, a JavaScript errors occurs and my applet fails to perform its execution.
    JavaScript error: Object does not support this property.
    The error points to the HTML page area where I’m calling getErrorReason() against applet object.
    The above JavaScript error occurs after the successful completion of Applet’s init(). I’m facing this problem only in JRE 6 build 1.6.0_10-b33.
    Please suggest me any solution.
    Thanks in advance.
    Regards,
    Israr Ahmed

    Hi Bharath,
    Even i got similar error and i tried deleting the below(Attaching the stack trace is always better way.)
    1) delete the folder ‘workspace’ or rename(including all files and subfolders) in the path D:\Documents and Settings\lzcr8r\Documents\SAP\workspace
    2) delete all .dtr/.dtc/.metadata directories in your personal folder (e.g. C:\Documents and Settings\lzcr8r).
    Restart the IDE once you are done with the above steps.
    Second part to increase the virtual mem
    1) RtClick on the Shortcut of NWDS -->Properties and in the Target put the below
    "C:\Program Files\SAP\IDE\IDE70\eclipse\SapIde.exe" -vmargs -Xms512m -Xmx1536m  "C:\j2sdk1.4.2_08\bin\javaw.exe"
    2) You can also try  Creating a bat file with the complete path of your IDE and start your ide from the bat
       content in the bat eg: "C:\Program Files\netbeans-4.1\bin\netbeans.exe" -vmargs -Xms512m -Xmx1536m
    Here -Xms512m is the min JVM size and -Xmx1024m is the max JVM size.
    You can place this batch file anywhere and double click the batch file.
    It will automatically start your IDE
    3) if you are using Tomcat you can try creating an env variable and assign Value
    Variable Name:  CATALINA_OPTS
    Variable Value:  -server -Xmx800m
    please award points if usefull.
    Regards
    Souza
    Edited by: Souza Aluri on Apr 9, 2008 9:46 AM

  • How can i connect multiple forms using swings or applets(AWT) & with D-Base

    Hello Friends,
    I am Sreedhar from Hyderabad. working as a java developer in a small organization. I got a challenge to work on java stand alone (desktop) application. Basically our company is based on SCM(Supply Chain Management), I never work before using swings and AWT. now my present challenge is to develope an application on swings and AWT using Net Beans IDE. but i am unble find the code to connect one form to another form, i want to develop similar application like a web application , suppose if i click on OK button it has to connect next form. in the next for it has to take user name and password should allow me to access main form. please help me about this topic, if anybody interested i can send u the screen shots and i can post to ur mail. please help me as soon as possible,

    sreedharkommuru wrote:
    Hello Friends,
    I am Sreedhar from Hyderabad. working as a java developer in a small organization. I got a challenge to work on java stand alone (desktop) application. Basically our company is based on SCM(Supply Chain Management), I never work before using swings and AWT. now my present challenge is to develope an application on swings and AWT using Net Beans IDE. but i am unble find the code to connect one form to another form, i want to develop similar application like a web application , suppose if i click on OK button it has to connect next form. in the next for it has to take user name and password should allow me to access main form. please help me about this topic, if anybody interested i can send u the screen shots and i can post to ur mail. please help me as soon as possible,There is no magic, you need to spend a good amount of time in tutorials, here is a good one to start off with:
    [The Really Big Index|http://java.sun.com/docs/books/tutorial/reallybigindex.html]
    Here are a few tips:
    1 - Do not mix AWT and SWING: it'll just cause you headaches in the long run that you cannot fix without refactoring to properly not mix the 2 together.
    2 - You use JDBC to access the database
    3 - You make accessors/constructors to pass parameters that you need from one form to another.
    Have fun.

  • Intercepting applet clicks with javascript

    I have an applet that runs in a jsp.
    Is it possible without changing the code of the applet
    to handle events of the applet like onmouseup in javascript?
    For example -when the user clicks on the applet I want to know that
    via javascript.
    Thanks.

    Not sure if it is possible with out changing the Applet code but to do Applet-JavaScript interaction you use LiveConnect
    http://java.sun.com/products/plugin/1.3/docs/jsobject.html

  • How can I use URLConnection to use applet communication with servlet?

    I want to send a String to a servlet in applet.I now use URLConnection to communicat between applet and servlet.
    ====================the applet code below=========================
    import java.io.*;
    import java.applet.Applet;
    import java.awt.*;
    import java.net.*;
    //I have tested that in applet get data from servlet is OK!
    //Still I will change to test in applet post data to a servlet.
    public class TestDataStreamApplet extends Applet
    String response;
    String baseurl;
    double percentUsed;
    String total;
    public void init()
    try
    java.net.URL url = new java.net.URL(getDocumentBase(),"/servlet/dataStreamEcho");
    //String currenturl=new String("http://lib.nju.edu.cn");
    java.net.URLConnection con = url.openConnection();
    //URL currentPage=getCodeBase();
    // String protocol=currentPage.getProtocol();
    // String host=currentPage.getHost();
    //int port=currentPage.getPort();
    // String urlSuffix="/servlet/dataStreamEcho";
    // URL url=new URL(protocol,host,port,urlSuffix);
    // URLConnection con=url.openConnection();
    con.setUseCaches(false);
    con.setDoOutput(true);
    con.setDoInput(true);
    ByteArrayOutputStream byteout = new ByteArrayOutputStream();
    PrintWriter out=new PrintWriter(byteout,true);
    String currenturl=new String("http://lib.nju.edu.cn");
    String var1=this.encodedValue(currenturl); //encode the data
    String data="currenturl="+var1;
    out.print(data);
    out.flush();
    con.setRequestProperty("Content-Length",String.valueOf(byteout.size()));
    con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    byteout.writeTo(con.getOutputStream());
    BufferedReader in=new BufferedReader(new InputStreamReader(con.getInputStream()));
    String line;
    while((line=in.readLine())!=null)
         System.out.println(line);
    catch (Exception e)
    e.printStackTrace();
    private String encodedValue(String rawValue)
         return(URLEncoder.encode(rawValue));
    =========================The servlet code below=====================
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class DataStreamEcho extends HttpServlet
    {public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
          res.setContentType("text/plain");
          PrintWriter out = res.getWriter();
          Runtime rt = Runtime.getRuntime();
          out.println(rt.freeMemory());
          out.println(rt.totalMemory());
          response.setContentType("text/html; charset=GBK");     
          request.setCharacterEncoding("GBK");
          PrintWriter out = response.getWriter();
          HttpSession session=request.getSession();
          ServletContext application=this.getServletContext();
          String currenturl=(String)session.getAttribute("currenturl");
          out.print(currenturl);
    =============================================================
    I have done up,but I found the program don't run as I have thought.
    Can you help me to find where is wrong?Very thank!

    You are trying to pass the current URL to the servlet
    from the applet, right?
    Well, what I put was correct. Your servlet code is
    trying to read some information from session data.
    request.getInputStream() is not the IP address of
    anything...see
    http://java.sun.com/products/servlet/2.2/javadoc/javax
    servlet/ServletRequest.html#getInputStream()
    Please read
    http://www.j-nine.com/pubs/applet2servlet/Applet2Servle
    .htmlNo,you all don't understand I.
    I want to send an Object to the server from a applet on a client.not url only.I maybe want to send a JPEG file instead.
    All I want is how to communicate with a servlet from an applet,send message to servlet from client's applet.
    for example,Now I have a method get the desktop picture of my client .and I want to send it to a server with a servlet to done it.How can I write the applet and servlet program?
    Now my program is down,But can only do string,can't not done Object yet.Can anyone help me?
    =======================applet=============================
    public void init()
    try
    java.net.URL url = new java.net.URL(getDocumentBase(),"/servlet/dataStreamEcho");
    //String currenturl=new String("http://lib.nju.edu.cn");
    java.net.URLConnection con = url.openConnection();
    //URL currentPage=getCodeBase();
    // String protocol=currentPage.getProtocol();
    // String host=currentPage.getHost();
    //int port=currentPage.getPort();
    // String urlSuffix="/servlet/dataStreamEcho";
    // URL url=new URL(protocol,host,port,urlSuffix);
    // URLConnection con=url.openConnection();
    con.setUseCaches(false);
    con.setDoOutput(true);
    con.setDoInput(true);
    ByteArrayOutputStream byteout = new ByteArrayOutputStream();
    PrintWriter out=new PrintWriter(byteout,true);
    String currenturl=new String("http://lib.nju.edu.cn");
    String var1=this.encodedValue(currenturl); //encode the data
    String data="currenturl="+var1;
    out.print(data);
    out.flush();
    con.setRequestProperty("Content-Length",String.valueOf(byteout.size()));
    con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    byteout.writeTo(con.getOutputStream());
    con.connect();
    BufferedReader in=new BufferedReader(new InputStreamReader(con.getInputStream()));
    String line;
    while((line=in.readLine())!=null)
         System.out.println(line);
    catch (Exception e)
    e.printStackTrace();
    =======================servlet=============================
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         response.setContentType("text/html; charset=GBK");
    //request.setCharacterEncoding("GBK");
    PrintWriter out = response.getWriter();
    HttpSession session=request.getSession();
    ServletContext application=this.getServletContext();
    //String currenturl=(String)session.getAttribute("currenturl");
    String currenturl=(String)request.getParameter("currenturl");
    out.print(currenturl);
    File fileName=new File("c:\\noname.txt");
    fileName.createNewFile();
    FileOutputStream f=new FileOutputStream(fileName); //I just write the String data get from
    //applet to a file for a test.
    byte[] b=currenturl.getBytes();
    f.write(b);
    f.close();
    }

  • Servlet to applet communication: with out polling

    hi,
    i need to write an applet which captures the realtime data as it appears in the server. Is this possible with out polling ther server at constant intervals? i.e... is it possible for the server to push data to an applet (say applet first registers etc etc with the server)
    One more thing..say applet had opened a connection with server and opened a stream. Now is it possible for it to keep listening over the connection so that server puts the info over the connection when ever it has it and the client displays the info when ever it receives it.
    Any pointers would be helpful.

    [email protected] wrote:
    hi,
    i need to write an applet which captures the realtime data as it appears in the server. Is this possible with out polling ther server at constant intervals? i.e... is it possible for the server to push data to an applet (say applet first registers etc etc with the server)sure it's possible
    One more thing..say applet had opened a connection with server and opened a stream. Now is it possible for it to keep listening over the connection so that server puts the info over the connection when ever it has it and the client displays the info when ever it receives it.
    Any pointers would be helpful.i'm not sure what the best way is, but I've done it with Sockets and ObjectOutputStream

  • Synchronizing Applet Initialization with JavaScript

    In reference to the thread Getting the input values in xacute query
    I want to:
    1.  pass a parameter value from an HTML form to my xacute query
    2.  not have the applet running the query run until after the HTML form's Submit button has been pressed

    David,
    I hope my response in that thread was helpful.
    Regards,
    Michael Teti

Maybe you are looking for