Applet to servlet communication


Web tier: servlets, JSP, Web frameworks: Applet to servlet communication

  1. Applet to servlet communication (6 messages)

    Hello. I want to know about how to write program on applet
    to servlet communication.please give example also.

    Thanks in advance

    Threaded Messages (6)

  2. You have to send a HTTP request from the applet to the servlet. It is looks like obtaining any HTML page from the applet. So, if you want to send parameters to servlet by GET method, use URLConnection class. If you wish to use POST method, probably, created the request manualy and sent it through Socket, port 80. But somethere may exist some more convenient classes.
  3. Applet to servlet communication[ Go to top ]

    The book by Marty Hall, Core Servlets and JavaServer Pages (JSP), has an example with code on how to do Applet to Servlet communication. Should have what you are looking for.
  4. Applet to servlet communication[ Go to top ]

    Try to get the book JAVA Servlet programming by Jason Hunter. It has the example that you need. You can also look at the O Reilly website at

  5. visit
    it has applet-servlet example

  6. Re: Applet to servlet communication[ Go to top ]

    Here is the code which you can use to communication between applet and servlet/JSP following code can be used at applet side : /* *URL to servlet */ URL serverURL = new URL(servletPath); URLConnection connection = serverURL.openConnection(); /* * Connection will be used for both input and output */ connection.setDoInput(true); connection.setDoOutput(true); /* * Disable caching */ connection.setUseCaches(false); /* *connection will be used for transfaring serialized java objects. */ connection.setRequestProperty("Content-Type", "application/octet-stream"); ObjectOutputStream outputStream = new ObjectOutputStream(connection.getOutputStream()); outputStream.writeObject(request); outputStream.flush(); outputStream.close(); ObjectInputStream inputStream = new ObjectInputStream(connection.getInputStream()); response = (Map)inputStream.readObject(); inputStream.close(); Here response is the response Map returned from servlet. following code can be used in your servlet to send serializable objects to applet. write this code in doXXX method of servlet. ObjectOutputStream out = new ObjectOutputStream(response.getOutputStream()); Map responseMap = new HashMap(); /* put watever objects you wants to return to applet. This objects must be serializable. responseMap.put("a", "a"); */ out.writeObject(responseMap); out.flush(); out.close(); response.setStatus(HttpServletResponse.SC_NO_CONTENT); SS
  7. Re: Applet to servlet communication[ Go to top ]

    See Applet Servlet Communication Example