Proper way of embedding an applet in a web page.

H

Heath Raftery

Hi there,

I thought this would be a fundamental token of knowledge in Java
but after weeks of searching and experimentation I am no closer to
a happy solution.

Quite simply, I wish to embed a Java applet residing in a jar archive,
into a web page for display on the Internet via the largest audience.

The deprecated method appears to be this:

<APPLET
archive="JarArchive.jar"
code="MyMainClass"
codebase="directory/of/jar/file"
width=500 height=311>
<param name="nameOfParam" value="valueOfParam">
Alternate text.
</APPLET>

I wanted to be buzzword compliant, and also became interested in
doing some version checking (because of a crash in IE with a
particular version of JVM) so looked up the preferred method.

This is where I ran into trouble of course - I could not find an
authorative source of documentation. Essentially, the common
knowlege appears to suggest this format:

<object
classid="clsid:CAFEEFAC-0015-0000-0000-ABCDEFFEDCBA"
<param name="code" value="Applet1.class">
<comment>
<embed code="Applet1.class"
type="application/x-java-applet;jpi-version=1.5.0">
<noembed>
No Java Support.
</noembed>
</embed>
</comment>
</object>

But that opens up a huge can of worms. How do I set a classid?
How do I specify a different version? What happens if a newer/
older version is installed? What if I want to use a jar file?
Do I use a java: or a clsid:? How long is this syntax likely to
be valid (since it's obviously a crude workaround)?

Ultimately, I've been unable to arrive at a satisfactory solution
using the second format, so I've abandoned version checking and
reverted to the original applet syntax. What are other people doing?

Regards,
Heath
 
R

Roedy Green

The deprecated method appears to be this:

<APPLET
archive=

IT is officially deprecated but it is better supported that the
supposed replacement. So I say **** W3C and their kowtowing to
Microsoft in yet another attempt to screw over Java.
 
T

Tail_Spin

Did you try the " HtmlConverter.exe " that comes with jdk?
It creates the appropriate <object>, <applet>, etc tags so that your applet
call will be compatible across a number of browsers.

You can find it in: \j2sdk1.4.2_05\bin





...
 
R

Roedy Green

Did you try the " HtmlConverter.exe " that comes with jdk?
It creates the appropriate <object>, <applet>, etc tags so that your applet
call will be compatible across a number of browsers.

The code it generates is utterly preposterous, reams and reams of crap
to invoke a microscopic Applet with 2 parameters. It is an obscene
joke, somebody's equivalent of a king making their subjects eat feces.
..
 
A

andrewthommo

Heath Raftery wrote:
....
I thought this would be a fundamental token of knowledge in Java
but after weeks of searching and experimentation I am no closer to
a happy solution.

Applet placement in web pages is a mess.
Quite simply, I wish to embed a Java applet residing in a jar archive,
into a web page for display on the Internet via the largest audience.

Use the applet tag unless you require versioning, and if so,
consider using a n applet launched by WebStart (which can do
the versioning) or converting the applet to an application.
The deprecated method appears to be this:

<APPLET

It is a deprecated HTML element. It was valid in HTML 3.2,
but was deprecated in HTML 4.0. I am with Roedy when I
agree it should be reinstated. The alternative nested elements
are a mess, are not valid HTML (either) and are difficult to
maintain in any reliable way.
I wanted to be buzzword compliant,

That's just idiotic. Can you name any single *technical*
reason why the nested elements would be better for your applet?
..and also became interested in
doing some version checking (because of a crash in IE with a
particular version of JVM) so looked up the preferred method.

It is not 'the preferred method', it was simply one alternative
offered by Sun. They have more recently begun recommending
you do *not* use it, though I don't have the time to hunt for the
references.
This is where I ran into trouble of course - I could not find an
authorative source of documentation. Essentially, the common
knowlege appears to suggest this format:

<object
classid="clsid:CAFEEFAC-0015-0000-0000-ABCDEFFEDCBA" ....
But that opens up a huge can of worms. How do I set a classid?

Class-ID's are explained somewhere on Sun's site. Try a search using
one of their clsid strings and it should lead you to a table of the
Java versions and their corresponding classid's.
How do I specify a different version? What happens if a newer/
older version is installed?

It depends on other codes in the elements. Check the HTMLConverter
documentation for further details. Basically the element can either
specify a specific Java version '1.4.2_03' precisely, *or* 'any version
1.4 +'. See the docs for further details.
What if I want to use a jar file?

Yes, it works.

...What are other people doing?

Reading the (sometimes hard to locate) documentation.

Andrew T.
 
T

trippy

Roedy Green said:
IT is officially deprecated but it is better supported that the
supposed replacement. So I say **** W3C and their kowtowing to
Microsoft in yet another attempt to screw over Java.

I can never get an <object> element to work right.

--
trippy
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

NP: "Doughnut Song" -- Tori Amos

"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum, a pocketknife,
and a smile."

-- Robert Redford "Spy Game"
 
T

Tail_Spin

...
I wanted to be buzzword compliant, and also became interested in
doing some version checking (because of a crash in IE with a
particular version of JVM) so looked up the preferred method.

This is what it took for me to get one little applet to run, lol. I used
LiveConnect for cookies and
that further complicated things because I found that live connect crashed
the browser when running
on win '98 in Firefox, so I had to create two versions of my applet, one
with cookies and one without.
What a pain!! With all the standards organizations around these days, why
can't they get their shit together?

<OBJECT
classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase =
"http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,
0,0"
WIDTH = "750" HEIGHT = "26" >

<PARAM NAME = CODE VALUE = "StandingsTicker.class">
<PARAM NAME = CODEBASE VALUE = "http://www.freesimracing.com/">
<PARAM NAME = MAYSCRIPT VALUE = true >
<PARAM NAME = ARCHIVE VALUE =
"garry/standingsTicker/StandingsTicker.jar">
<PARAM NAME = "type" VALUE = "application/x-java-applet;version=1.4">
<PARAM NAME = "scriptable" VALUE = "false">
<PARAM NAME = "DELAY" VALUE = "26">

<COMMENT>
<script type="text/javascript" language="javascript">
if ( isWin98 && isFirefox ) { // Must use cookie dissabled
version.
document.write(""
+"<EMBED"
+" type = \"application/x-java-applet;version=1.4\" \\"
+" CODE = \"StandingsTicker.class\" \\"
+" JAVA_CODEBASE = \"http://www.freesimracing.com/\" \\"
+" ARCHIVE =
\"garry/standingsTicker/StandingsTickerNoCookies.jar\" \\"
+" WIDTH = \"750\" \\"
+" HEIGHT = \"26\" \\"
+" DELAY = \"26\" \\"
+" MAYSCRIPT = true \\"
+" scriptable = false \\"
+" pluginspage =
\"http://java.sun.com/products/plugin/index.html#download\">"
+" <NOEMBED>"
+" </NOEMBED>"
+"</EMBED>");
}
else { // It must be Netscape so use cookie enabled version.
document.write(""
+"<EMBED"
+" type = \"application/x-java-applet;version=1.4\" \\"
+" CODE = \"StandingsTicker.class\" \\"
+" JAVA_CODEBASE = \"http://www.freesimracing.com/\" \\"
+" ARCHIVE = \"garry/standingsTicker/StandingsTicker.jar\"
\\"
+" WIDTH = \"750\" \\"
+" HEIGHT = \"26\" \\"
+" DELAY = \"26\" \\"
+" MAYSCRIPT = true \\"
+" scriptable = false \\"
+" pluginspage =
\"http://java.sun.com/products/plugin/index.html#download\">"
+" <NOEMBED>"
+" </NOEMBED>"
+"</EMBED>");
}
</script>
</COMMENT>
</OBJECT>
 
H

Heath Raftery

Heath Raftery wrote:
...

Applet placement in web pages is a mess.
Appreciate the confirmation!
Use the applet tag unless you require versioning, and if so,
consider using a n applet launched by WebStart (which can do
the versioning) or converting the applet to an application.

Both alternatives are unapplicable - my applet is served through another
site as part of a customised profile page. Falling back to the APPLET
tag and dealing with the versioning issues in another way seems to be
my best bet.
That's just idiotic. Can you name any single *technical*
reason why the nested elements would be better for your applet?
If not, use the <APPLET> element, declare your HTML as 3.2
and be done with it.
Forward compatibility for one. If APPLET is deprecated then by
definition support may disappear at any time. Declaring as 3.2 is not
appropriate because other parts of the site (not under my control)
would not be served well at all by being similarly constrained.

Access to modern technology for two. The APPLET tag is a little...
underpowered, don't you think? Versioning is one good example.

Avoiding the <br> <br /> (for example) confusion for three. I think
there are plenty of technical reasons why supporting the latest
standards is a good idea.


Thank you everyone for your replies. They certainly clear up my
queries, and in a rather entertaining way actually. While I'm not
a Windows guy and thus have not run HtmlConverter.exe, I did run
the equivalent for my OS and as described, it spat out a pile of
poo. Inserting my PHP amongst its output and otherwise maintaining
the code during development would prove to be quite a nightmare.

Regards,
Heath
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top