jsp:plugin Tag

The <jsp:plugin> tag enables a JSP page author to generate HTML that contains the appropriate client browser dependent constructs (OBJECT or EMBED), which will result in the download of the Java Plugin software (if required) and subsequent execution of the specified applet or JavaBeans component.

In the rendered JSP, the <jsp:plugin> tag is replaced by either an <object> or <embed> tag, as appropriate for the requesting user agent, and emitted into the output stream of the response. The attributes of the <jsp:plugin> tag provide configuration data for the presentation of the tag.

The <jsp:params> tag indicate the parameters to the applet or JavaBeans component.

The <jsp:fallback> tag indicates the content to be used by the client browser if the plugin cannot be started, either because OBJECT or EMBED is not supported by the client browser, or due to some other problem. If the plugin can
start but the applet or JavaBeans component cannot be found or started, a plugin specific message is presented to the user. Usually the message is in a popup window reporting a ClassNotFoundException.

You are not required to bundle the actual plugin code with the JSP container. You may use a reference to the plugin location.

For more information, see the JavaServer Pages (JSP) v1.2 Syntax Reference on the Sun Microsystems® web site.  

Syntax

<jsp:plugin
   type="bean|applet"
   code="classFileName"
   codebase="classFileDirectoryName"
   [ name="instanceName" ]
   [ archive="URIToArchive, ..." ]
   [ align="bottom|top|middle|left|right" ]
   [ height="{displayPixels | <%= expression %>}"]
   [ width="{displayPixels | <%= expression %>}"]
   [ hspace="leftRightPixels" ]
   [ vspace="topBottomPixels" ]
   [ jreversion="JREVersionNumber | 1.2" ]
   [ nspluginurl="URLToPlugin" ]
   [ iepluginurl="URLToPlugin" ] >
   [ <jsp:params>
      [ <jsp:param name="parameterName"
      value="{parameterValue | <%= expression %>}" /> ]+
   </jsp:params> ]
   [ <jsp:fallback> text message for user </jsp:fallback> ]
</jsp:plugin>

Attributes

type="bean | applet"

The type of object the plug-in will execute. You must specify either bean or applet, as this attribute has no default value.

code="classFileName"

The name of the Java class file the plug-in will execute. You must include the .class extension in the name. The class file you specify should be in the directory named in the codebase attribute.

codebase="classFileDirectoryName"

The directory (or path to the directory) that contains the Java class file the plug-in will execute. If you do not supply a value, the path of the JSP page that calls <jsp:plugin> is used.

name="instanceName"

A name for the instance of the bean or applet, which makes it possible for applets or Beans called by the same JSP page to communicate with each other.

archive="URIToArchive, ..."

A comma-separated list of pathnames that locate archive files that will be preloaded with a class loader located in the directory named in codebase. The archive files are loaded securely, often over a network, and typically improve the applet's performance.

align="bottom | top | middle | left | right"

The position of the image, object, or applet. The position descriptions listed below use the term text line to mean the line in the viewable JSP page that corresponds to the line in the JSP page where the <jsp:plugin> tag appears. The allowed values for align are as follows:

bottom: Aligns the bottom of the image with the baseline of the text line.

top: Aligns the top of the image with the top of the text line.

middle: Aligns the vertical center of the image with the baseline of the text line.

left: Floats the image to the left margin and flows text along the image's right side.

right: Floats the image to the right margin and flows text along the image's left side.

height="{displayPixels | <%= expression %>}"
width="{displayPixels | <%= expression %>}"

The initial height and width, in pixels, of the image the applet or bean displays, not counting any windows or dialog boxes the applet or bean brings up.

hspace="leftRightPixels"
vspace="topBottomPixels"

The amount of space, in pixels, to the left and right (or top and bottom) of the image the applet or bean displays. The value must be a nonzero number. Note that hspace creates space to both the left and right and vspace creates space to both the top and bottom.

jreversion="JREVersionNumber | 1.2"

The version of the Java Runtime Environment (JRE) the applet or bean requires. The default value is 1.2.

nspluginurl="URLToPlugin"

The URL where the user can download the JRE plug-in for Netscape Navigator. The value is a full URL, with a protocol name, optional port number, and domain name.

iepluginurl="URLToPlugin"

The URL where the user can download the JRE plug-in for Internet Explorer. The value is a full URL, with a protocol name, optional port number, and domain name.

<jsp:params>
     [ <jsp:param name="parameterName"
          value="{parameterValue | <%= expression %>}" /> ]
</jsp:params>

The parameters and values that you want to pass to the applet or bean. To specify more than one parameter value, you can use more than one <jsp:param> tag within the <jsp:params> tag. The name attribute specifies the parameter name and takes a case-sensitive literal string. The value attribute specifies the parameter value and takes either a case-sensitive literal string or an expression that is evaluated at runtime. If the dynamic resource you are passing the parameter to is an applet, it reads the parameter with the java.applet.Applet.getParameter method.

<jsp:fallback> { Text message for user } </jsp:fallback>

A text message to display for the user if the plug-in cannot be started. If the plug-in starts but the applet or bean does not, the plug-in usually displays a popup window explaining the error to the user.

Example

<jsp:plugin type=applet code=”Molecule.class” codebase=”/html” >
  <jsp:params>
    <jsp:param name=”molecule” value=”molecules/benzene.mol”/>
  </jsp:params>
  <jsp:fallback>
    <p> Unable to start plugin </p>
  </jsp:fallback>
</jsp:plugin>

Related Topics

jsp:fallback Tag

jsp:forward Tag

jsp:getProperty Tag

jsp:include Tag

jsp:param Tag

jsp:params Tag

jsp:setProperty Tag

jsp:useBean Tag

JSP Tag Reference for Page Flows