Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Load applet class In a servlet ?

Status
Not open for further replies.

mithra

Programmer
May 26, 2000
21
IN
Hi,<br><br>&nbsp;&nbsp;&nbsp;We have an applet and we want to embed it in the output of our servlet. Applet works fine with HTML but does not get executed when it is being output by Servlet. Can anyone help us?<br><br>&nbsp;&nbsp;Thanks<br>Mithra
 
Dear Mithra,<br><br>Do you mean that you are generating an &lt;applet&gt; HTML tag in your Servlet?<br><br>If so and the applet does not run in the resultant page then there must be an error in the HTML you are generating. <br><br>Once you view the page from your Servlet in the browser, use the 'View Source' menu command in the browser and save the HTML file to disk.<br><br>Then edit and repair the HTML file until the applet runs correctly. This will allow you to find the errors produced in your Servlet code.<br><br>Good luck<br>-pete
 
Can somebody give a concrete example of code for running an applet in a servlet ?
Thank You.
Vinh
 
Hi,

I know it sounds funny but somehow I can't seem to load applets using servlets too. It seems to me that the applets are somehow not downloaded to the client's pc.

In case if you think my HTML page is incorrect, what I did was I have a HTML page that when open will load an APPLET. Nothing is wrong with this, my applet was loaded successfully. I then created a servlet which prints out to the response page exactly with the same codes as my HTML page but somehow the applet was not loaded. So in this case, it can't be that my HTML codes are wrong.

So what I did instead was to create a response page through the servlet containing javascript. When the page loads, it will call a javascript function which will reload the page into the original HTML page(that manages to load the applet successfully. Somehow it works this way.

Hopefully someone can help to solve this problem too as I feel that the using of javascript is just a temp solution??

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
hi,
just to prove your all mad, i thought i would check out these clames of applet/servlet issues abd, to be honest, i can't reproduce any of your errors. Sorry!!!

first of all i used the normal html...no problem. i then saved the html into a jsp file. a jsp as we all know is compiled into a servlet. no problem. So i created a servlet to test the applet....and it worked fine :)

I used the CLSFractal applet that comes as and example servlet with jdk1.3. i am also using tomcat as my servlet engine....what tools are u guys using????

i can email anyone the servlet code if they want it but its not any different to anything i've seen posted here
 
Hi LittleWing,

Well I guess we are sort of mad :p (cus it doesn't make any sense for not being able to load the applet)

However, some questions. Which directory did you put your applet files into? Which directory did you put your jsp files in? Did you put the applet class files into a JAR file or just as a single class file? Did you specify the codebase for the applet class/JAR file?

Thanks for your time,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
hi,
i used the following directory structure.

c:\myapp <- build files etc
c:\myapp\src\servlet <- servlet source
c:\myapp\src\applet <- applet source
c:\myapp\web <- html/jsp

yes, all class files are added to a jar alright.

after performing the tomcat build, all the files end up in the following directory structure.

c:\tomcat\webapps\myapp <- html/jsp files end up here
c:\tomcat\webapps\myapp\WEB-INF <- jar contents here

I then called the following url
and i saw the fractal applet working away

I hope this helps, source available on request

by the way, neither the applet(used as is) or the servlet are in any specific package.

what applications are u using??? could there be a bug in the servlet container you are using? or maybe i'm the one with the bug that allows it to work! :)
 
Very sorry LittleWing... I haven't have the time to do much testing... quite bz at work. I promise you I will work on it once I have the time. If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top