aspose file tools*
The moose likes Servlets and the fly likes Servlet can Call an Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet can Call an Applet " Watch "Servlet can Call an Applet " New topic
Author

Servlet can Call an Applet

mala H.R.
Greenhorn

Joined: Dec 21, 2002
Posts: 4
My Question is when servlet call an applet like this
out.println("<applet code=xyz.class codebase=http://..... width=200 height=400></applet>")
is this works?? if yes kindly tell me where the xyz.class should placed or how should i call an applet class in servlet??
i have placed xyz.class file in the same directory as my servlet class file.
ie. http://url/servlet directory.
what path should i give it to call my applet in servlet.should it be
out.println("<applet code=xyz.class codebase=http://url/servlet/ width=200 height=400></applet>")
or if i place my applet xyz.class in html directory.then how should i give the path. since
both the ways are not working.
it is should applet load: class xyz not found
thanks in advance
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
1. Servlets don't call applets, servlets write HTML pages that have embedded applet tags.
2. Applet classes are loaded by applet rules NOT servlet rules. They are loaded by requests from the browser to the web server so the class files have to be where the web server can serve them. Servers are forbidden to serve files from WEB-INF.
3. A page written by a servlet should look just like a static HTML page when it gets to the browser.
You should start by creating a static page containing your applet and get that running. Then you can work on making your servlet write a page containing the applet tag.
Bill
Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 626

In short you just have to use Http Tunneling.
-jignesh
Debashish Chakrabarty
Ranch Hand

Joined: May 14, 2002
Posts: 230

Originally posted by j_kokil:
In short you just have to use Http Tunneling.

Hi Jignesh,
I am afraid we are not talking about HTTP tunneling here, are we Bill? This query was not about Applet-Servlet communication, the servlets simply creates an APPLET tag. HTTP tunneling is simply a way of bypassing firewall restrictions and enabling Java applets to communicate with the servers.


Debashish
SCJP2, SCWCD 1.4, PMP, ITIL Foundation
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
As I understand the use of the word, we are not talking about HTTP tunneling when a browser loads an applet by requesting class files from the server. Now, if the applet exchanges data with the server using a HttpURLConnection, I would call it tunneling.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet can Call an Applet