Applet server communication

I am wondering if its possible to have an applet on one server who connects through http to a servlet on another server?
I read that due to security restrictions applets can only communicate back to the server where it reside's. If this is the case are there any ways around it?
I have a web server hosting my applet and for some resons out of my controll it cant host servlets, so i need to host the servlet and the databse on a diffrent server.
I really appreciate any help I can get.

Unless you have a specific reason not to, use the simplest, most common approach - socket + http + html.

Similar Messages

  • Applet - Server socket problem

    Hello i'm trying to develop a simple chat application
    The applet connects to the server via a socket and it can successfully send a line of text to the server and receive one back.
    But if I try to put a loop in to receive more lines the applet doesn't start
    here is some source, i'd appreciate any help
    * ChatClient.java
    * Java Applet for communicating with server
    import java.io.*;
    import java.net.*;
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ChatClient extends Applet
         public Panel input;
         public OutputPanel output;
         public PrintWriter out = null;
    public BufferedReader in = null;
         public Socket client = null;
         public Label label;
         public TextField itext;     
         public boolean connected = false;
         public String fromServer = "";
         public void init()
              setLayout( new BorderLayout() );
              input = new Panel();
              input.setLayout( new FlowLayout() );
              label = new Label( "Enter Message" );
              itext = new TextField( 15 );
              TextHandler handler = new TextHandler();
              itext.addActionListener( handler );
              input.add( label );
              input.add( itext );          
              output = new OutputPanel();     
              add( "South", input );
              add( "Center", output );
         public void start()
              String host = getDocumentBase().getHost();          
              try
                   // create socket connection
                   client = new Socket( host, 4444 );
                   out = new PrintWriter( client.getOutputStream(), true );
    in = new BufferedReader( new InputStreamReader( client.getInputStream() ) );
              catch (UnknownHostException e)
                   System.err.println("Don't know about host: 10.1.7.2.");
    System.exit(1);
              catch (IOException e)
    System.err.println("Couldn't get I/O for the connection to: 10.1.7.2.");
    System.exit(1);
              output.otext.append( "Chat client started, listening\n\n" );
              listen();               
         public void listen()
              out.println( "Client 1" );
              try
                   fromServer = in.readLine();
                   output.otext.append( "Server: " + fromServer + "\n\n" );
                   connected = true;
                   //do
                   //     fromServer = in.readLine();
                        System.err.println( "Server: " + fromServer );
                   //     if ( fromServer.equals( "Bye" ) )
                   //          connected = false;
                   //     output.otext.append( "Server: " + fromServer + "\n\n" );
                   //}while ( connected );
              catch( IOException io )
                   System.err.println( "Cannot read from server" );
                   io.printStackTrace();
         public void sendData ( String s )
              out.println( s );
              //output.otext.append( "Client: " + s + "\n\n" );
         public void destroy()
              try
                   out.println( "Bye" );
                   out.close();
                   in.close();
                   client.close();
              catch( IOException io )
                   System.err.println( "Error closing Socket or IO streams");
                   io.printStackTrace();
    class TextHandler implements ActionListener
         public void actionPerformed( ActionEvent e )
              sendData( e.getActionCommand() );
    public String getAppletInfo()
              return "A simple chat program.";
         public static void main(String [] args)
              Frame f = new Frame( "Chat Applet" );
              ChatClient chatclient = new ChatClient();
              chatclient.init();
              chatclient.start();          
              f.add( "Center", chatclient );
              f.setSize( 300, 300 );
              f.show();
    class OutputPanel extends Panel
         public TextArea otext;
         public OutputPanel()
              setBackground( Color.white );
              setLayout( new BorderLayout() );
              otext = new TextArea( 6, 60 );
              otext.setEditable( false );
              add( "Center", otext );
              setVisible( true );
    public void paint(Graphics g)
    }

    I think you have to modify the loop, which receive data from your socket.
    here an example which I tryed
    hope I can help you
    while (z==1)
    anzeige = in.readLine();
    if (anzeige.charAt(0) == ende.charAt(0) && anzeige.charAt(1) == ende.charAt(1) && anzeige.charAt(2) == ende.charAt(2)) // searching for the end"-~-"
    break;
    textField.add(anzeige);

  • Asynchronous applet-servlet communication

    Hi all,
    I am trying to implement asynchronous applet-servlet communication and need your help. Anything would help(I tried with synchronous applet-servlet communication but doesn't solve my problem).
    Thanks,

    http://java.sun.com/docs/books/tutorial/networking/index.html
    You can open a socket connection. Bother the client and the server
    can have separate threads for reading and writing and that you gives you
    asynchronous communication. Later, if you think the server is generating
    too many threads and not scaling, you can use features of .java.nio to
    make it more scalable:
    java.nio.channels

  • Applet-servlet communication, object serialization, problem

    hi,
    I encountered a problem with tomcat 5.5. Grazing the whole web i didn't find any solution (some guys are having the same problem but they also got no useful hint up to now). The problem is as follows:
    I try to build an applet-servlet communication using serialized objects. In my test scenario i write a serialized standard java object (e.g. a String object) onto the ObjectOutputStream of the applet/test-application (it doesn't matters wheter to use the first or the latter one for test cases) and the doPost method of the servlet reads the object from the ObjectInputStream. That works fine. But if i use customized objects (which should also work fine) the same code produces an classnotfound exception. When i try to read and cast the object:
    TestMessage e = (TestMessage)objin.readObject();
    java.lang.ClassNotFoundException: TestMessage
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    ...That seems strange to me, because if i instantiate an object of the same customized class (TestMessage) in the servlet code, the webappclassloader doesn't have any problems loading and handling the class and the code works fine!
    The class is located in the web-inf/classes directory of the application. I've already tried to put the class (with and without the package structure) into the common/classes and server/classes directory, but the exception stays the same (I've also tried to build a jar and put it in the appropriate lib directories).
    I've also tried to catch a Throwable object in order to get information on the cause. But i get a "null" value (the docu says, that this will may be caused by an unknown error).
    I've also inspected the log files intensively. But they gave me no hint. Until now I've spend a lot of time on searching and messing around but i always get this classnotfound exception.
    I hope this is the right place to post this problem and i hope that there is anyone out there who can give me some hint on solving this problem.
    Kindly regards,
    Daniel

    hi, thanks for the reply,
    all my classes are in the web-inf/classes of the web-app and have an appropriate package structure. thus the TestMessage class is inside a package.
    i tried some names for the testclass but it didn't matter. the exception stays the same. I also tried to put the jar in the common/lib but the problem stays.
    Well the problem with loaded classes: As i mentioned in the post above i can instantiate an object of TestMessage in the code without any problems (so the classloader of my webapp should know the class!!)
    only when reading from the objectinputstream the classloader doesn't seem to know the class?? maybe theres a parent classloader resposible for that and doesn't know the class?
    strange behaviour...
    p.s. sending the same object from the servlet to the client works well
    regards
    daniel
    Message was edited by:
    theazazel

  • Applet, Application communication

    Hi
    Someone tell me how to do applet, application communication.
    I have one standalone application, running in server and receiving connection from applets and every min. the server has to send some data back to each apllet connected.
    How to do it... any sample or reffernces please..
    Thanks in advance
    Tomy

    Can you give me example codes using RMI / Socket
    thanks

  • Applet -- Server Name & Port

    Hello Java's
    How can i get a Server Name and Port inside Applet. I am looking for similiar code in servlet to get the server name and port.
    Thanks in advance.

    For applet to server communication you can use URL and URLConnection.
    URL u = new URL(this.getCodeBase(),"../../myservlet");
    Note that if you use a socket the socket does not use your proxy unless you've set it (read
    all your clients have set it).
    Default settings of the jre is that applets will use the browser's proxy settings but this is
    only for URL, sockets don't use your browsers proxy settings at all.

  • Problem in Applet Servlet communication in cluster

              Our new production server has been configured with
              clusters very recently.The application is running fine if and only if one instance
              of weblogic is running.The application has two applets that communicate through a
              servlet and the servlet is hosted by both the WL servers in the cluster.
              Please consider the following scenario :
              1. JSP#1(having embedded tag for Applet#1) is served by, say, WLInstance#1.
              2. JSP#2(having embedded tag for Applet#2) is served by, say, WLInstance#2.
              3. Applet#1 is loaded by BrowserInstance#1.
              4. Applet#2 is loaded by BrowserInstance#2.
              The way I understand applet-servlet communication is as follows :
              The servlets are invoked through the url-pattern specified in web.xml - if the applet
              is making use of a certain url-pattern that is mapped to servlet, then the call from
              that applet will
              eventually invoke a servlet on any of the two instances till a session is established,
              at which point all subsequent requests from the same browser window/frame will go
              to the servlet hosted on the instance where the http session was created.
              (Please correct me, if I am wrong.)
              So, Applet#1 will always talk to the servlet hosted by WLInstance#1 and Applet#2
              will always talk to the servlet hosted by WLInstance#2.
              In our case, the servlet is maintaining data structures to store all the messages
              sent by diffterent instances of Applets.
              The applets periodically polls the messages from those data structures.Once the messages
              are polled, those are deleted from
              the data structures.
              As there are two different instances of the servlet, Applet#1 never gets messages
              posted by Applet#2.
              Is there a way to make this data structure global to both the servlet instances?
              Thanks and best regards,
              Subir Das
              

              "Subir Das" <[email protected]> wrote:
              >So, Applet#1 will always talk to the servlet hosted by WLInstance#1 and
              >Applet#2
              >will always talk to the servlet hosted by WLInstance#2.
              This statement is not entirely true.
              Suppose WLInstance#1 were to be brought down (for whatever reason), Applet#1 will
              then talk to servlet hosted by WLInstance#2.
              Server pinning could be modified by different load balancing algorithms, configurable
              via containers (or hardware).
              So don't count on which servlet instance your applet is going to be served by.
              Instead consider to give a second look into the design of the servlet data structure
              (object):
              1.Read from data store, if it has been persisted.
              2.If the data is client related then consider sticking the data into session, which
              would then replicate to other WL instances.
              3.Stateless EJB in a cluster ? Don' know much about this(yet).
              My 2 cents..Good luck.
              Rama
              

  • Why am I getting the error: error getting license License Server communication problem W_ADEPT_CORE_EXPIRED when I try to download a book from the public library using Adobe Digital Editions. It has been working for a few months, but now I suddenly get th

    I have checked and the Adobe Digital Editions is authorized. The library book doesn't expire for another 14 days.  These have been the only two suggestions that I have found in other forums.  Does anyone have any other suggestions?

    I am having this exact issue. I just downloaded a book and went to open it and got this exact problem.
    I purchased he book through indigo/kobo edition and paid for it and immediately went to open it and am getting the same error
    Error getting License. License Server Communication Problem only mine says  Bad Device key after.
    Not sure why someone has not answered this question yet...i am using windows 7 and this is how i always do it. Never had this problem before when purchasing a book.
    i hope someone answers this soon.

  • When I open a book in Adobe Digital Editions, I get the following error: Error getting License. License Server Communication Problem: E_ADEPT_DOCUMENT_TYPE_UNKNOWN:

    Hi, I bought an e-book in PDF format that uses Adobe DRM.  I've created an account on adobe.com and tried downloading the book in Adobe Digital Editions on the Mac (as well as the bookstore's e-reader--logged into my Adobe account--on an Android device). 
    It tries to download the book but get's the following error:
    Error getting License. License Server Communication Problem:
    E_ADEPT_DOCUMENT_TYPE_UNKNOWN:
    Has anyone come across this?  Any guidance would be most appreciated!
    Thanks!
    Tony

    Please refer to the KB article, Public Knowledge Base

  • Window Server communications from outside of session allowed for root

    Hi ,
    When I am running the following program, i got the exception as
    49:wasp.corp.apple.com_kevinli:/ngs/app/giat/src/java/chart> java MyFrame
    kCGErrorRangeCheck : Window Server communications from outside of session allowed for root and console user only
    Exception in thread "main" java.lang.InternalError: Can't connect to window server - not enough permissions.
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1503)
    at java.lang.Runtime.loadLibrary0(Runtime.java:788)
    at java.lang.System.loadLibrary(System.java:834)
    at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
    at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
    at java.awt.Component.<clinit>(Component.java:506)
    at MyFrame.<clinit>(MyFrame.java:6)
    import java.awt.*;
    import javax.swing.*;
    public class MyFrame
    public static JFrame f = new JFrame();
    public static void main(String[] args)
    JFrame.setDefaultLookAndFeelDecorated(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Add the ubiquitous "Hello World" label.
    JLabel label = new JLabel("Hello World");
    f.getContentPane().add(label);
    //Display the window.
    f.pack();
    f.setVisible(true);
    Please send a reply on this.
    with regards,
    Mohan

    Seth,
    you may also install the latest update (10.4.6) using the combo file from apple.com.
    Mihalis.
    Dual G5 @ 2GHz   Mac OS X (10.4.6)  

  • I keep getting the following message after I download a book and try to open the book from my downloads (in finder) Error getting License. License Server Communication Problem: E_ACT_NOT_READY. It gives me no other information and no options other than to

    I don't really know what to do. I download a book from my library and it then goes to my download folder in finder (I have a macbook pro). When I double click on the downloaded book to open, digital editions comes up and then I get the following message
    Error getting License. License Server Communication Problem:
    E_ACT_NOT_READY
    The only option I have at that point is to close the window. My computer is registered/authorized and I have tried everything I can think of but can't get the books to download into adobe digital editions.
    Help please

    I am having this exact issue. I just downloaded a book and went to open it and got this exact problem.
    I purchased he book through indigo/kobo edition and paid for it and immediately went to open it and am getting the same error
    Error getting License. License Server Communication Problem only mine says  Bad Device key after.
    Not sure why someone has not answered this question yet...i am using windows 7 and this is how i always do it. Never had this problem before when purchasing a book.
    i hope someone answers this soon.

  • I upgraded to a new apple mac book pro and now when I try to download to adobe digital edition I receive this error:Error getting License. License Server Communication Problem: E_ACT_NOT_READY

    I upgraded to a new apple mac book pro and now when I try to download to adobe digital edition I receive this error:Error getting License. License Server Communication Problem: E_ACT_NOT_READY

    What does that have to do with Digital Publishing Suite?
    We’d love to help but if does have something to do with it, please give us
    some details.

  • Applet/servlet communication for byte transmission

    Hello all !
    I wrote an applet to transfer binary file from web servlet (running under Tomcat 5.5) to a client (it's a signed applet) but I have a problem of interpretation of byte during transmission.
    the code of the servlet is :
            response.setContentType("application/octet-stream");
            ServletOutputStream sos = response.getOutputStream();
            FileInputStream fis = new FileInputStream(new File(
                    "C:\\WINDOWS\\system32\\setup.bmp"));
            byte[] b = new byte[1024];
            int nbRead = 1;
            while (nbRead > 0) {
                nbRead = fis.read(b);
                System.out.println("octets lus = " + nbRead);
                sos.write(b, 0, nbRead-1);
            fis.close();
            sos.close();et le code de l'applet qui appelle cette servlet est :
            URL selicPortal = null;
            try {
                selicPortal = new URL(
                        "http://localhost:8080/AppletTest/servlet/FileManipulation");
            } catch (MalformedURLException e) {
                e.printStackTrace();
            URLConnection selicConnection = null;
            try {
                selicConnection = selicPortal.openConnection();
            } catch (IOException e) {
                e.printStackTrace();
            selicConnection.setDoInput(true);
            selicConnection.setDoOutput(true);
            selicConnection.setUseCaches(false);
            selicConnection.setRequestProperty("Content-Type",
                    "application/octet-stream");
            try {
                InputStream in = selicConnection.getInputStream();
                FileOutputStream fos = new FileOutputStream(new File(tempDir
                        + "\\toto.bmp"));
                byte[] b = new byte[1024];
                int nbRead = in.read(b);
                while (nbRead > 0) {
                    fos.write(b);
                in.close();
                fos.close();
             } catch (IOException ioe) {
                ioe.printStackTrace();
            }the file dowloaded is broken. it seems that bytes 01 00 or 00 01 are not correctly process.
    Some ideas to help me please ?

    hi,
    have you solved this issue.. please post me the code since i m also doing the applet/servlet communication and can use your code as reference.
    how to read the content placed in the urlConnection stream in the servlet
    Below is my code in applet
    public void upload(byte[] imageByte)
              URL uploadURL=null;
              try
                   uploadURL=new URL("<url>");
                   URLConnection urlConnection=uploadURL.openConnection();
                   urlConnection.setDoInput(true);
                   urlConnection.setDoOutput(true);
                   urlConnection.setUseCaches(false);
                   urlConnection.setRequestProperty("Content-type","application/octet-stream");
                   urlConnection.setRequestProperty("Content-length",""+imageByte.length);
                   OutputStream outStream=urlConnection.getOutputStream();
                   outStream.write(imageByte);
                   outStream.close();
              catch(MalformedURLException ex)
              catch(IOException ex)
    How can i read the byte sent on the outstream (in above code) in the servlet.
    Thanks,
    Mclaren

  • Agentry Server Communications error (14)

    Hi All,
    We are trying to use WPF client for testing the application,
    but we were getting the below error message
    To resolve that we used the local certificate generated by using steps mentioned in the below link
       http://infocenter.sybase.com/help/topic/com.sybase.infocenter.dc01930.0233/doc/html/fre1383608304168.html
    After installing new certificate we are getting below communication error in ATE and as well as in WPF client:
    before installing local certificate Application was working fine in ATE
    Message:
    Requesting Public Key from Server
    Communications error (14)
    Connection failed
    Ending transmission
    Please guide me to resolve the issue
    Regards,
    Lekhak Patil

    Hi  Steve,
    We got the same issue working with WPF client  , Hence we upgraded the SMP server 2.3 from SP00 to SP03 .
    At present the Server is SMP 2.3 SP03  but we have not installed any certificate.
    Again when trying to connect to server we got the Communication error(14) error.
    Do we need to install the certificate again ?
    Please let us know the exact process of installing and working with WPF client with SMP 2.3 SP03
    Thanks
    Neha

  • Is there a good advanced review on applet-servlet communication

    I am working on a web application and unfortunately experiencing a lot of trouble trying to use an applet as front end which interacts with a couple of servlets running on Tomcat. I need to get data from one servlet and send data to another.
    There is a lot of messages posted in this and other forums about how to do this, but none of them got a response pointing to a useful advanced reference on this subject. I have reviewed some of the references given, but couldn't find a thorough detailed advanced reference on applet-servlet communication. For this I mean an exhaustive explanation of the mechanism of communication and when and when is neccesary to use each of the multiple configuration possibilities regarding content-type, message-length, request-method, connection settings, and so on.
    Would anybody be so kind to show me the right direction? As I read the (literally) hundreds of messages posted on this topic, I see this info as widely useful. Most of the topic tracks ends on void or with painful no-way sentences, and maybe many people is avoiding Java technology on web application because of this problem (development delays can abort a project).

    This sample chapter in Java developers' guide to Servlets and Jsp focuses on Applet-Servlet communication, is a pretty good one, and is free :
    http://www.javaranch.com/bunkhouse/samps/2809ch12.pdf
    As to an exhaustive & complete guide that covers absolutely everything, I may be wrong but I doubt you'll find anything like that...unless there is a book somewhere dedicated to the subject.

Maybe you are looking for