Including an Applet - The Java EE 5 Tutorial (original) (raw)
2. Using the Tutorial Examples
3. Getting Started with Web Applications
5. JavaServer Pages Technology
Using Objects within JSP Pages
Using Application-Specific Objects
Immediate and Deferred Evaluation Syntax
Deactivating Expression Evaluation
Process of Expression Evaluation
JavaBeans Component Design Conventions
Creating and Using a JavaBeans Component
Setting JavaBeans Component Properties
Retrieving JavaBeans Component Properties
Including the Tag Library Implementation
Transferring Control to Another Web Component
Including an Applet
Setting Properties for Groups of JSP Pages
Deactivating EL Expression Evaluation
Further Information about JavaServer Pages Technology
7. JavaServer Pages Standard Tag Library
10. JavaServer Faces Technology
11. Using JavaServer Faces Technology in JSP Pages
12. Developing with JavaServer Faces Technology
13. Creating Custom UI Components
14. Configuring JavaServer Faces Applications
15. Internationalizing and Localizing Web Applications
16. Building Web Services with JAX-WS
17. Binding between XML Schema and Java Classes
19. SOAP with Attachments API for Java
21. Getting Started with Enterprise Beans
23. A Message-Driven Bean Example
24. Introduction to the Java Persistence API
25. Persistence in the Web Tier
26. Persistence in the EJB Tier
27. The Java Persistence Query Language
28. Introduction to Security in the Java EE Platform
29. Securing Java EE Applications
31. The Java Message Service API
32. Java EE Examples Using the JMS API
36. The Coffee Break Application
37. The Duke's Bank Application
![]() |
---|
Home | Download | PDF | FAQ | Feedback
Including an Applet
You can include an applet or a JavaBeans component in a JSP page by using the jsp:plugin element. This element generates HTML that contains the appropriate client-browser-dependent construct ( or ) that will result in the download of the Java Plug-in software (if required) and the client-side component, and in the subsequent execution of any client-side component. The syntax for the jsp:plugin element is as follows:
<jsp:plugin type="bean|applet" code="_objectCode_" codebase="_objectCodebase_" { align="_alignment_" } { archive="_archiveList_" } { height="_height_" } { hspace="_hspace_" } { jreversion="_jreversion_" } { name="_componentName_" } { vspace="_vspace_" } { width="_width_" } { nspluginurl="_url_" } { iepluginurl="_url_" } > { jsp:params { <jsp:param name="_paramName_" value= _paramValue_" /> }+ } { jsp:fallback arbitrary-text }
The jsp:plugin tag is replaced by either an or an tag as appropriate for the requesting client. The attributes of the jsp:plugin tag provide configuration data for the presentation of the element as well as the version of the plug-in required. The nspluginurl and iepluginurl attributes override the default URL where the plug-in can be downloaded.
The jsp:params element specifies parameters to the applet or JavaBeans component. The jsp:fallbackelement indicates the content to be used by the client browser if the plug-in cannot be started (either because or is not supported by the client or because of some other problem).
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 ClassNotFoundException.
The Duke’s Bookstore page /template/prelude.jspf creates the banner that displays a dynamic digital clock generated by DigitalClock (see Figure 5-3).
Figure 5-3 Duke’s Bookstore with Applet
Here is the jsp:plugin element that is used to download the applet:
<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:fallback
Unable to start plugin.
Copyright © 2010, Oracle and/or its affiliates. All rights reserved. Legal Notices