File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes request from Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "request from Applet" Watch "request from Applet" New topic

request from Applet

Xinyi Zhang
Ranch Hand

Joined: Apr 28, 2001
Posts: 42
Can a Applet send HTTP request? I mean it communicate with Servlet or JavaBean.

Devesh H Rao
Ranch Hand

Joined: Feb 09, 2002
Posts: 687

hi Xinyi
you can communicate with a servlet from a servlet in the following way
URL servletURL = new URL("/URL of servlet");
URLConnection oServletConnection = servletURL.openConnection();
ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
and then use the java api for ObjectInputStream to communicate with the servlet....
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
hey, if GET request is good enough for you, you don't need http tunneling.
you can use getAppletContext().showDocument(new URL("path_to_servlet");
from your applet.

Asher Tarnopolski
Xinyi Zhang
Ranch Hand

Joined: Apr 28, 2001
Posts: 42
Thanks, Devesh and Asher. Now, Let me try.
I agree. Here's the link:
subject: request from Applet
It's not a secret anymore!