aspose file tools*
The moose likes Applets and the fly likes embedding applets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "embedding applets" Watch "embedding applets" New topic
Author

embedding applets

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Hi there,

I'm trying to embed an applet into a JSP page. My source code for the JSP page looks like this:

NOTE: I had to replace the ':' character with the actual word "colon" in order to prevent these dumb smiley faces from appearing!

<jsp colon plugin type="applet" code="mvcs.TableForm.class" codebase="." width="400" height="300">
<jsp colon params>
<jsp colon param name="action" value="<%=AppletAction%>" />
<jsp colon param name="redirect" value="<%=AppletRedirect%>" />
<jsp colon param name="CompanyID" value="<%=companyID%>" />
<jsp colon param name="AdministratorID" value="" />
<jsp colon param name="RecordLimit" value="40" />
<jsp colon param name="OnErrorPage" value="<%=AppletError%>" />
</jsp colon params>
<jsp colon fallback>
<B>Error: Unable to load Applet.<br>This page requires the Java Virtual Machine version 1.5 or greater to run.
</jsp colon fallback>
</jsp colon plugin>

When I load the page into Internet Explorer the applet loads just fine. Different story with Netscape though. It won't load in Netscape. When I look at the source page after attempting to load the applet in Netscape it looks like this:

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="400" height="300" codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0">
<PARAM name="java_code" value="mvcs.TableForm.class">
<PARAM name="java_codebase" value=".">

<PARAM name="type" value="application/x-java-applet;">
<PARAM name="action" value="http://localhost:8080/scholastic/AddStudentTableData">
<PARAM name="redirect" value="http://localhost:8080/scholastic/admin/SuccessfulTransaction.jsp">
<PARAM name="CompanyID" value="4">
<PARAM name="AdministratorID" value="">
<PARAM name="RecordLimit" value="40">
<PARAM name="OnErrorPage" value="http://localhost:8080/scholastic/admin/AdminMainMenu.jsp">
<COMMENT>
<EMBED type="application/x-java-applet;" width="400" height="300" pluginspage="http://java.sun.com/products/plugin/" java_code="mvcs.TableForm.class" java_codebase="." action="http://localhost:8080/scholastic/AddStudentTableData" redirect="http://localhost:8080/scholastic/admin/SuccessfulTransaction.jsp" CompanyID="4" AdministratorID="" RecordLimit="40" OnErrorPage="http://localhost:8080/scholastic/admin/AdminMainMenu.jsp"/>
<NOEMBED>

<B>Error: Unable to load Applet.<br>This page requires the Java Virtual Machine version 1.5 or greater to run.

</NOEMBED>
</COMMENT>
</OBJECT>

I compared this with the source in IE and they're the same. Has anyone had this same type of difficulty? For the heck of it, to prove there was nothing wrong with the applet itself, I created a test html page that simply used the <applet></applet> tags:

<applet code="mvcs.TableForm.class" width="400" height="300">
<PARAM name="action" value="http://localhost:8080/scholastic/AddStudentTableData">
<PARAM name="redirect" value="http://localhost:8080/scholastic/admin/SuccessfulTransaction.jsp">
<PARAM name="CompanyID" value="4">
<PARAM name="AdministratorID" value="">
<PARAM name="RecordLimit" value="40">
<PARAM name="OnErrorPage" value="http://localhost:8080/scholastic/admin/AdminMainMenu.jsp">

</applet>

Netscape didn't have a problem with this and loaded the applet fine. So what's wrong with the other code that uses the OBJECT and EMBED tags?

Alan
[ October 26, 2005: Message edited by: Alan Shiers ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

Since the issue is with browser interpretation of the same generated HTML, this is clearly not a problem with your JSP code. So I'm moving this off to the Applets forum where the applet-savvy hang out.

P.S. If you click the 'disable smilies' button when posting code, your tags will look a little less disrespectful.

P.P.S. It might be helpful to point out what versions of the browsers that you are using.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41874
    
  63
I never got the hang of the OBJECT and EMBED tags. If APPLET works, why not just use that? My impression is that it works more widely than the other ones, and that the jsp:plugin tag is a relict of times past.


Ping & DNS - my free Android networking tools app
Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 237
Well, I found the problem! I'm wondering if I should report this as a bug to SUN Microsystems? All it was, was a syntax error generated by:

<jsp:params>
<jsp:param name="action" value="<%=AppletAction%>" />
<jsp:param name="redirect" value="<%=AppletRedirect%>" />
<jsp:param name="CompanyID" value="<%=companyID%>" />
<jsp:param name="AdministratorID" value="" />
<jsp:param name="RecordLimit" value="40" />
<jsp:param name="OnErrorPage" value="<%=AppletError%>" />
</jsp:params>
<jsp:fallback>
<B>Error: Unable to load Applet.<br>This page requires the Java Virtual Machine version 1.5 or greater to run.
</jsp:fallback>
</jsp:plugin>

That code creates the following code for the client side:

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="400" height="300" codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0">
<PARAM name="java_code" value="mvcs.TableForm.class">
<PARAM name="java_codebase" value=".">

<PARAM name="type" value="application/x-java-applet;">
<PARAM name="action" value="http://localhost:8080/scholastic/AddStudentTableData">
<PARAM name="redirect" value="http://localhost:8080/scholastic/admin/SuccessfulTransaction.jsp">
<PARAM name="CompanyID" value="4">
<PARAM name="AdministratorID" value="">
<PARAM name="RecordLimit" value="40">
<PARAM name="OnErrorPage" value="http://localhost:8080/scholastic/admin/AdminMainMenu.jsp">
<COMMENT>
<EMBED type="application/x-java-applet;" width="400" height="300" pluginspage="http://java.sun.com/products/plugin/" java_code="mvcs.TableForm.class" java_codebase="." action="http://localhost:8080/scholastic/AddStudentTableData" redirect="http://localhost:8080/scholastic/admin/SuccessfulTransaction.jsp" CompanyID="4" AdministratorID="" RecordLimit="40" OnErrorPage="http://localhost:8080/scholastic/admin/AdminMainMenu.jsp"/>
<NOEMBED>

<B>Error: Unable to load Applet.<br>This page requires the Java Virtual Machine version 1.5 or greater to run.

</NOEMBED>
</COMMENT>
</OBJECT>

There's a lot going on there, but basically Netscape only cares what is inside the <EMBED> tag. The rest is for IE to decipher. The line that contains the bug is: type="application/x-java-applet;". IE doesn't seem to mind this little string but Netscape does! The problem with it is the semi-colon! Netscape doesn't like it! I removed it out of desperation after trying numerous things, then WHALAA!!! The applet loaded!

I'm feeling kinda proud now! Maybe I will report this as a bug. Don't come across too many of them.

Alan

[ October 26, 2005: Message edited by: Alan Shiers ]
[ October 26, 2005: Message edited by: Alan Shiers ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: embedding applets