O'Reilly logo

Java Servlet & JSP Cookbook by Bruce W. Perry

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required