• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Communication between Servlet and Applet

 
Amol Chavan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

One more Doubt!!!
Can anyone tell me how can an Applet and servlet can communicate with each other?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the Applet FAQ for a link to an article and an example describing how to do this.
 
Dan Kim
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this simple example:

http://www.frank-buss.de/echoservlet/
 
fedai gandjaliyev
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is simple.
Say your servlet (HelloServlet) resides in the WEB-INF/classes of your web server.
And the code looks like this:


import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletException;


public class HelloServlet extends HttpServlet{


public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{

PrintWriter pw = response.getWriter();
pw.println(accessType);
pw.flush();
pw.close();

}

In your applet (in an event of pressing a button, for ex.) type the following
getAppletContext).showDocument("http:\\hostname\\servlet\\HelloServlet ort");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic