Servlet to load Applet

Hi,
          I am trying to write a servlet that deliver an applet to any html page which
          requested for it. How should I go about doing it?
          Can I use URLClassLoader to load the applet class from network and then use
          ServletOutputStream to send the applet to the client's brower? If so, is
          there a method to write the class to the output stream?
          Would really appreciate any help on this.
          regards
          Ee Ming
          

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!

Similar Messages

  • Could not load applet in a browser using jre 1.6.0_06

    Hi,
    I am facing problem with loading applets when the browser uses jre 1.6.0_06.
    Not able to understand what actually the problem is, I tried to check with a small applet that would simply print Hello World on the java console. Even this applet also could not be loaded on the browser. I could load this applet in the test environment of eclipse, but not able to load it on the browser when the applet is deployed on Tomcat.
    We have no problems in loading applet if the browser is using an earlier version of the jre.
    One more thing we have found out that, if we change the SSL cipher suite of the ssl.conf file such that it can support weaker protocols, my applet works with jre 1.6.0_06 also.
    But one thing we could not understand is that why changes in SSL cipher suite of the ssl.conf file creates problem in loading the applet, only in case the browser is using jre 1.6.0_06. I mean to say that changes in the SSL cipher suite does not create any problem in loading the applet if my browser is using an earlier version of jre 1.6.0_06.
    Please help me out as I don't have any clue regarding this problem.
    Thanks in advance.

    Hi,
    We have found a wor around for this problem.
    The following option has been unchecked and the applet could be loaded.
    Go to java control panel
    Under the Advanced Tab
    Under the Security section
    Uncheck the last option "Use TLSv1.0".
    This makes the applet work.
    But could not understand as why this is creating a problem.
    We have tried to include TLSv1.0 in the cipher suite of our apache server, while keeping the above option in java plugin control panel checked, but even that did not solve the problem.
    Please help me of how should I proceed for this problem, as I am totally stuck.
    Thank you.

  • Help needed to call a servlet from an applet

    Hi,
    can someone help me with the way to call a servlet from an applet.
    actually on click of a button i wanna call my servlet and save some data in DB.
    i am not able to call my servlet. see the sample code which i am trying..
    public void actionPerformed(ActionEvent event) {
    if (event.getActionCommand().equals("Upload")) {
    try {
    System.out.println("Upload button has been clicked -----------");
    URL url = new URL("http://localhost:8084/uploadApp/TestServlet");
    URLConnection urlConnection = url.openConnection();
    urlConnection.setDoInput(true);
    urlConnection.setDoOutput(true);
    urlConnection.setUseCaches(false);
    ObjectOutputStream objOut = new ObjectOutputStream (urlConnection.getOutputStream());
    objOut.writeBytes(userId); // pass parameter to servlet
    objOut.flush();
    objOut.close();
    } catch (MalformedURLException ex) {
    Logger.getLogger(ButtonListener.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
    Logger.getLogger(ButtonListener.class.getName()).log(Level.SEVERE, null, ex);
    is there any problem with the code? please suggest.

    hii,
    checkout my add from, HTH
    [http://forums.sun.com/thread.jspa?threadID=5419921&messageID=10885709#10885709]
    ... kopik

  • LOADING APPLET TO SMARTCARD

    How do I load my applet (cap file) to my smartcard using JCOPToolkit ????
    Also how do you send APDUs to test the applet?
    Kind regards
    Saeed

    are you want to use JCShell to load applet to the smartcard?
    just set the shell properties to (PC/SC)
    1.initialize
    2.authenticate
    3.load package
    4.install applet
    or you can type the apdu by yourself
    you also can tyep "help"
    to check how to use install
    just type install, you can see such '-p'
    is set the applet have pin-change privilege

  • Problem on loading applet netscape4.73 in macos9 very urgent pls help me

    Hello,
    Problems on loading applet in Netscape4.73(jre1.1.5) AppleMac OS-9.
    when i try to load applet of size ~ 200kb in Netscape 4.73 AppleMac os9, then browser abruptly closing with the AppleMac os error message :- the Applicarion " Netscape Communicator " has unexpectedly quit because an error of type 2 occured. And then asking for system restart.
    Since i am new to the AppleMac environment i cant adjust the settings please help me to overcome the problem. Its Very urgent and i am in great hurry pls.
    thanks in advance.
    Rao. V.N.

    Hi Rao,
    I'm not a mac-os specialist (even I had some business with mac !!), and it is very difficult speaking in blind, but I have severals questions that may help you.
    - Did you try you applet in other AppleMac plateform ?
    - Does your applet work fine in other browser/plateform ?
    - Does a small applet work fine on this plateform with this browser ?
    - Does you applet contains instructions like System.exit, System.* or try to access (read or write) to local files ?
    Otherelse it is possible you have problem with your jre config, try to configure your plugin with command like : -Xmx64m -Xms16m
    (These commands tell the plugin to use at least 16 Mo memory and 64 Mo for the maximum see : http://java.sun.com/docs/hotspot/gc/)
    Hope that will help you

  • Problem while loading applet in opera- very urgent please

    hi,
    I am having problem while loading applet in opera browser. Showing "Applet loading " continuously. I am trying to use URLConnection to read information from applet's own host. I cant find the exact problem what is happening, Since there is no error message in browser Javaconsole.
    If anybody have idea on this please help me. I am in great hurry.
    Thanks in advance.
    Rao. V

    hi this is rao,
    I inserted a lot of System.out statements throughout applet life cycle. But they are not displaying in java console. I think the problem is in Opera-java settings. Since i am new to the opera environment i cant get right solution.
    Please help me if anybody having clear idea on this aspect.
    thanks in advance

  • Is it possible to load applets if ki imsi iccid are known?

    is it possible to load applets if ki imsi iccid are known for a sim? if the sim is given by a mobile operator. how to connect to such a card using jcop/javacard.

    bilal,
    is it legal to post answer here ?
    anyways i am posting here for knowledge only,hope nobody will do any mis use.
    u have generate KI from ICCID & IMSI(ICCID & IMSI u can read from SIM file system)
    for KI generation , u can find any s/w from internet search,which will generate KI from ICCID & IMSI using broute-force attack,
    then replace KI of ur SIM with generated KI,
    thats it,ur job is done :-)
    now u can connect to CM as u have ADM 0 privileges for SIM.
    cheers
    Divyesh.

  • How to call a method in the servlet from an applet

    I want to get the data for the applet from the servlet.
    How to call a method that exits in the servlet from the applet? I want to use http protocol to do this.
    Any suggestions? Please help.
    thanks

    Now that Web Services is around, I'd look at possibly implement a Web Service call in your applet, which can then be given back any object(s) on return. Set up your server side to handle Web Service calls. In this way, you can break the applet out into an application should you want to (with very little work) and it will still function the same

  • Is OCF related to loading applet into the sim

    I've read some text about OCF(Open Card Framework) it is said that it is an interface to both smart card reader and applications on the sim. if we take "the application on the sim" same as "Installer Applet" then the ocf stands in the place which the problem of loading applet exists.
    could you please explain:
    Can I use OCF for witing a programm to load my applet into card?
    Is There any other way to do the task??

    If it is a GlobalPlatform card, there are some simple steps to validate if your card is locked/terminated
    1. send GET DATA on some tag you know for sure is in the data store of the CardManager
    2. If this works, try to authenticate (INIT-UPD, EXT-AUTH)
    3. If this works, GET STATUS on ISD --> AID and life cycle of the CM
    - If 1. does not work, then your default select application is not the ISD --> contact the issuer for the AID
    - If 2. does not work, then your card is locked or terminated
    - If 3. does not work, then the GP secure channel protocol on-card has a different implementation than your off-card tool/API (most likely with a Gemalto card)

  • Dynamically Loading Applet in an IFRAME

    Hi All!
    I'm not sure if this is the right place to put my question, since it's more of a JavaScript issue. But, I'll just test my luck here.
    I have a signed applet that I wish to load dynamically. What I did was to create an HTML document containing the applet then have another HTML document, containing an IFRAME element with it's source pointing to the applet HTML document. This is how it looks like:
    *Applet.htm (HTML containing the applet)<HTML>
    <BODY>
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
              width="0"
              height="0"
              id="JavaPOSDiags"
              name="JavaPOSDiags"
              viewastext>
              <PARAM name="CODE" value="javapos.DiagApplet">
              <PARAM name="ARCHIVE" value="JavaPOSDiags.jar">
              <PARAM name="NAME" value="JavaPOSDiags">
              <PARAM name="type" value="application/x-java-applet;jpi-version=1.3.0">
              <PARAM name="scriptable" value="true">
    </OBJECT>
    </BODY>
    </HTML>
    *Main.htm (HTML containing the IFRAME that loads the applet)<HTML>
    <BODY>
         <iframe id="fxJavaPOS" src="Blank.htm" width=0 height=0 frameborder=0 style="display: none"></iframe>     <!-- Blank.htm is another HTML file that contains a blank document. ->
         <script language=javascript>
              var bAppletLoaded = false;
              function loadApplet() {
                   var eJavaPOSFrame = document.getElementById("fxJavaPOS");
                   if(eJavaPOSFrame != null) {
                        eJavaPOSFrame.src = "Applet.htm";
                        bAppletLoaded = true;
              function testApplet() {
                   if(bAppletLoaded) {
                        var eJavaPOS = document.getElementById("fxJavaPOS").contentWindow;
                        var eJavaPOSApplet = eJavaPOS.document.getElementById("JavaPOSDiags");
                        try {
                             if(eJavaPOSApplet != null) {
                                  //call applet's methods/properties here...
                        } catch(exception) {
                             //an exception occured...
         </script>
         <input type=button id=loadApplet value="Load Applet" onclick="loadApplet()" name=loadApplet>
         <input type=button id=testApplet value="Test Applet" onclick="testApplet()" name=testApplet>
    </BODY>
    </HTML>My problem is, when testApplet() is called, an exception is thrown once the applet reference is compared to null:if(eJavaPOSApplet != null).... I don't know why this happens. When I do remove the comparison statement and just proceed w/ calling the applet's methods/properties, the browser goes crazy. It seems that the line:var eJavaPOSApplet = eJavaPOS.document.getElementById("JavaPOSDiags");gives me an object, but, I'm not sure if it is the applet, because referencing eJavaPOSApplet, e.g. calling methods or comparing to null, causes the browser to hang.
    Could this be a Java security issue?
    Can anyone help me?

    How long does it take to load the same remote image in a browser? (clear the cache first)
    What code are you using to load and wait for the image?
    Have you indentified for certain that the 15s is entirely down to image loading and not anything else?

  • SEVERE: Servlet  threw load() exception

    I am trying to load servlet in Tomcat 5.5 . It is throwing an exception as follows. The LicenseAuthentication class exists in WEB-INF/Class directory. So it is not the problem.
    1. In lib folder there is no servlet.jar. If I put that I am getting different exception.
    2. In my servlet In init(), doPost() and doGet method implementation.
    3. In web.xml I had put the <load-on-start> parameter as 1.
    Can someone help immediately ? I am stuck with this issue for long time ?
    Thanks
    Murali
    =================================================
    <servlet>
    <servlet-name>License</servlet-name>
    <servlet-class>LicenseAuthentication</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>License</servlet-name>
    <url-pattern>/License</url-pattern>
    </servlet-mapping>
    =======================================================
    SEVERE: Servlet threw load() exception
    java.lang.NoClassDefFoundError: LicenseAuthentication$1
         at java.lang.Class.getDeclaredConstructors0(Native Method)
         at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
         at java.lang.Class.getConstructor0(Class.java:2699)
         at java.lang.Class.newInstance0(Class.java:326)
         at java.lang.Class.newInstance(Class.java:308)
         at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1089)
         at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
         at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
         at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
         at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
         at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
         at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
         at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
         at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
         at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
         at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
         at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
         at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
         at org.apache.catalina.core.StandardService.start(StandardService.java:448)
         at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
         at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)

    This is just Java 101. The NoClassDefFoundError simply means that the mentioned class is missing in the runtime classpath (while it was available in the classpath during compilation, this is the key difference with ClassNotFoundException).
    In the future, please start a new topic for each independent question instead of resurrecting old topics or hijacking other's topics.

  • Loading applet..

    Hello
    I've an applet in a *.jar file with the classes, some images, etc... This applet take a little time to load in the explorer, so i'm sarching fomr something to read, or some code, i don't know.. to make an 'loader applet'.. to print a message 'LOADING' when the jar, or the class is loading.. i don't know..
    Thanks for any help, and sory my basic english to write
    Daniel

    I think one applet class, print loading message.. and
    load the others... but it's imposibble.. no?Here I could see it once:
    http://java.sun.com/applets/jdk/1.4/demo/applets/ArcTest/example1.html
    I think it shows that coffee cup while it's downloading the classes.
    As I said, that's no special code. The JVM does it automatically already.
    You couldn't really implement it yourself, thinking about it. You don't have control over the download process. You wouldn't be able to tell when all the classes are available so you can stop showing the "loading" screen... and one applet can't replace another in a document, either. It'd have to be the same applet, but that won't run until everything is available. Full circle...
    My suggestion is: don't bother. Make a note on the webpage that it'll take a moment or two to download, and package it in a JAR, so you can benefit from the ZIP compression when downloading.

  • Problem in loading applet from non executable jar file

    hello ,
    I am new to jar concept plz help.. I am trying to call an applet from another applet through frame it is working fine but its download time is much more. now i want to store all my images , sound files and class files of other applets in a jar file and want to access these inner applets from this jar file so that it will make only one http connection with the server for this jar file only and can reduce the download time of applet.
    Can anyone can give me suggestion plz..
    Thanx

    You have to download what you have to download. You
    probably can't easily share images between 2 separate
    Jar files. Unless you can expose them through the
    other applet via a method that can be known once you
    have the reference to the other applet.Thanx but i think i have to elaborate the problem :
    my project structure is just like this ::
    on the top is ::
    Applet A---> from this applet i am callling Applet B & Applet C in frame
    and communication is established between these 3 applets successfully .
    now i have made a single non executable jar file which contains images , sound and class files of these applets .
    so i am referencing images and sound files in applets through this jar.
    but i wanted to load Applet B & C through this jar file only.
    How can i do this ??
    Thanx .. I hope now the problem is clear

  • Loading Applet on a Smart Card

    I am new to JavaCard development so forgive me if you find the question stupid.
    I am trying to load an applet on a NXP based Sm@rtCafe Expert card. I have completed the following steps:
    - Compiled the applet
    - Converted the package into a cap file using the Converter tool.
    - Generated the upload scrpit file using the scriptgen tool and appended the requisite powerup and powerdown commands.
    Now when I try to upload the applet through the apdutool, I get an exception.
    Here is the apdutool command I am using:
    apdutool -t0 upload
    Where upload is the name of my script file.
    I am getting the following exception:
    Opening connection to localhost on port 9025.
    java.net.ConnectException: Connection refused: connect
    So my card reader is probably not on the default port is what I gather. How do I find out what port is my reader at if that is the problem.
    For additional information I am using JavaCard 2.2.2 development kit along with JDK1.5. My card reader is a USB based SCR3310 reader manufacture by SCM Microsystems.
    Any help in this regard will be greatly appreciated.
    Thanks.

    hi
    1- for Sending commands to a PC/SC-compatible card reader with apdutool, you have to use pcsc command line option , apdutool -pcsc
    you need to configure pcsc Functionality. refer to
    java card dev kit2.2.2 user guide, page 10,11.
    2 - The sun JavaCard Development Kit can only be used for testing applets in a simulated environment, it does not allow you to load applets to a physical card. Most cards use the GlobalPlatform specification for content management.
    Best regards,
    siavash

  • A servlet  From an applet

    Dear friends,
    Hope you are doing well.
    I am facing a problem of how to call a servlet from an applet.
    Any help , please forward it.
    thanks
    vishal

    You can communicate with servlet from an applet, using URL connection, and then send POST/GET methods through HTTP protocol, here is a code snippet,
    // applet side, this method will send a POST method to the servlet and then get url openstream to read a
    // returned object from the servlet, params should be in the form param1=value&param2=value etc...
    public Object getObjectFromServlet(String servletName,String params) {
        Object object = null;
        try {
          URL url = new URL(codeBase,
                            contextRoot + servletName + params);
          URLConnection con = url.openConnection();
          con.setUseCaches(false);
          InputStream in = con.getInputStream();
          ObjectInputStream result = new ObjectInputStream(in);
          object = result.readObject();
          result.close();
          in.close();
        catch (ClassNotFoundException ex) {
          System.err.println("ClassNotFoundException caught:" + ex.getMessage());
        catch (MalformedURLException ex) {
          System.err.println("MalformedURLException caught:" + ex.getMessage());
        catch (IOException ex) {
          System.out.println("IOException caught:" + ex.getMessage());
        return object;
    //servlet side
    public void doPost(HttpServletRequest request, HttpServletResponse response){
          //Extract all the necessary supplied parameters from the request object and configurations.
           String param1 = request.getParameter("param1");
           String param2 = request.getParameter("param2");
      try {
            ObjectOutputStream out = new ObjectOutputStream(response.getOutputStream());
            out.writeObject(object);
            out.close();
          catch (IOException ioe) {
            System.err.println("IOException caught:" + ioe.getMessage());
    }

Maybe you are looking for

  • Is there an easier way to view distant date information on the dashboard calendar?

    I'm attempting to use the calendar on the dashboard to inspect dates that are far in the future or past, but it seems like the only option for changing the month is to use the forward or back buttons, stepping you a month at a time. If I want to see

  • Page Switching in Post Script file

    I need to print the first page of my bills on a specified pre printed bill form and the next Page i.e two or three on plain sheet.   I have follwoing command line for Page switching. For First Page <</Duplex false/PageSize  [595 842] /Tumble false /M

  • DDE package

    Can We use DDE.initiate built in without using DDE.APP_Begin if yes then how

  • HP 6700 scan to PDF

    I have installed an HP 6700 all ino one printer and need to scan to PDF but the option isn't available.  I have the latest drivers installed. How do I get this to appear in the file type list?  Do I need some additional software to do this? Thanks Ga

  • SUM in Oracle 7.3.3.0.0

    Hello everyone Version Oracle 7.3.3.0.0 Developer 6i I have following values... Bill# Amount 2376 1693 2354 11813 2342 2694 2313 13055 2273 1860 I want to get the sum(amount) of only those bills whose sum is less then or equal to 25000. Result should