[ Team LiB ] Previous Section Next Section

Recipe 17.4 Writing HTML Template to Embed a Flash File

Problem

You want to write the HTML template text to embed a Flash file in your JSP.

Solution

Use the object and embed tags so that the HTML is read correctly by the browsers that support either of these tags.

Discussion

You may not have the Macromedia Flash application that can automatically generate the HTML which is necessary to embed a Flash file (Recipe 17.4). In this case, write the required HTML template text for embedding a Flash movie inside a JSP.

Example 17-6 shows a JSP with an embedded Flash file (the embedded file has a .swf extension). The same concept applies to this example as to the other recipes: the object tag is for the Internet Explorer Windows browser, which embeds the media file as an ActiveX control, not a Netscape-style plug-in. The embed tag, nested inside the object tag, is designed to embed the Flash file in Netscape and other browsers that support Netscape-style plug-ins.

Example 17-6 is derived from a technical note at http://www.macromedia.com/support/flash/technotes.html.

Example 17-6. A JSP contains an embedded file
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<jsp:useBean id="date" class="java.util.Date" />

<html>
<head><title>Flash in a JSP</title></head>
<body>
<h2>Enjoy the Flash Movie</h2>

<OBJECT CLASSID=
    "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE=
    "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#
     version=6,040,0" width="293" height="423"
>

<PARAM name="movie" VALUE="coolFlashMov.swf">

<PARAM name="quality" VALUE="high">

<PARAM name="bgcolor" VALUE="#FFFFFF">

<EMBED SRC=
   "coolFlashMov.swf" quality="high" width="293" height="423" 
   bgcolor="#FFFFFF" type="application/x-shockwave-flash" PLUGINSPAGE=
   "http://www.macromedia.com/go/getflashplayer"
>

</EMBED>

</OBJECT>

<br /><c:out value="${date}"/>

</body>
</html>

Both the embed and object tags are designed to prompt the end user to download the required version of the Flash plug-in or ActiveX control if they do not already have it installed.

See Also

Macromedia technical notes page: http://www.macromedia.com/support/flash/technotes.html; an article about alternative techniques to using the embed tag: http://www.macromedia.com/devnet/mx/dreamweaver/articles/flash_satay.html.

    [ Team LiB ] Previous Section Next Section