Servlet/Applet Communication and JRE Version

Hey all,
I have an applet that sends objects back and forth to a servlet. I have heard that there can be issues if the applet and servlet are run under different versions of java, and right now, the applet works from some machines but not others (I've only tested on PCs so far). I posted a question similar to this a month or two ago, and someone suggested I use UIDs. Can anyone give me some detailed information on how I would do this, or something similar to ensure that any version of Java on someone's machine will work ok, or a link to some helpful info? Thanks.

Thanks mchan0! I think this will be very helpful.

Similar Messages

  • 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!

  • Mismatch of JDK and JRE versions cause screen freeze for applications ?

    Hi,
    My Java swing application is built on jdk1.3.1_17 in server. It was working fine without any issue when I use Java webstart 1.0.1 to download the client part of the application and JRE 1.3.1_10 to run the application from my local desktop.
    For better performance, I upgraded my local desktop to 1.4.2_07 version of JRE and same version of java Web start 2 months before. From that day, I am facing a "Screen freeze" issue in my application. It means, while working on the application, the application screen goes blank or White screen. This issue may come while doing any activity all of a sudden , there is no pattern found.
    Is there any reason like incompatibility of lower JDK version and higher JRE/JWS versions could have caused this issue ? Any Idea plz
    Thanks in advance
    David

    I'm using a 15" Macbook Pro with Retina Display. The applications I have are Indesign, Illustrator, and Photoshop. Over a period of time, using these programs will make the screen turn blank. Sometimes, the screen turns a solid color and it just happens to be what ever color I've been using with the Color picker tool.
    I don't know for sure what it could be. I tried checking Disk Utility (one problem was solve, but blank screen wasn't fixed).
    I have to force reboot only to be faced with another blank screen. I either keep trying or keep cmd+opt+p+r until the screen boots back to normal. (This is probably due to the programs not shutting down properly when the laptop blank screens)

  • Mac OS 10.4.8 , Java Web Start and JRE version of 1.4.2 and 1.5.0 problem

    Hello,
    I've been searching internet and reading the problems related to Java Web Start and JNLP.
    But no solution I read can solve what I faced.
    I'm running Mac OS x 10.4.8 and Macintosh updates the Java in my machine so that it has Java version 1.4.2 and Java 1.5.0
    The application I'm running needs to be running in JRE 1.4.2.
    So I changed the Java Preferences so that the default Java setting is JRE 1.4.2. However, the JNLP application still running in Java 1.5.0
    So I changed the MIME and make sure the JNLP is opened with Java Web start instead. The Java Web start is for version 1.4.2. I also change its preference so that the console is opened.
    I tried to run the JNLP application once again. Java web start 1.4.2_09 starts and console open, but the Java Runtime is still showing Java 1.5.0
    I adjust the JNLP file so that the version is only showing 1.4.2_09 (ignoring all other variables of version 1.4.1, 1.4.2, etc found in the original JNLP file). That didn't work either.
    I search on methods on how to uninstall Java 1.5.0 in Mac - apple page told me that I can't do that unless I reinstall the whole OS.
    I am henceforth declare that I am stuck now !!!! Heellllpp....

    Are you up to date with the updates?
    Update for Snow Leopard users:
    Apple issued update 12 for Java for OS 10.6:
    http://support.apple.com/kb/DL1573
    Note:  On systems that have not already installed Java for Mac OS X 10.6 update 9 or later, this update will configure web browsers to not automatically run Java applets. Java applets may be re-enabled by clicking the region labeled "Inactive plug-in" on a web page. If no applets have been run for an extended period of time, the Java web plug-in will deactivate.
    If, after installing Java for OS X 2013-002 and the latest version of Java 7 from Oracle, you want to disable Java 7 and re-enable the Apple-provided Java SE 6 web plug-in and Web Start functionality, follow these steps:
    http://support.apple.com/kb/HT5559?viewlocale=en_US
    Further update:
    Apple issued this Java related security update No. 13 on February 19:
    http://support.apple.com/kb/HT5666
    and Update No. 14 on March 4:  http://support.apple.com/kb/DL1573
    http://support.apple.com/kb/HT5677
    The standard recommendation is for users to turn off Java except when they have to use it on known and trusted websites (like their bank). Javascript, which is unrelated despite the name, can be left on.

  • Servlet applet communication

    I'm having a problem getting a servlet to answer a call from an applet...in the applet I do something like:
    String servlet = "http://192.168.123.148/root/MyServlet.class";
    url= new URL(servlet);
    conn = url.openConnection();
    conn.setUseCaches(false);
    in = conn.getContentLength();
    String contype = conn.getContentType();
    And in the servlet:
    java.io.PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    response.setHeader("segment",Integer.toString(99));
    out.flush();
    The problem is I don't get my header back in the applet...and when I look at the content type, its "application/java-vm"...not " text/html"...as I set in the servlet...???

         InputStream urlInput = null;
         HttpURLConnection urlConn =  null;
         URL url = new URL(urlStr);
         urlConn = (HttpURLConnection)url.openConnection();
         urlConn.setDoInput(true);
         urlConn.setDoOutput(true);
         urlConn.setUseCaches(false);
         urlConn.setRequestMethod("POST");
         urlConn.setRequestProperty("Accept-Language", "en");
         urlConn.setRequestProperty("content-type", "text/xml");
         urlInput = urlConn.getInputStream();

  • JNLP and JRE versions...

    I have a machine with JDK 1.2.2 and Java Web Start 1.0.1 (update package). I am accessing an app. that runs on JRE 1.3, but I cannot update to 1.3 yet due to other application dependencies. Is there a way that the downloaded app. can be packaged in such a way that it brings in JRE 1.3 in its JARs and uses it from the JAR, leaving my system at JRE 1.2.2 level?
    Thanks!

    A jre is a lot more than the jars it loads. You can't run an application under 1.2.2 VM using 1.3 classfiles.
    You can install some later versions of the JRE "privately". a private installed jre will not become the default on the system, but can be configured to be used in java web start applications.
    /Dietz

  • 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!

  • IE 7 problem with jre version 1.4.1

    We are experiencing a problem with a site that is running java applets. It requires version 1.4.1. After logging into this site, a second window should appear. There are several times when that second window will attempt to open but then closes immediately. The only fix that I have found is to open the Java Console (tools>Sun Java Console) with the browser open and then immediately close the console.
    Is there another workaround or fix?
    Thanks

    Starting in JRE 5.0u7 and 6, we have family clsid support for the 1.4.2 and 5.0 JRE family. Please refer to Deploying Java Applets With Family JRE Versions in Java Plug-In for Internet Explorer for details. In your HTML page you can specify the 1.4.2 family clsid so that the latest installed JRE 1.4.2 version on the machine will be used. Note that we no longer support JRE 1.4.1. Please migrate your applet to JRE 1.4.2 or newer JRE versions.
    http://java.sun.com/developer/community/askxprt/2007/jl0212.html
    => upgrade to the latest jre

  • JRE versions to test

    1. There are so many JRE versions from Sun out there. I wonder which versions do people typically test their java programs/applets with.
    2. what is the relation between JRE version (1.4.2_07) and the default virtual machine version(1.4.2_07-b05)?
    3. 1.4.2_07-b05 ... can someone explain the 5 fields of this version number and when each of them changes?
    thanks.

    Reply to (1) - Whatever Java virtual machine(s) you
    want to guarantee it'll run with. Typically a few
    versions.The reason I ask is my applet works on a machine with JRE1.4.2_08 but not on a machine with 1.4.2_04. For another problem, reading cookie through liveconnect did not work very well with 1.4.1. I also know that in 1.4.2_03, javascript cannot called applet methods to do privileged work even if the applet is signed - what I dont know is if this is a change between 1.4.1 and 1.4.2 series or introduced in 1.4.2_03.
    Things like these make me wonder if I have to test my applet with every JRE version out there. But since that is lot ot work, I am looking for recommedations as to what versions the QA can use for testing.

  • JDK and JRE comptability for Windows server 2008

    Hi,
    Could someone please let me know what are the JDK and JRE versions that are comptabile with Windows server 2008 ?
    Thanks.

    Hi,
    For security purposes, the IP address for the Windows Update web site constantly changes and it is not a fixed address. Also, there is no official publication of the
    IP addresses. We normally advise against defining IP addresses on the firewall for this purpose. Instead, we suggest either allowing all outbound connections to http & https ports or defining the DNS addresses as permitted destinations for traffic via
    the firewall.
    For up-to-date information about the IP's being used by Windows Update, use the DNS system, as this is the only reliable up to date source of information. If you use
    DNS, make sure the following destination hosts are specified:
    http://windowsupdate.microsoft.com
    http://*.windowsupdate.microsoft.com
    https://*.windowsupdate.microsoft.com
    http://*.update.microsoft.com
    https://*.update.microsoft.com
    http://*.windowsupdate.com
    http://download.windowsupdate.com
    http://download.microsoft.com
    http://*.download.windowsupdate.com
    http://wustat.windows.com
    http://ntservicepack.microsoft.com
    http://stats.microsoft.com
    https://stats.microsoft.com
    Thanks for your understanding.
    Best Regards,
    Nina
    This posting is provided "AS IS" with no warranties, and confers no rights.

  • I have been getting java.lang.ClassNotFoundException: ZeroApplet.class and java.lang.ClassNotFoundException: JavaToJS.class crashes with JRE version 1.6.0_26-b03-384-10M3425 VM executing a Java Applet. Is Apple aware of this problem? No longer supported?

    My web page uses a Java Applet to allow my visitors to replay chess games; the Chess Viewer Deluxe applet was written by Nikolai Pilafov some time ago and has been working properly for some time (until recently). I don't monitor this part of my site regularly so I am not sure when it began to fail. On his web site [http://chesstuff.blogspot.com/2008/11/chess-viewer-deluxe.html] he has a link to check LiveConnect object functionality (which fails for OBJECT tags). His recommendation is to "seek platform specific support which might be available from the JRE developers for your platform".
    I have been getting java.lang.ClassNotFoundException: ZeroApplet.class and java.lang.ClassNotFoundException: JavaToJS.class crashes with JRE version 1.6.0_26-b03-384-10M3425 VM executing a Java Applet. Until I checked the LiveConnect object functionality, I was unable to identify the source of the console error messages. This does seem to be the smoking gun.
    Is Apple aware of this problem? Are these classes no longer supported? Has anyone else had this problem? You can attempt to recreate the problem locally by going to my web page: http://donsmallidge.com/DonSmallidgeChess.html
    Thanks in advance for any help you can provide!
    Abbreviated Java Console output:
    Java Plug-in 1.6.0_26
    Using JRE version 1.6.0_26-b03-384-10M3425 Java HotSpot(TM) 64-Bit Server VM
    load: class ZeroApplet.class not found.
    java.lang.ClassNotFoundException: ZeroApplet.class
        at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:211)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:144)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:662)
        at sun.applet.AppletPanel.createApplet(AppletPanel.java:807)
        at sun.plugin.AppletViewer.createApplet(AppletViewer.java:2389)
        at sun.applet.AppletPanel.runLoader(AppletPanel.java:714)
        at sun.applet.AppletPanel.run(AppletPanel.java:368)
        at java.lang.Thread.run(Thread.java:680)
    load: class JavaToJS.class not found.
    java.lang.ClassNotFoundException: JavaToJS.class
        at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:211)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:144)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:662)
        at sun.applet.AppletPanel.createApplet(AppletPanel.java:807)
        at sun.plugin.AppletViewer.createApplet(AppletViewer.java:2389)
        at sun.applet.AppletPanel.runLoader(AppletPanel.java:714)
        at sun.applet.AppletPanel.run(AppletPanel.java:368)
        at java.lang.Thread.run(Thread.java:680)

    I just went up to check the LiveConnect object functionality page AND IT WORKED THIS TIME! I must confess, this is very mysterious. I will do some more checking and reply here if I can determine why it is working now (and more importantly, why it didn't work before).

  • JRE versions and Browsers and Applets

    Is there a way to assign a particular JRE version to a browser session through JavaScript or VBScript programatically so that I can run applets from different sources which need different JREs?
    Basically I will have 2 links/buttons which will call two separate javascript methods to open two different browser windows to run two different applets running under different JREs
    However when I start IE each 'session' of IE is assigned to one JRE, any way to overcome this?
    TIA,
    Raj

    Martin thanks for your inputs
    I am sourcing html pages from multiple sites and the html/applet tag is generated by those websites.
    They do have the applet tag pointing to proper class-id of the java plugin.
    However, the problem is with IE one family(session) of browsers are attached to one version of JRE plugin.
    Here 'session' means: you open a browser and from within that browser you do go from a link or javascript etc. to another browser they are in same 'session'
    I am working on dynamically setting JRE plugin version to different browsers.
    Not sure I made it clear or confusing : )
    Thanks

  • 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

  • Use 2 jre versions (Java 5.x and Java 6.x) on diferent web pages.

    On windows XP SP3.
    I need use on internet explorer 7 and firefox 3, 2 differents JRE versions for two diferent servers
    example:
    - "www.site1.com" needs java 5.x (don't work with java 6.x)
    - "www.site2.com" needs java 6.x (don't work with java 5.x)
    If i have installed both versions, internet explorer and firefox even uses java 6.x, and i only can use java 5.x if uninstall java 6.x
    I need use to default use: java 6.x; except for "www.site1.com" that i need use java 5.x
    How can use both JRE versions?

    Questions: Do you plan to use the same web browser? The earlier applet running on JRE 1.5.x cannot run on 1.6 ? Sun puts forth a lot of effort in attempt to ensure that applets are forwards compatible.

  • Communication between servlet & applet

    Hello everybody,
    Well, I have a problem with my applet/servlet system.
    I Would like my applet to send some queries to the servlet.
    However, I don't know how to link the applet with the servlet (the only way I know is to use "openConnection()", but I don't see how to incorporate my query in the URLConnection (in order to have one, I need openCOnnection, and once it's done, well, the doGet method has already be laucnh, without any parameter to read). In my case, the DoGet methods of the servlet is launched, and of course, the HTTPRequest is almost empty, seeing thath I don't see how to specify the differnets parameters.
    Is thereany simple meaning to make the applet communicate this the servlet, sending strings, and receiving objects (I have already solve the problem of the sending of an object from the servlet to the applet, in the doGet method).
    Thank you very much
    C U

    In the applet html include a servlet parameter.
    <param
    name="servlet"
    value="/SqlServlet" />
    In your applet open a connection to servlet.
    InputStream in = null;
    URLConnection conn = null;
    URL url = null;
    String servlet = getParameter("servlet");
    url = new URL(servlet + "?sql=" + URLEncoder.encode(sql));
    conn = url.openConnection();
    in = conn.getInputStream();

Maybe you are looking for