Skip to main content



      Home
Home » Newcomers » Newcomers » Loading an applet from a servlet
Loading an applet from a servlet [message #166743] Tue, 22 August 2006 14:35 Go to next message
Eclipse UserFriend
Originally posted by: anthonymacegan.yahoo.ie

I am using Eclipse with Tomcat as my server.
I have been using servlets to generate html and all is working well.
I now want to call an applet within the servlet.
I am not having much success and am reading a lot of stuff on various
sites but I can find no definate information.
I create the applet like any other class and when I have it saved I choose
to run it as an applet and it works fine. It is stored in the same folder
as the other classes.
jakarta-tomcat-5.5.7\ProjectX\WEB-INF\classes

So when I call it within the applet tags what should I specify as the
CODEBASE?
Do I have to create a web.xml file and do some mapping of sorts?
Do I save the class in a different folder.
The applet is a simple one I am using as an initial test.

import java.awt.*;
import java.applet.Applet;

public class CounterApplet extends Applet
{
Button button1, button2, button3, button4, button5;

public void init()
{
this.setLayout(new BorderLayout());
button1 = new Button("Button 1");
button2 = new Button("Button 2");
button3 = new Button("Button 3");
button4 = new Button("Button 4");
button5 = new Button("Button 5");
add("North",button1);
add("South",button2);
add("East",button3);
add("West",button4);
add("Center",button5);
}
}

Any help would be greatly appreciated.
Best regards,
Anthony.
Re: Loading an applet from a servlet [message #166920 is a reply to message #166743] Wed, 23 August 2006 16:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse4.rizzoweb.com

Anthony wrote:
> I am using Eclipse with Tomcat as my server.
> I have been using servlets to generate html and all is working well.
> I now want to call an applet within the servlet. I am not having much
> success and am reading a lot of stuff on various sites but I can find no
> definate information.
> I create the applet like any other class and when I have it saved I
> choose to run it as an applet and it works fine. It is stored in the
> same folder as the other classes.
> jakarta-tomcat-5.5.7\ProjectX\WEB-INF\classes
>
> So when I call it within the applet tags what should I specify as the
> CODEBASE?
> Do I have to create a web.xml file and do some mapping of sorts?
> Do I save the class in a different folder.

Bottom line: you've got a bit more research to do.
Servlet code runs on the server (Tomcat, in your case), while applet
code is served as static files to the browser and runs there.
You are trying to mix the two, when in fact they are totally orthogonal,
not related.

You'll need to deploy your applet code alongside where you deploy your
HTML or images or other browser-accessible files, then construct a page
with an appropriate <applet> tag to reference the applet code. I'd
recommend packaging the applet classes as a JAR which you make publicly
available on your server - makes things a little easier in my opinion.

Remember, servlet and applet code have nothing to do with each other.

Hope this helps,
Eric
Re: Loading an applet from a servlet [message #166936 is a reply to message #166920] Wed, 23 August 2006 17:03 Go to previous message
Eclipse UserFriend
Originally posted by: anthonymacegan.yahoo.ie

Thanks Eric.
I will try this approach.
Could you give me an idea as to how I make the jar files publically
available from the server (running on my own machine)
Ths is a bit of a new field for me but I am really hungry for any new
knowledge.
Thanks for your help so far.
Anthony.
Previous Topic:perference change listner error
Next Topic:Project like Visio
Goto Forum:
  


Current Time: Sun May 11 23:24:42 EDT 2025

Powered by FUDForum. Page generated in 0.32836 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top