You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by qingtao peng <qi...@yahoo.com.cn> on 2013/01/29 13:45:49 UTC

html page can not present an java Applet embedded in the page

  I have built the apache-tomcat-7.0.32 server on my computer.My operating system is Windows7.I place a html page named DbApplet.html under the directory of DbServlet in the webapps of the apache-tomcat-7.0.32 server .My DbApplet.htm code is as follow :
<html>
     <head>
     </head>
     <body>
          <center>
                     <object  codebase="http://localhost:8080/DbServlet/build/classes/servlet/" classid = "DbApplet.class"  width = "600" height = "600" name = "DbApplet">
                     </object>
          </center>
     </body> 
</html>
I have started the apache-tomcat-7.0.32 server.Then i type http://localhost:8080/DbServlet/DbApplet.html in the field of the address on the browser.I can open the page on the browser,but the html page can not present the java Applet embedded in the page.I have encoded the java Applet and compiled it into the class named DbApplet.class.I
place it under  the directory of DbServlet/build/classes/servlet in the directory of the webapps of the apache-tomcat-7.0.32 server .Why can the page not present my java Applet.
        I thank you for helping

Re: html page can not present an java Applet embedded in the page

Posted by André Warnier <aw...@ice-sa.com>.
qingtao peng wrote:
>   I have built the apache-tomcat-7.0.32 server on my computer.My operating system is Windows7.I place a html page named DbApplet.html under the directory of DbServlet in the webapps of the apache-tomcat-7.0.32 server .My DbApplet.htm code is as follow :
> <html>
>      <head>
>      </head>
>      <body>
>           <center>
>                      <object  codebase="http://localhost:8080/DbServlet/build/classes/servlet/" classid = "DbApplet.class"  width = "600" height = "600" name = "DbApplet">
>                      </object>
>           </center>
>      </body> 
> </html>
> I have started the apache-tomcat-7.0.32 server.Then i type http://localhost:8080/DbServlet/DbApplet.html in the field of the address on the browser.I can open the page on the browser,but the html page can not present the java Applet embedded in the page.I have encoded the java Applet and compiled it into the class named DbApplet.class.I
> place it under  the directory of DbServlet/build/classes/servlet in the directory of the webapps of the apache-tomcat-7.0.32 server .Why can the page not present my java Applet.
>         I thank you for helping

You may want to open the Java error console on your workstation, and look at any messages 
shown there.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: html page can not present an java Applet embedded in the page

Posted by Konstantin Preißer <ve...@t-online.de>.
Hi,

> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Sent: Tuesday, January 29, 2013 6:38 PM
> To: Tomcat Users List
> Subject: Re: html page can not present an java Applet embedded in the
> page
> 
> Also, Oracle says this only works with Microsoft Internet Explorer. An
> online HOW-TO[2] (a bit dated) says that you can still use <object> in
> other browsers, but the syntax is a little different:
> 
> <object classid="java:fully/qualified/class/name.class"
>               type="application/x-java-applet">
>   <param name="code" value="fully/qualified/class/name.class" />
> [...]
> </object>
> 
> I'm not sure why you have to specify the class name twice in there.
> That page also shows you how to embed Java applets in such a way that
> they will work in both MSIE and everywhere else. Oracle has similar
> documentation in their page I referenced, though using a different
> technique. You'll have to test in your target environment to see what
> actually works for you.


I don't know why Oracle says that you need different syntaxes for IE and other browsers (that probably applied to old versions of the HTML spec and browsers), since e.g. the following syntax works for me with IE, Firefox and Chrome (which is also given as a example in the current HTML5 spec [1]):

  <object type="application/x-java-applet">
    <param name="code" value="mypackage.MyClass" />
    <param name="archive" value="MyJarFile.jar" />
    <param name="java_arguments" value="-Dsun.java2d.d3d=false" />

    Your don't have the Java plugin installed...
  </object>


However, I would recommend the <embed> element because it allows Browsers to display a specific error message when the Java plugin is not installed:

  <embed type="application/x-java-applet" code="mypackage.MyClass" archive="MyJarFile.jar" java_arguments="-Dsun.java2d.d3d=false" />


Regards,
Konstantin Preißer


[1] http://www.w3.org/TR/html51/embedded-content-0.html#the-object-element


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: html page can not present an java Applet embedded in the page

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Gingtao,

On 1/29/13 7:45 AM, qingtao peng wrote:
> I have built the apache-tomcat-7.0.32 server on my computer.My 
> operating system is Windows7.I place a html page named
> DbApplet.html under the directory of DbServlet in the webapps of
> the apache-tomcat-7.0.32 server .My DbApplet.htm code is as follow
> :
> 
> <html> <head> </head> <body> <center> <object
> codebase="http://localhost:8080/DbServlet/build/classes/servlet/"
> classid = "DbApplet.class"  width = "600" height = "600" name =
> "DbApplet"> </object> </center> </body> </html>
> 
> I have started the apache-tomcat-7.0.32 server.Then i type 
> http://localhost:8080/DbServlet/DbApplet.html in the field of the 
> address on the browser.I can open the page on the browser,but the 
> html page can not present the java Applet embedded in the page.I
> have encoded the java Applet and compiled it into the class named 
> DbApplet.class.I place it under  the directory of 
> DbServlet/build/classes/servlet in the directory of the webapps of 
> the apache-tomcat-7.0.32 server .Why can the page not present my
> java Applet.

The available online documentation is a bit murky these days. Oracle's
own documentation[1] does not explain how to tell the browser where
your code is (e.g. in a JAR file on the server). I suspect it should
be done this way:

<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93">
  <param name="codebase"
value="http://localhost:8080/DbServlet/build/classes/servlet/" />
  <param name="code" value="DbApplet.class" />
</object>

You should ensure that the URL
http://localhost:8080/DbServlet/build/classes/servlet/DbApplet.class
actually returns something. If Tomcat refuses to serve that request,
you'll get nothing.

Also, Oracle says this only works with Microsoft Internet Explorer. An
online HOW-TO[2] (a bit dated) says that you can still use <object> in
other browsers, but the syntax is a little different:

<object classid="java:fully/qualified/class/name.class"
              type="application/x-java-applet">
  <param name="code" value="fully/qualified/class/name.class" />
[...]
</object>

I'm not sure why you have to specify the class name twice in there.
That page also shows you how to embed Java applets in such a way that
they will work in both MSIE and everywhere else. Oracle has similar
documentation in their page I referenced, though using a different
technique. You'll have to test in your target environment to see what
actually works for you.

Good luck,
- -chris

[1]
http://download.java.net/jdk8/docs/technotes/guides/jweb/applet/using_tags.html
[2]
http://depth-first.com/articles/2008/02/20/demystifying-java-applets-part-1-cross-browser-standards-compliant-pure-html-deployment-using-the-object-tag/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlEICO0ACgkQ9CaO5/Lv0PAa3gCcD0QN+PjtpI5gWBulGW0A2kJu
5VAAoJJ1E/7o356crfZw5h3eAS6BZTw3
=Rftp
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org