📄 jspintro12.html
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <title>Including an Applet</title> <link rel="StyleSheet" href="document.css" type="text/css" media="all" /> <link rel="StyleSheet" href="catalog.css" type="text/css" media="all" /> <link rel="Table of Contents" href="J2EETutorialTOC.html" /> <link rel="Previous" href="JSPIntro11.html" /> <link rel="Next" href="JSPIntro13.html" /> <link rel="Index" href="J2EETutorialIX.html" /> </head> <body> <table width="550" summary="layout" id="SummaryNotReq1"> <tr> <td align="left" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a> </td> <td align="center" valign="center"><a accesskey="p" href="JSPIntro11.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="JSPIntro13.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a> </td> <td align="right" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font> </font> </td> </tr> </table> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"> <blockquote><a name="wp66270"> </a><h2 class="pHeading1">Including an Applet</h2><a name="wp66272"> </a><p class="pBody">You can include an applet or JavaBeans component in a JSP page by using the <code class="cCode">jsp:plugin</code> element. This element generates HTML that contains the appropriate client-browser-dependent constructs (<code class="cCode"><object></code> or <code class="cCode"><embed></code>) that will result in the download of the Java Plug-in software (if required) and client-side component and subsequent execution of any client-side component. The syntax for the <code class="cCode">jsp:plugin</code> element is as follows:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative"><jsp:plugin type="bean|applet" code="<code class="cVariable">objectCode</code>" codebase="<code class="cVariable">objectCodebase</code>" { align="<code class="cVariable">alignment</code>" } { archive="<code class="cVariable">archiveList</code>" } { height="<code class="cVariable">height</code>" } { hspace="<code class="cVariable">hspace</code>" } { jreversion="<code class="cVariable">jreversion</code>" } { name="<code class="cVariable">componentName</code>" } { vspace="<code class="cVariable">vspace</code>" } { width="<code class="cVariable">width</code>" } { nspluginurl="<code class="cVariable">url</code>" } { iepluginurl="<code class="cVariable">url</code>" } > { <jsp:params> { <jsp:param name="<code class="cVariable">paramName</code>" value= <code class="cVariable">paramValue</code>" /> }+ </jsp:params> } { <jsp:fallback> <code class="cVariable">arbitrary_text</code> </jsp:fallback> } </jsp:plugin><a name="wp66274"> </a></pre></div><a name="wp66275"> </a><p class="pBody">The <code class="cCode">jsp:plugin</code> tag is replaced by either an <code class="cCode"><object></code> or <code class="cCode"><embed></code> tag as appropriate for the requesting client. The attributes of the <code class="cCode">jsp:plugin</code> tag provide configuration data for the presentation of the element as well as the version of the plug-in required. The <code class="cCode">nspluginurl</code> and <code class="cCode">iepluginurl</code> attributes override the default URL where the plug-in can be downloaded.</p><a name="wp66277"> </a><p class="pBody">The <code class="cCode">jsp:params</code> element specifies parameters to the applet or JavaBeans component. The <code class="cCode">jsp:fallback</code> element indicates the content to be used by the client browser if the plug-in cannot be started (either because <code class="cCode"><object></code> or <code class="cCode"><embed></code> is not supported by the client or because of some other problem). </p><a name="wp66279"> </a><p class="pBody">If the plug-in can start but the applet or JavaBeans component cannot be found or started, a plug-in-specific message will be presented to the user, most likely a pop-up window reporting a <code class="cCode">ClassNotFoundException</code>.</p><a name="wp66281"> </a><p class="pBody">The Duke's Bookstore page <code class="cCode"><a href="../examples/web/bookstore2/web/template/prelude.txt" target="_blank">/template/prelude.jspf</a></code> creates the banner that displays a dynamic digital clock generated by <code class="cCode">DigitalClock</code>:</p><a name="wp66285"> </a><p class="pBody"></p><div align="left"><img src="images/Fig293.gif" height="375" width="399" alt="Duke's Bookstore with Applet" border="0" hspace="0" vspace="0"/></div><p class="pBody"></p><p> <a name="66286"> </a><strong><font >Figure 12-3 Duke's Bookstore with Applet</font></strong></p><a name="wp66287"> </a><p class="pBody">The <code class="cCode">jsp:plugin</code> element used to download the applet follows:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative"><jsp:plugin type="applet" code="DigitalClock.class" codebase="/bookstore2" jreversion="1.4" align="center" height="25" width="300" nspluginurl="http://java.sun.com/j2se/1.4.2/download.html" iepluginurl="http://java.sun.com/j2se/1.4.2/download.html" > <jsp:params> <jsp:param name="language" value="${pageContext.request.locale.language}" /> <jsp:param name="country" value="${pageContext.request.locale.country}" /> <jsp:param name="bgcolor" value="FFFFFF" /> <jsp:param name="fgcolor" value="CC0066" /> </jsp:params> <jsp:fallback> <p>Unable to start plugin.</p> </jsp:fallback></jsp:plugin><a name="wp66288"> </a></pre></div> </blockquote> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"> <table width="550" summary="layout" id="SummaryNotReq1"> <tr> <td align="left" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a> </td> <td align="center" valign="center"><a accesskey="p" href="JSPIntro11.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="JSPIntro13.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a> </td> <td align="right" valign="center"> <font size="-1"> <a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a> <br> <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font> </font> </td> </tr> </table> <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider"><p><font size="-1">All of the material in <em>The J2EE(TM) 1.4 Tutorial</em> is <a href="J2EETutorialFront2.html">copyright</a>-protected and may not be published in other workswithout express written permission from Sun Microsystems.</font> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -