Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Serving a web page with embedded applet
Serving a web page with embedded applet [message #640251] Fri, 19 November 2010 18:30 Go to next message
Nick Violi is currently offline Nick VioliFriend
Messages: 1
Registered: November 2010
Junior Member
Hello,
I'm trying to create a web project that serves a web page with an embedded applet using WTP / Tomcat 6.

If I compile the applet manually and build the project manually in Tomcat it works fine, so I know there's no problem with the code or my server setup.

I think the problem might be something with the way Eclipse builds projects, like how to refer to the location of the applet from the WebContent folder.

I tried:
*referring to "../build/classes/MyApplet.class" from index.html in the WebContent folder
*manually moving the class files from build/classes to WebContent
*setting WebContent as the output folder

In all cases the applet simply does not show up. In Firefox I get a gray rectangle and the message "Start: Applet not initialized". In Chrome and Eclipse's built-in browser I just get blank space.

Can anyone give me a push in the right direction? Am I missing some configuration to give the server access to the applet? Am I not on the right track at all?
Re: Serving a web page with embedded applet [message #640290 is a reply to message #640251] Sat, 20 November 2010 01:24 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
WTP assumes that all classes you build in your Dynamic Web Project are
destined to reside in WEB-INF/classes, which is by design inaccessible
to browsers. To add applets to your project you will need to first open
the project's Properties dialog and on the Java Build Path Source tab,
add a new source folder specifically for applet classes. You then need
to enable "Allow output folders for source folders" and assign this
applet source folder its own output folder. Switch to the Deployment
Assembly properties page, applying the changes to the build path when
prompted. Select the item that has a Deploy Path of "WEB-INF/classes"
and references your applet source folder, then click Remove. Next click
Add, select "Folder Mapping", and click Next. In the Add Folder dialog,
pick the *output* folder for the applet source folder and click Finish.
Verify that the Deploy Path for this output folder is "/", and click
OK to exit the Properties dialog. Now, whatever you build in your
applet source folder will go into the "content" portion of your Web
application where it belongs, and not into WEB-INF/classes.

Cheers,
Larry

On 11/19/2010 1:30 PM, nvioli2@gmail.com wrote:
> Hello,
> I'm trying to create a web project that serves a web page with an
> embedded applet using WTP / Tomcat 6.
>
> If I compile the applet manually and build the project manually in
> Tomcat it works fine, so I know there's no problem with the code or my
> server setup.
>
> I think the problem might be something with the way Eclipse builds
> projects, like how to refer to the location of the applet from the
> WebContent folder.
>
> I tried:
> *referring to "../build/classes/MyApplet.class" from index.html in the
> WebContent folder
> *manually moving the class files from build/classes to WebContent
> *setting WebContent as the output folder
>
> In all cases the applet simply does not show up. In Firefox I get a gray
> rectangle and the message "Start: Applet not initialized". In Chrome and
> Eclipse's built-in browser I just get blank space.
>
> Can anyone give me a push in the right direction? Am I missing some
> configuration to give the server access to the applet? Am I not on the
> right track at all?
Re: Serving a web page with embedded applet [message #773582 is a reply to message #640251] Mon, 02 January 2012 02:52 Go to previous messageGo to next message
Ed Thompson is currently offline Ed ThompsonFriend
Messages: 5
Registered: December 2011
Junior Member
Larry,

I've been working on a similar problem for a few days now and was hoping you could help me out. I'm new to all of this, but this seems to be the problem that has insisted on perpetually kicking my but. I am using Tomcat 7.0.

Project name: ThompsonFamily (I am just using a family website as place to practice some of the things I've learned)

Applet name: CalcLoan

Browser: Google Chrome

I have a dynamic web project that has an applet. I believe that I have it set up as you directed (but the "Allow output folders for source folders" box does not stay checked). My output folder is the default, and within the workspace/build/classes/CalcLoan directory are two files: CalLoan$1.class, and CalcLoan.class. After exporting a WAR file, these are also shown in the directory WEB-INF/classes/calcLoan.

In the Tomcat webapps/ThompsonFamily directory, I now have a CalcLoan folder (after following your previous post), which contains a CalcLoan.java file.

My call for the applet is: <applet code="CalcLoan.class" width="320" height="200"></applet>

The error I'm receiving is kinda long, but boils down to "class not found."

I've tried copying the CalcLoan$1.class and CalcLoan.class files into the new CalcLoan folder just to see if I could get this to work, but that didn't help at all.

Any suggestion you may have would be highly appreciated (aside from giving up).

Thanks,

Ed





[Updated on: Mon, 02 January 2012 03:00]

Report message to a moderator

Re: Serving a web page with embedded applet [message #773777 is a reply to message #773582] Mon, 02 January 2012 14:02 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
On 1/1/2012 9:52 PM, Ed Thompson wrote:
> Nick,
>
> I've been working on a similar problem for a few days now and was hoping
> you could help me out. I'm new to all of this, but this seems to be the
> problem that has insisted on perpetually kicking my but. I am using
> Tomcat 7.0.
>
> Project name: ThompsonFamily (I am just using a family website as place
> to practice some of the things I've learned)
>
> Applet name: CalcLoan
>
> Browser: Google Chrome
>
> I have a dynamic web project that has an applet. I believe that I have
> it set up as you directed (but the "Allow output folders for source
> folders" box does not stay checked). My output folder is the default,
> and within the workspace/build/classes/CalcLoan directory are two files:
> CalLoan$1.class, and CalcLoan.class. After exporting a WAR file, these
> are also shown in the directory WEB-INF/classes/calcLoan.
>
> In the Tomcat webapps/ThompsonFamily directory, I now have a CalcLoan
> folder (after following your previous post), which contains a
> CalcLoan.java file.
>
> My call for the applet is: <applet code="CalcLoan.class" width="320"
> height="200"></applet>
>
> The error I'm receiving is kinda long, but boils down to "class not found."
>
> I've tried copying the CalcLoan$1.class and CalcLoan.class files into
> the new CalcLoan folder just to see if I could get this to work, but
> that didn't help at all.
>
> Any suggestion you may have would be highly appreciated (aside from
> giving up).
>
> Thanks,
>
> Golfnut
>

Where is the "CalcLoan" folder in your project?

Note: It should not be under the "src" folder (i.e. "src/CalcLoan") as
it needs to be a separate Java source folder.

Cheers,
Larry
Re: Serving a web page with embedded applet [message #773872 is a reply to message #773777] Mon, 02 January 2012 19:16 Go to previous messageGo to next message
Ed Thompson is currently offline Ed ThompsonFriend
Messages: 5
Registered: December 2011
Junior Member
The Applets folder is not in the src folder

ThompsonFamily
src
Applets
---calcLoan
------CalcLoan.java
JRE System Library
Apache Tomcat 7.90
build
ThompsonFamily
---build
Webcontent
---everal files

Please let me know any other info I can give you to assist. Thanks much for replying!!!

Ed


Re: Serving a web page with embedded applet [message #773903 is a reply to message #773872] Mon, 02 January 2012 21:11 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
On 1/2/2012 2:16 PM, Ed Thompson wrote:
> The Applets folder is not in the src folder
>
> ThompsonFamily
> src
> Applets
> ---calcLoan
> ------CalcLoan.java
> JRE System Library
> Apache Tomcat 7.90
> build
> ThompsonFamily
> ---build
> Webcontent
> ---everal files
>
> Please let me know any other info I can give you to assist. Thanks much
> for replying!!!
>
> Ed
>
>
>

If you go to the Source tab on the Java Build Path page of the
ThompsonFamily project properties, do you see "Applets" or
"Applets/calcLoan" listed as a source folder?

Cheers,
Larry
Re: Serving a web page with embedded applet [message #773929 is a reply to message #773903] Mon, 02 January 2012 22:35 Go to previous messageGo to next message
Ed Thompson is currently offline Ed ThompsonFriend
Messages: 5
Registered: December 2011
Junior Member
I see two source folders.
ThompsonFamily/Applets
ThompsonFamily/src
Re: Serving a web page with embedded applet [message #774015 is a reply to message #773929] Tue, 03 January 2012 05:01 Go to previous messageGo to next message
Ed Thompson is currently offline Ed ThompsonFriend
Messages: 5
Registered: December 2011
Junior Member
Hoping this may provide you with a little more information. The attachment shows a couple screen shots of my project (I realize that "Funstuff.html" should be "funstuff.html", but am just trying to get the applet to work for now).

Thanks again


Ed
Re: Serving a web page with embedded applet [message #774019 is a reply to message #774015] Tue, 03 January 2012 05:12 Go to previous messageGo to next message
Ed Thompson is currently offline Ed ThompsonFriend
Messages: 5
Registered: December 2011
Junior Member
Okay now--got it working with: code="calcLoan/CalcLoan.class". I hadn't that before because I have been reading to use codebase to show a different file location than the location of the calling html doc. Is this the correct method, or is this a (frowned upon) shortcut?

Thanks,

Ed
Re: Serving a web page with embedded applet [message #774245 is a reply to message #773929] Tue, 03 January 2012 15:22 Go to previous message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
On 1/2/2012 5:35 PM, Ed Thompson wrote:
> I see two source folders.
> ThompsonFamily/Applets
> ThompsonFamily/src

In the Source tab, enable the "Allow output folders for source folders"
option. Then expand "ThompsonFamily/Applets" and select the "Output
folder" item and click "Edit...". In the dialog that appears, select
"Specific output folder..." and provide an output folder other than
"build/classes", perhaps "build/Applets". This gives you a project
folder where the applet class will be compiled that can be used as a
content folder (like "WebContent").

On the Deployment Assembly page you should remove any mapping with
"/Applets" as the source. Then you should add a mapping for the output
folder for "Applets" (e.g. "/build/Applets") to "/" (I believe the
<applet> tag will default to looking for classes from the root of the
webapp). This will put the applet class in the correct location in your
webapp and not treat it like servlet classes which go under
"WEB-INF/classes".

As you noted in your later e-mail, since "Applets" is your Java source
folder, the fully qualified applet class is "calcLoan.CalcLoan". Your
<applet> tag will have to account for the "calcLoan" package for it to
work. It's been a long time since I messed with applets so I'll let you
work out any additional details with the <applet> tag.

Cheers,
Larry
Previous Topic:Web Application Setup
Next Topic:Listening for EAR Changes
Goto Forum:
  


Current Time: Tue Nov 25 23:41:32 GMT 2014

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

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