JavaScript -Applet Communication problem

Hi All,
Requirement : Onclick of particular location of loaded applet. I am calling JavaScript function which will render the table(as a popup like a bubble).
Problem Description:
I am calling below javascript function from Applet. Javascript function contains the code which create a table (popup). We have verified the JS function and it is displaying in normal HTML.
JavaScript Function
function CreateBubble(txt)
var t= GetElement('TABLE');
//t.style.background = 'white';
t.cellSpacing=0;
t.cellPadding=0;
var r,c;
r=t.insertRow();
c=r.insertCell();
c.innerHTML='<img src="images/nw.gif">';
c=r.insertCell();
c.innerHTML='<img src="images/n.gif">';
c.style.background = 'url("images/n.gif")';
c=r.insertCell();
c.innerHTML='<img src="images/ne.gif">';
r=t.insertRow();
c=r.insertCell();
c.innerHTML='<img src="images/w.gif">';
c.style.background = 'url("images/w.gif")';
c=r.insertCell();
c.style.background = 'url("images/1.gif")';
c.style.backgroundColor='white';
if(txt.tagName)
c.appendChild(txt);
else
c.innerHTML=txt;
c=r.insertCell();
c.innerHTML='<img src="images/e.gif">';
c.style.background = 'url("images/e.gif")';
r=t.insertRow();
c=r.insertCell();
c.innerHTML='<img src="images/sw.gif">';
c=r.insertCell();
c.innerHTML='<img src="images/s.gif">';
c.style.background = 'url("images/s.gif")';
c=r.insertCell();
c.innerHTML='<img src="images/se.gif">';
return t;
function GetElement(t){return document.createElement(t);}
When I call CreateBubble(txt) function from Applet. It is not rendering table. If i put the alert inside the function then it displays. I tried to debug by puttting alert before return statement of the JS function. It still display the alert box, but doesn't display the table.
I am not sure but the applet might be overshadow the table created through java-script.
This is my applet code:
public void mouseClicked(MouseEvent e)
          System.out.println( "Mouse clicked in applet - Getting JSObject" );
          System.out.println(("X, Y :" + e.getX() + "," +e.getY()));
          //First segement point
          if(e.getX() > 200 && e.getX() < 212){
               JSObject jso = JSObject.getWindow( enclosingContainer );
               System.out.println( "Getting JSObject - SUCCESS" );
               System.out.println( "Invoking the script..." );
               String [] args = new String[] {"acdd"};
               jso.call("CreateBubble", args);
Let me know are there any other approach to do so?
Thanks
Chintan

Only pass strings between applets and JS. They both use unicode, so it works. Other data types, including primitive, don't work well.
In your JS code, you say, txt.tagName. This doesn't make sense if txt is a string.
Also, your Java code to call the JS looks funny. See the Java code in reply #11 in this thread: http://forum.java.sun.com/thread.jspa?forumID=421&threadID=482551

Similar Messages

  • Is jre1.4 still support javascript to applet communication?

    is jre1.4 still support javascript to applet communication?
    I can't get the method in applet from javascript in jre1.4. Are there have a different way to communication?

    I have a similiar problem. Left a post in the Signed Applet board. I can get the methods called on my applet when operating over HTTP, but when I am on a page served from HTTPS, the browser chews up memory, goes to 100% processor utilization, and the method is never called. This is with the 1.4 plugin.
    Suppose this is related ?

  • Servlet Applet object communication problem???!!!

    Hy folks,
    I need to validate the ability of complex Servlet Applet communication an run into my first pb right at the beginning of my tests. I need to have around 200 Applet clients connect to my servlet and communicate by ObjectInput and ObjectOutput streams. So I wrote a simple Servlet accepting HTTP POST connections that return a Java object. When the java Applet get instantiated, the Object Stream communication workes fine. But when the Applet tries to communicate with the servlet after that, I can not create another communication session with that Servlet, instead I get a 405 Method not allowed exception.
    Summarized:
    - Applet init() instantiate URLConnection with Servlet and request Java object (opening ObjectInput and Output Stream, after receaving object, cloasing streams).
    - When I press a "get More" button on my Applet, I am not able to instantiate a new URLConnection with my servler because of that 405 exception, WHY???
    Here my Servlet code:
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
             ObjectInputStream inputFromApplet = null;
             ArrayList transmitContent = null;       
             PrintWriter out = null;
             BufferedReader inTest = null;
             try{               
                   inputFromApplet = new ObjectInputStream(request.getInputStream());           
                     transmitContent = (ArrayList) inputFromApplet.readObject();       
                     inputFromApplet.close();
                     ArrayList toReturn = new ArrayList();                 
                     toReturn.add("One");
                     toReturn.add("Two");
                     toReturn.add("Three");
                     sendAnsweredList(response, toReturn);                 
             catch(Exception e){}        
         public void sendAnsweredList(HttpServletResponse response, ArrayList returnObject){
             ObjectOutputStream outputToApplet;    
              try{
                  outputToApplet = new ObjectOutputStream(response.getOutputStream());          
                  outputToApplet.writeObject(returnObject);
                  outputToApplet.flush();           
                  outputToApplet.close();              
              catch (IOException e){
                     e.printStackTrace();
    }Here my Applet code:
    public void init() {         
             moreStuff.addActionListener(new ActionListener(){
                  public void actionPerformed(ActionEvent e){
                       requestMore();
             try{
                  studentDBservlet = new URL("http://localhost/DBHandlerServlet");              
                  servletConnection = studentDBservlet.openConnection();      
                   servletConnection.setUseCaches (false);
                   servletConnection.setDefaultUseCaches(false);
                   servletConnection.setDoOutput(true);
                   servletConnection.setDoInput(true);
                   ObjectOutputStream outputToApplet;
                 outputToApplet = new ObjectOutputStream(servletConnection.getOutputStream());          
                 outputToApplet.writeObject(new ArrayList());
                 outputToApplet.flush();           
                 outputToApplet.close(); 
                   ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
                   ArrayList studentVector = (ArrayList) inputFromServlet.readObject();
                   area.setText("Success!\n");
                   for (int i = 0; i<studentVector.size(); i++) {
                        area.append(studentVector.get(i).toString()+"\n");
                  inputFromServlet.close();
                  outputToApplet.close();             
              catch(Exception e){
                   area = new JTextArea();
                   area.setText("An error occured!!!\n");
                   area.append(e.getMessage());
            getContentPane().add(new JScrollPane(area), BorderLayout.CENTER);
            getContentPane().add(moreStuff, BorderLayout.SOUTH);
        private void requestMore(){
             try{              
                  studentDBservlet = new URL("http://localhost/DBHandlerServlet");                             
                  servletConnection = studentDBservlet.openConnection(); 
                   ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
                   ArrayList studentVector = (ArrayList) inputFromServlet.readObject();
                   area.setText("Success2!\n");
                   for (int i = 0; i<studentVector.size(); i++) {
                        area.append(studentVector.get(i).toString()+"\n");
              catch(Exception e){               
                   area.setText("An error occured2!!!\n");
                   area.append(e.getMessage());
        }Can someone help me solv this issue please, this is my first Applet Servlet work so far so I have no idea on how to solve this issue.

    Sorry folks, just found my error. Forgot about the ObjectInputStream waiting on the Servlet side, so of course had a dead look...
    Sorry!

  • How would/should you invoke a javascriptable applet from WDA or WDJ?

    The background to this question is here:
    OK - finally a bioinformatic coding problem that may not be so easy ...
    The question is as follows.
    Suppose you have a javascriptable applet - that is, an applet whose behavior can be tailored by passing it certain parameters from javascript.
    What would the best way be to invoke the javascript from WDA or WDJ, assuming that you wanted to "pop" the applet in a separate HTML frame within tne WDA or WDJ application?

    Anton -
    Glad to see you contributing again!
    Well, your original comment about RasMol shamed me into doing some research into molecular viewers callable as applets.
    Here are the latest responses I've gotten from Angel Herraez at Jmol.  (You might find it fun to join the Jmol project at SourceForge and also subscribe to its jmol-users list-server.)
    I told Angel that here's what I want to do:
    > 1) we're in Frame1 of a portal that has two other frames in it: FrameA and
    > FrameB.
    >
    > 2) A query in Frame1 against a certain database brings back two sets of
    > specifications for Jmol, say:
    >
    > a 1hru, A, 123-145
    > b) 2eqa, A, 144-167
    >
    > 3) Via "client-side eventing" at the portal level , the portal passes the
    > parameters in (a) to JMol and Jmol runs in FrameA to display the "partial"
    > structure view requested (with rotate capability, same as in interactive
    > JMol;
    >
    > 4) At the same time , the portal passes the parameters in (b) to JMol and
    > Jmol runs in FrameB to display the "partial" structure view requested (with
    > rotate capability, same as in interactive JMol;
    >
    > Is this scenario currently possible as JMol is currently written?
    He then responded:
    As long as you have already set the means to communicate with the
    Jmol applets in your portal system, I think it is indeed.
    This is what I'd pass to Jmol in FrameA:
    load "1hru.pdb"; display *:A and 123-145;
    and this to jmol in FrameB:
    load "2eqa.pdb"; display *:A and 144-167;
    (you will have to adjust the loading of the pdb file depending on
    where it is located)
    "display" is a better choice than the alternative, "restrict", for
    reason I won't discuss now (but we can separately, if you need it)
    Depending on your ways of inserting Jmol into your frames, there may
    be some details to solve, but on the Jmol scripting side that's all
    needed.
    > Or would I have to settle for the portal simply invoking Jmol in FrameB
    > and again in FrameC and letting the user manipulate settings in the
    > console, as you suggest.
    No, I won't suggest so, you can indeed preprogram what you want.
    I also asked him about capturing the views after rotating in each frame to get the desired view of each structure, and here's his response to that:
    Yes, the views can be captured to the user's computer, in a web page
    (e.g. popup window) from where the user can copy or save them to
    disk, using the browser's capabilities.
    If you need to "capture" to the server, I cannot say *but see below.
    The discussion on how to make snapshots is quite long. There are
    several mesages in the list some time ago and there are several
    places that use this functionality; Bob has at least one, I dont0
    remember exactly where right now, and I have a testpage/tutorial at
    http://biomodel.uah.es/Jmol/export-image/index.htm
    See if you can make it from that, then ask if you need help.
    >From the screenshot, displayed inside the browser, you can save
    directly to your disk in some browsers, or else copy-paste into any
    image editing program (I would not recommend Powerpoint, as the
    quality of saved images is poor). You get a jpeg file directly.
    Now that I think of it, in fact all the trouble was getting the
    server-generated image into the client browser, so there should be a
    way to store the image in the server maybe.
    Anyway, will you be in LasVegas?
    If so, will you be at SDN Community Day?
    If neither, do you have MS shareview ????
    Anyway, I will be talking soon (this weekend) in the WIKI about "alignments" and how I have to use them to get the results at StrucClues (http://strucclue.ornl.gov).
    This is where the really interesting and heavy regex-ing and returned html parsing is going to come in, so I hope you will remain interested long enough to solve the new propblems I am going to pose.  They will be much more related to real scripting problems - I just wanted to get this "view/rotate" issue out of the way, so that I could do an honest job at my SDN Community Day Session.
    Very best regards
    djh

  • Communication problems: A device attached to the system is not functioning.

    Hi all,
    I'm developing an applet and using the OMNIKEY 5321 CL reader for communication and testing. One of the requirements for our card is to read large binary data.
    For this purpose i used extented lenght APDU to read the data from card.
    When I tested it via JCOP simulation I was able to read up to 32767 bytes as described in specification. But problem occurs when I test it with reader, in this case I'm able to read max 298B in APDU response. When I send greater byte count than 298B i have got following error in JCShell plugin:
    jcshell: requestSessionKey.jcsh[1]: Error code: -6 (Card terminal error)
    jcshell: requestSessionKey.jcsh[1]: Communication problems: A device attached to the system is not functioning.
    Regarding the extend lengh APDU support it should by OK from the OMNIKEY. I'm using newest driver 1.2.9.2 for Win 7.
    Here my configuration:
    JCOP:JCOP 2.4.2r1
    JAVA CARD: jc301
    Global Platform: gp22
    Can somebody help me? Any ideas?

    If you want to use PC/SC directly, I have a simple Go program that reads an APDU file (just hex encoded APDU strings) and sends them to a smart card. You can give that a try if you like.
    The code is at: https://bitbucket.org/safarmer/go-apdus
    There is a Goclipse project as well as the source. You will need to install Go and run "go get github.com/ebfe/go.pcsclite/scard" to install the required PC/SC wrapper. Once you have done this you can run the program with -file <apth to text file>
    An example text file:
    # A comment that is ignored
    00a4040000
    80ca9f7f00- Shane

  • APPLET DELETION PROBLEM: CARD TERMIN AL ERROR

    Hello.
    I have developed several on-card packages. First is the library package (package1), containing no applets. And the other package (package2) contains serverApllet that uses libraries from the package1. The strange problem occurs during the deletion of the serverApplet package2. It has to be deleted first, only then a library package1 can be deleted.
    I've implemented uninstall() method of the serverApplet, that sets all references to the library instances to null and requests Objects deletion. The problem is:
    that after calling:
    delete -r |package2  //i.e. server package deletionJCOP Shell always returns JCException:
    jcshell: Error code: -6 (Card Terminal error)
    jcshell:Communication problems: nullIt allways happens, when I am deleting package2. After i connect to the same simulation session, there is no more serverApllet package2, i.e. it was deleted. Then a library package1 can be successfully deleted.
    Could anyone tell me what might be the reason of such an error?
    Now i am trying the deletion only in simulator. I am not sure in trying it on-card, because i am not sure that i will be able to delte it from the card.
    Thanks for a help,
    Best regards,
    Eve
    Message was edited by:
    Ieva

    Yes, your advice was very useful for me. I had to read JCVM and JCRE specification
    one time more. And i found out that certainly to make applet and its package deletable:
    1 .no references to static memory can remain (i.e. must be set to null);
    2. in case the shareable interface is used, we must have in mind that no references to server SIO objects must remain. Regarding this second sentence i have to poin, that i found out the example in Java Card Kit v2.2.2 with A, B and C applets using shareable interfaces and static references.
    I hope this might help people, who might koin the same problem.
    Thanks, lexdabear.
    Best regards,
    Eve

  • Servlet/Applet communication, data limit?

    I have an applet that uses a servlet as a proxy to load/retrieve images from an Oracle database. I have a problem when trying to retrieve images larger than 9-10kb from the database. When using JDBC from a Java Application I don't have any probelms but through the Applet-Servlet configuration I do.
    I use the following code in the Applet:
    URL url =new URL("http","myserver",myport,"/servlet/MyServlet");
    HttpURLConnection imageServletConn = (HttpURLConnection)url.openConnection();
    imageServletConn.setDoInput(true);
              imageServletConn.setDoOutput(true);
              imageServletConn.setUseCaches(false);
    imageServletConn.setDefaultUseCaches (false);
    imageServletConn.setRequestMethod("GET");
    byte buf[] = new byte[imageServletConn.getContentLength()];
    BufferedInputStream instr = new BufferedInputStream(imageServletConn.getInputStream());
    instr.read(buf);
    Image image = Toolkit.getDefaultToolkit().createImage(buf);
    // then code to display the image
    And the following for the Servlet:
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("image/gif");
    byte[] buff = loadImage(); // this method returns a byte array representing the image.
    response.setContentLength(contentLength);//contentLength is the size of the image
    OutputStream os = response.getOutputStream();
    os.write(buff);
    os.close();
    thanks in advance!

    thanks for your replay,
    I tried your suggestion but whatever I do it seems that tha applet only brings the first 5-10k of the image from the servlet. This is the value I get from instr.read() or any other type of read method. The value of bytes is not always the same.
    Now I also have something new. For images greater than 100k or so I get this error:
    java.io.IOException: Broken pipe
         at java.net.SocketOutputStream.socketWrite(Native Method)
         at java.net.SocketOutputStream.socketWrite(Compiled Code)
         at java.net.SocketOutputStream.write(Compiled Code)
         at java.io.BufferedOutputStream.write(Compiled Code)
         at org.apache.jserv.JServConnection$JServOutputStream.write(Compiled Code)
         at java.io.BufferedOutputStream.write(Compiled Code)
         at java.io.FilterOutputStream.write(Compiled Code)
         at interorient.DBProxyServlet.doGet(Compiled Code)
         at javax.servlet.http.HttpServlet.service(Compiled Code)
         at javax.servlet.http.HttpServlet.service(Compiled Code)
         at org.apache.jserv.JServConnection.processRequest(Compiled Code)
         at org.apache.jserv.JServConnection.run(Compiled Code)
         at java.lang.Thread.run(Compiled Code)
    I am using the Oracle Internet application server (ias 9i) which actualy uses the apache web listener.
    It seems that this servlet-applet communication is really unstable. If you have anything that may help me it will be greatly appriciated. You can even e-mail me at [email protected]
    thanks!

  • Inter Applet Communication across frames - Help Needed

    I am trying inter applet communication across frames. For this to happen I am using an intermidiate
    class which registers two applets and whenever any applet needs reference of other applet it gets it
    through this class.
    The page is an important part of a navigation link. So it is loaded many times while traversing through
    the site.
    Every time I load this page the applet does not paint itself (shows grey or background) and the browser
    stops responding. The machine needs to be restarted. This also happens when we keep that page idle for
    a long time (say 2 hours - session does not time out but applet hangs). I have used another thread object
    which is for utility and accesses the applet in the other frame every 10 seconds or so.
    When the applet hangs it does ot throw any exception or JVM error. This happens on certain machines
    evrytime and never on some machines. The applet hangs only in Microsoft IE 5 & 5.5 and never in Netscape
    4.x.
    What could be the problem?
    Can anyone help me with this problem? Its a deadline project and I can't get through.
    Thanks & Regards,
    Rahul

    Try making the register and getter methods of the intermediate class static synchronized. Then register the applets in their start() methods and unregister them in their stop() methods. Call the getter method of the intermediate class wherever you need access to another applet and never cache the instance you get. You may have to also synchronize all your start() and stop() methods to the intermediate class, as well as all methods that perform interapplet communication.
    Tell me what happenned ...

  • Asp-applet communication(URGENT!!)

    hi,
    i am facing a problem on asp-applet communication. i would like to ask how to pass applet parameters to asp page?my code below doesnt seem to work..
    smsClient.java
    public class smsClient {
    private JOptionPane jOptionPanel = new JOptionPane();
    private dialog dd;
    String str;
    public void executeSend(String smsno, String smsMessage,String user_id){
    String qrysmsno=smsno;
    String qrysmsMessage=smsMessage;
    String qryUserId=user_id;
    try{
    String qry=URLEncoder.encode("smsno")+ "=" + URLEncoder.encode(qrysmsno) + "&";
    qry= qry + URLEncoder.encode("smsMessage")+ "=" + URLEncoder.encode(qrysmsMessage);
    //qry= qry + URLEncoder.encode("user_id")+ "=" + URLEncoder.encode(qryUserId);
    URL url=new URL("http://172.20.34.116:8081/3dcommunity/sendsms.asp?"+qry);
    dialog dd=new dialog();
    //dd.showDialog(qry, "Alert!", JOptionPane.WARNING_MESSAGE);
              URLConnection uc = url.openConnection();
              uc.setDoOutput(true);
              uc.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
              PrintWriter pw = new PrintWriter(uc.getOutputStream());
              pw.println(str);
              pw.close();
              BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
              String res = in.readLine();
              dd.showDialog(res, "Alert!", JOptionPane.WARNING_MESSAGE);
              in.close();
    /*HttpURLConnection http = (HttpURLConnection)url.openConnection();
         http.setRequestMethod("GET");
         InputStream iStrm = null;
         if (http.getResponseCode() == HttpURLConnection.HTTP_OK) {
         iStrm = http.getInputStream();
         int length = (int) http.getContentLength();
         if (length > 0) {
         byte servletData[] = new byte[length];
         iStrm.read(servletData);
         String resultString = new String(servletData);
    dd.showDialog(res, "Alert!", JOptionPane.WARNING_MESSAGE);
         iStrm.close();*/
         catch(MalformedURLException e){
         System.err.println(e);
    dd.showDialog("MalformedURLException", "Alert!", JOptionPane.ERROR_MESSAGE);
         catch(IOException e){
         System.err.println(e);
    dd.showDialog("IOException", "Alert!", JOptionPane.ERROR_MESSAGE);
    sendsms.asp
    <%
         set mySMS = Server.CreateObject("SCSMS.SMS")
         mySMS.Port = "COM3"
    %>
    <%
              mfg = mySMS.Manufacturer
              mdl = mySMS.Model
              if mySMS.Error then
                   response.write mySMS.ErrorMsg
              else
                   response.write "Manufacturer : " & mfg & "<br>"
                   response.write "Model : " & mdl & "<br><br>"
              end if
              smsno=request.queryString("smsno")
              smsMessage=request.queryString("smsMessage")
         mySMS.sendsms smsno, smsMessage
         if mySMS.Error <> 0 then
              'response.write "Failed" & mySMS.ErrorMsg
         else
              response.write "Success"
         end if
    %>

    use the following class for applet to any web site connection (it can be asp, jsp, cgi etc)
    package com.oreilly.servlet;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    * A class to simplify HTTP applet-server communication. It abstracts
    * the communication into messages, which can be either GET or POST.
    * <p>
    * It can be used like this:
    * <blockquote><pre>
    * URL url = new URL(getCodeBase(), "/servlet/ServletName");
    * HttpMessage msg = new HttpMessage(url);
    * // Parameters may optionally be set using java.util.Properties
    * Properties props = new Properties();
    * props.put("name", "value");
    * // Headers, cookies, and authorization may be set as well
    * msg.setHeader("Accept", "image/png"); // optional
    * msg.setCookie("JSESSIONID", "9585155923883872"); // optional
    * msg.setAuthorization("guest", "try2gueSS"); // optional
    * InputStream in = msg.sendGetMessage(props);
    * </pre></blockquote>
    * <p>
    * This class is loosely modeled after the ServletMessage class written
    * by Rod McChesney of JavaSoft.
    * @author <b>Jason Hunter</b>, Copyright &#169; 1998
    * @version 1.3, 2000/10/24, fixed headers NPE bug
    * @version 1.2, 2000/10/15, changed uploaded object MIME type to
    * application/x-java-serialized-object
    * @version 1.1, 2000/06/11, added ability to set headers, cookies,
    and authorization
    * @version 1.0, 1998/09/18
    public class HttpMessage {
    URL servlet = null;
    Hashtable headers = null;
    * Constructs a new HttpMessage that can be used to communicate with the
    * servlet at the specified URL.
    * @param servlet the server resource (typically a servlet) with which
    * to communicate
    public HttpMessage(URL servlet) {
    this.servlet = servlet;
    * Performs a GET request to the servlet, with no query string.
    * @return an InputStream to read the response
    * @exception IOException if an I/O error occurs
    public InputStream sendGetMessage() throws IOException {
    return sendGetMessage(null);
    * Performs a GET request to the servlet, building
    * a query string from the supplied properties list.
    * @param args the properties list from which to build a query string
    * @return an InputStream to read the response
    * @exception IOException if an I/O error occurs
    public InputStream sendGetMessage(Properties args) throws IOException {
    String argString = ""; // default
    if (args != null) {
    argString = "?" + toEncodedString(args);
    URL url = new URL(servlet.toExternalForm() + argString);
    // Turn off caching
    URLConnection con = url.openConnection();
    con.setUseCaches(false);
    // Send headers
    sendHeaders(con);
    return con.getInputStream();
    * Performs a POST request to the servlet, with no query string.
    * @return an InputStream to read the response
    * @exception IOException if an I/O error occurs
    public InputStream sendPostMessage() throws IOException {
    return sendPostMessage(null);
    * Performs a POST request to the servlet, building
    * post data from the supplied properties list.
    * @param args the properties list from which to build the post data
    * @return an InputStream to read the response
    * @exception IOException if an I/O error occurs
    public InputStream sendPostMessage(Properties args) throws IOException {
    String argString = ""; // default
    if (args != null) {
    argString = toEncodedString(args); // notice no "?"
    URLConnection con = servlet.openConnection();
    // Prepare for both input and output
    con.setDoInput(true);
    con.setDoOutput(true);
    // Turn off caching
    con.setUseCaches(false);
    // Work around a Netscape bug
    con.setRequestProperty("Content-Type",
    "application/x-www-form-urlencoded");
    // Send headers
    sendHeaders(con);
    // Write the arguments as post data
    DataOutputStream out = new DataOutputStream(con.getOutputStream());
    out.writeBytes(argString);
    out.flush();
    out.close();
    return con.getInputStream();
    * Performs a POST request to the servlet, uploading a serialized object.
    * <p>
    * The servlet can receive the object in its <tt>doPost()</tt> method
    * like this:
    * <pre>
    * ObjectInputStream objin =
    * new ObjectInputStream(req.getInputStream());
    * Object obj = objin.readObject();
    * </pre>
    * The type of the uploaded object can be determined through introspection.
    * @param obj the serializable object to upload
    * @return an InputStream to read the response
    * @exception IOException if an I/O error occurs
    public InputStream sendPostMessage(Serializable obj) throws IOException {
    URLConnection con = servlet.openConnection();
    // Prepare for both input and output
    con.setDoInput(true);
    con.setDoOutput(true);
    // Turn off caching
    con.setUseCaches(false);
    // Set the content type to be application/x-java-serialized-object
    con.setRequestProperty("Content-Type",
    "application/x-java-serialized-object");
    // Send headers
    sendHeaders(con);
    // Write the serialized object as post data
    ObjectOutputStream out = new ObjectOutputStream(con.getOutputStream());
    out.writeObject(obj);
    out.flush();
    out.close();
    return con.getInputStream();
    * Sets a request header with the given name and value. The header
    * persists across multiple requests. The caller is responsible for
    * ensuring there are no illegal characters in the name and value.
    * @param name the header name
    * @param value the header value
    public void setHeader(String name, String value) {
    if (headers == null) {
    headers = new Hashtable();
    headers.put(name, value);
    // Send the contents of the headers hashtable to the server
    private void sendHeaders(URLConnection con) {
    if (headers != null) {
    Enumeration enum = headers.keys();
    while (enum.hasMoreElements()) {
    String name = (String) enum.nextElement();
    String value = (String) headers.get(name);
    con.setRequestProperty(name, value);
    * Sets a request cookie with the given name and value. The cookie
    * persists across multiple requests. The caller is responsible for
    * ensuring there are no illegal characters in the name and value.
    * @param name the header name
    * @param value the header value
    public void setCookie(String name, String value) {
    if (headers == null) {
    headers = new Hashtable();
    String existingCookies = (String) headers.get("Cookie");
    if (existingCookies == null) {
    setHeader("Cookie", name + "=" + value);
    else {
    setHeader("Cookie", existingCookies + "; " + name + "=" + value);
    * Sets the authorization information for the request (using BASIC
    * authentication via the HTTP Authorization header). The authorization
    * persists across multiple requests.
    * @param name the user name
    * @param name the user password
    public void setAuthorization(String name, String password) {
    String authorization = Base64Encoder.encode(name + ":" + password);
    setHeader("Authorization", "Basic " + authorization);
    * Converts a properties list to a URL-encoded query string
    private String toEncodedString(Properties args) {
    StringBuffer buf = new StringBuffer();
    Enumeration names = args.propertyNames();
    while (names.hasMoreElements()) {
    String name = (String) names.nextElement();
    String value = args.getProperty(name);
    buf.append(URLEncoder.encode(name) + "=" + URLEncoder.encode(value));
    if (names.hasMoreElements()) buf.append("&");
    return buf.toString();
    }

  • Applet reload problem

    How can one ensure that an applet re-initialise itself when returning to the applet's page after leaving to other pages.
    I can only force to reload by pressing ctrl and refresh botton on the browser. Is there any tricks that can bypass this procedure and reload the applet automatically when one re-enter the applet's page?
    Thanks for any great suggestion.

    I think that JavaScript can be very useful if you wish to establish communication between your Applet and your browser.
    JavaScript -- > Java communication does not require the use of any particular API
    You just neet to clearly specify the name of your applet like this :
    (I prefer to use OBJECT tag than APPLET... is more generic)
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" name="myApplet" width="230" height="360" align="baseline">
    <PARAM name="code" value="myApplet.class">
    <PARAM name="type" value="application/x-java-applet">
    <PARAM name="scriptable" value="true">
    </OBJECT>Check out the scriptable parameter. This is required for Java --> JavaScript communication.
    Now, let's say you want a call a method called setMyAppletName that you have implemented in your applet, you would call it from a JavaScript function like this :
    function callJavaMethod(){
    document.myApplet.setMyAppletName("myApplet");
    }Notice that parameter name in your tag insertion tags should match the name of the applet you're tring to acces in the JavaScript function.
    Java -- > JavaScript communication it's a bit more complicated. It requires the use of netscape libraries that you can find in the following path of your Netscape install :
    [your Program Files directory ]\Netscape\Communicator\Program\java\classes
    There you will need a jar file called java40.jar (this is what I have with Netscape 4.7) where netscape packages are found. After having isntalled this jar in my package directory, this is how I refer to API
    import netscape.javascript.*;
    //Reference to browser window where current applet is embedded
    JSObject jsoWindow = JSObject.getWindow(this);
    //Preparing parameters to be sent to a JavaScript function that is going to be called
    String strHelloMsg = "Hello";
    //Parameters neet to be stored in a String array in order to be passed to JavaScript function
    String[] strArrParams = {strHelloMsg };
    //Init JavaScript function name to be called
    String strFunctionName = "showMessage"
    //Call JavaScript function
    _jsoWindow.call(strFunctionName, strArrParams);In your HTML page you could define such function like this :
    <script>
        function showMessage(strMsg){
                alert(strMsg);      
    </script>That's all the help I can give since I don't know how JavaScript browser events work. You should find it out in the huge amounts of JavaScript tutorial and reference sites.
    Good luck !
    Diego

  • Applet Flash problem

    I have an applet and a flash in two frames in a HTML page. The applet and the falsh app communicate through the Javascript code with in the HTML pages. The flash app does not work as it is supposed to when the applet is present in the Parent HTML page. When I removed the applet, the flash app seems to work ok. But the applcation that I am working needs both of them together. Plz suggest me a solution if you know of any flash and applet related problems.
    Thanks in advance.
    kris

    http://forum.java.sun.com/thread.jsp?forum=31&thread=378703&start=0&range=15#1618263

  • Applet to Applet communication in one browser process with 2 windows

    Applet to Applet communication in Same IE process bu in different IE windows
    I have two IE windows
    (1) base window
    (2) child window (created through wondow.open() and hence share the same IE process and same JVM)
    Now I have two applets in one in base window and other is in child window and I want to do applet to applet communication. Since both applets are in different windows so AppletContext will not work and I tried to use custom AppletRegistory class to keep each Applet in static Hashtable. Now here comes the problem, Each applet gets different copy of this static Hashtable. i have tried hard to find the reason why a static varible has multiple copies running in the same JVM. Then my friend told me about something called class loader which is according to him is different for each window. I have tried this with two different iframes but in same window and it works fine and the reason being is that they share the same JVM. But why this fails for different windows althougt they also have same JVM?
    I am using JRE v5 update 7 and IE6 on WIN XP SP2.
    Thanks in advance..

    Try this example :
    Files used :
    1). AppletCom.html
    2). First.java
    3). Second.java
    1).AppletCom.html
    <HTML>
    <BODY bgcolor="#FFFFFF" link="#0000A0" vlink="#000080">
    <LI><H2><I>Inter applet communication Applet</I></H2>
    <applet code=First.class name="theFirst" width=250 height=100></applet>
    <applet code=Second.class width=350 height=100></applet>
    <BR>
    Source First.java Second.java
    <P>
    <HR>
    <i>Last updated 8/5/97 Martin Eggenberger</i>
    <HR>
    </BODY>
    </HTML>
    2). First.java
    import java.awt.*;
    <applet code="First" width="200" height="200">
    </applet>
    public class First extends java.applet.Applet {
    //Variables for UI
    Label lblOutput;
    public void init() {
    //Create the UI
    add(new Label("The First applet."));
    lblOutput = new Label("Click on a button in the Second applet.");
    add(lblOutput);
    public Color getcc()
    return Color.pink;
    public String getnm(int a,int b)
    int cnt=a+b;
    String str;
    str="Sum is :_________"+cnt;
    return str;
    public boolean handleEvent(Event event) {
    if ("One".equals(event.arg)) {
    lblOutput.setText("You clicked: One");
    return true;
    } else if ("Two".equals(event.arg)) {
    lblOutput.setText("You clicked: Two");
    return true;
    } else if ("Three".equals(event.arg)) {
    lblOutput.setText("You clicked: Three");
    return true;
    return super.handleEvent(event); }
    3). Second.java
    import java.awt.*;
    import java.applet.*;
    <applet code="Second.java" width="200" height="200">
    </applet>
    public class Second extends java.applet.Applet {
    //Declare the UI variables
    Button btnOne;
    Button btnTwo;
    Button btnThree;
         Applet f;
    Label lb;
    public void init() {
    //Build the UI
    btnOne = new Button("One");
    add(btnOne);
    btnTwo = new Button("Two");
    add(btnTwo);
    btnThree = new Button("Three");
    add(btnThree);
    lb=new Label("SUNO RE KAHANI TERI MERI SHHHHHHH");
    add(lb);
    setLayout(new FlowLayout());
    // lb.setSize(100,100);
    public boolean handleEvent(Event event) {
    if (event.id == Event.ACTION_EVENT && event.target == btnOne) {
         f = getAppletContext().getApplet(new String("theFirst"));
    First applet1=(First)f;
    // int cnt=applet1.givenum(22,25);
    // String str="Sum is:"+cnt+" Fine";
    String str=applet1.getnm(22,25);
    lb.setText(str);
    Color cl=applet1.getcc();
    setBackground(cl);
    return f.handleEvent(event);
    } else if (event.id == Event.ACTION_EVENT && event.target == btnTwo) {
    f = getAppletContext().getApplet(new String("theFirst"));
    return f.handleEvent(event);
    } else if (event.id == Event.ACTION_EVENT && event.target == btnThree) {
    f = getAppletContext().getApplet(new String("theFirst"));
    return f.handleEvent(event);
    return super.handleEvent(event);
    I had this example, so i am sharing it as it is.. instead of giving you any link for tutorial... hope this helps.
    Regards,
    Hiten

  • Communication problem between NetBeans and Tomcat

    hi!
    i got a quite mysterious problem. here is what happens:
    - i start NetBeans 5.5.1 (the first time)
    - i want to debug my JSF-Project, the Debugger starts
    - After a few seconds the debugger waits for tomcat (it sais: "Waiting for Tomcat...") and tomcat starts
    - Again after a few seconds the tomcat-debugger-output sais "Tomcat startet in 3333 ms".
    okay.
    when i enter http://localhost:8084/ in my browser i get the tomcat homepage, so the server has definitely started! But nothing happens in NetBeans and nothing happens with my project....
    In the lower-right corner i see this blue working-bar that sais "deploying project" but nothing happens. The Project-Debugger-Output still sais "Waiting for Tomcat..." but nothing happens...
    And after something around 3 minutes (i guess it's a timeout) i get the error "Starting of Tomcat failed." But is HAS started, i can login to the Administration-Area in my browser!
    so i guess there is a communication problem between netbeans an tomcat. Netbeans waits for a message from tomcat but tomcat doesn't send it..or netbeans doesn't understand it.
    But the story goes on:
    When i press the debug-button a second time it takes only a few seconds till i get the message: "Tomcat server port 8084 already in use". OF COURSE! Because Tomcat has already startet and can't be stoped by NetBeans.
    i'm trying to solve this problem for 4 days now, so i would be very happy if anyone has an idea where to start/continue the search...
    thanks,
    flo.
    some system-info:
    - windows vista business 32-bit
    - no firewall is running
    - AntiVir Personal Edition IS running
    - Yahoo Widgets Engine IS running
    - no other software is running
    and finally the tomcat-log:
    Using CATALINA_BASE: C:\Users\Administrator\.netbeans\5.5.1\apache-tomcat-5.5.17_base
    Using CATALINA_HOME: C:\Program Files\NetBeans\enterprise3\apache-tomcat-5.5.17
    Using CATALINA_TMPDIR: C:\Users\Administrator\.netbeans\5.5.1\apache-tomcat-5.5.17_base\temp
    Using JRE_HOME: C:\Program Files\Java\jdk1.5.0_12
    Listening for transport dt_shmem at address: tomcat_shared_memory_id
    21.09.2007 18:27:50 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
    INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.5.0_12\bin;.;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\ThinkPad\ConnectUtilities;C:\Program Files\Common Files\Teleca Shared;C:\Program Files\Common Files\Adobe\AGL;C:\Program Files\MySQL\MySQL Server 5.0\bin;C:\Program Files\cvsnt;
    21.09.2007 18:27:50 org.apache.coyote.http11.Http11BaseProtocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8084
    21.09.2007 18:27:50 org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 1862 ms
    21.09.2007 18:27:50 org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    21.09.2007 18:27:50 org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/5.5.17
    21.09.2007 18:27:50 org.apache.catalina.core.StandardHost start
    INFO: XML validation disabled
    21.09.2007 18:27:53 org.apache.coyote.http11.Http11BaseProtocol start
    INFO: Starting Coyote HTTP/1.1 on http-8084
    21.09.2007 18:27:54 org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /0.0.0.0:8009
    21.09.2007 18:27:54 org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/31 config=null
    21.09.2007 18:27:54 org.apache.catalina.storeconfig.StoreLoader load
    INFO: Find registry server-registry.xml at classpath resource
    21.09.2007 18:27:54 org.apache.catalina.startup.Catalina start
    INFO: Server startup in 3626 ms

    As i wrote before, the same problem occured for me. I have found a solution which is : Go to tools menu and then select options . In the proxy info, select No Proxy.
    I hope this help you

  • Communication Problem with the second battery

    Hello,
    In Lenovo Solution Center it says that there is communiction problem with the second battery. I already had this problem some months ago, back then it didn't charge the second battery. I got a new one and it worked again. Now it says the same thing "communication problem", but i can charge the battery and I also can't find any other sign of something not working. But still- it seems weird that the program tells me something is wrong. Can somebody help me?
    Thanks Lina

    Hi, Lina
    What is the machine type and model of your computer? Also, what operating system are you running?
    Thanks in advance,
    Adam
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution!" This will help the rest of the community with similar issues identify the verified solution and benefit from it.

  • Communication problem with proxy server

    We have establish the configuration of an iPad to access the enterprise net, but when trying to access any webpage we get the next message: Safari can not open the page. Error:"There is a communication problem with proxy web server (HTTP)"
    The access has no problems with other movile devices.
    Ahy help?

    Hi,
    I am not sure whether you have already solved the problem or not....
    Do the following to deploy MobileBIService.war file on tomcat
    1.Stop Tomcat Web application server.
    2.Copy the file, MobileBIService.war from [Install directory]\Mobile 14\Client to the Tomcat's "Webapps" directory.
    In my case, I copied the MobileBIService.war from C:\Program Files (x86)\SAP BusinessObjects\Mobile14\Client to C:\Program Files (x86)\SAP BusinessObjects\Tomcat6\webapps. ( I used BO 4.0 SP02)
    3.     Start Tomcat.
    Restarting Tomcat would automatically deploy war file as a Web App
    One folder u201CMobileBiServiceu201D will appear in webapps folder when MobileBIService.war is deployed successfully.
    Hope it helps.
    Regards,
    Ankur

Maybe you are looking for