Hello. I want to know about how to write program on applet
to servlet communication.please give example also.
Thanks in advance
-
Applet to servlet communication (6 messages)
- Posted by: Nishant Jindal
- Posted on: October 25 2000 07:55 EDT
Threaded Messages (6)
- Applet to servlet communication by Anonimous Anonimous on October 25 2000 11:17 EDT
- Applet to servlet communication by Marty Mersinger on October 26 2000 09:54 EDT
- Applet to servlet communication by Sohail Sikora on October 27 2000 17:16 EDT
- Applet to servlet communication by sundar varadarajan on November 02 2000 04:35 EST
- Re: Applet to servlet communication by J Dev on September 09 2007 03:19 EDT
- Re: Applet to servlet communication by J Dev on September 25 2008 10:05 EDT
-
Applet to servlet communication[ Go to top ]
- Posted by: Anonimous Anonimous
- Posted on: October 25 2000 11:17 EDT
- in response to Nishant Jindal
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.
-
Applet to servlet communication[ Go to top ]
- Posted by: Marty Mersinger
- Posted on: October 26 2000 09:54 EDT
- in response to Nishant Jindal
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.
-
Applet to servlet communication[ Go to top ]
- Posted by: Sohail Sikora
- Posted on: October 27 2000 17:16 EDT
- in response to Nishant Jindal
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 www.oreilly.com -
Applet to servlet communication[ Go to top ]
- Posted by: sundar varadarajan
- Posted on: November 02 2000 04:35 EST
- in response to Sohail Sikora
visit www.j-nine.com/pubs.
it has applet-servlet example
thanx
sundar -
Re: Applet to servlet communication[ Go to top ]
- Posted by: J Dev
- Posted on: September 09 2007 03:19 EDT
- in response to Nishant Jindal
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 http://www.jyog.com -
Re: Applet to servlet communication[ Go to top ]
- Posted by: J Dev
- Posted on: September 25 2008 10:05 EDT
- in response to Nishant Jindal