Share on Google+Share on Google+

Standard Action "jsp:plugin"

In this Section, we will discuss about standard action "jsp:plugin" & their implementation using a example.

Standard Action <jsp:plugin>

In this Section, we will discuss about standard action "jsp:plugin" & their implementation using a example.

The <jsp:plugin> action is use to download a plugin (an Applet or a Bean) to the client Web browser to execute it. The <jsp:plugin> tag is replaced by either an <object> or <embed> tag, whichever is most appropriate for the client Web browser (the <object> tag is for browsers that use HTML 4.0). The <jsp:params> element sends parameter names and values to an applet or Bean at startup. The <jsp:fallback> element provides a message for the user if the plugin does not start. If the plugin starts but the applet or Bean does not, the plugin usually displays a popup window explaining the error to the user.

Syntax :

<jsp:plugin type="bean|applet"
            [ height="
displayPixels" ]
            [ width="
displayPixels" ] [ <jsp:params>
            [ <jsp:params>
parameterName" value="parameterValue" /> ]+
            </jsp:params> ]
            [ <jsp:fallback>
text message for user </jsp:fallback> ]

Description :

  • type="bean|applet"

    The type of object the plugin 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 that the plugin will execute. You must include the .class extension in the name following code. The filename is relative to the directory named in the codebase attribute.

  • codebase="classFileDirectoryName"

    The absolute or relative path to the directory that contains the applet's code. If you do not supply a value, the path of the JSP file that calls <jsp:plugin> is used.

  • height="displayPixels" width="displayPixels"

    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.

  • <jsp:params> [ <jsp:param name="parameterName" value="parameterValue" /> ]+ </jsp:params>

    The parameters and values that you want to pass to the applet or Bean. To specify more than one name and value, use multiple <jsp:param> tags within the <jsp:params> element. Applets read parameters 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 plugin cannot be started.


    In this example, we are going to insert the "" Applet into the "Pluginstandardaction.jsp" file using '<jsp:plugin>' standard action.


  • <html>

    <title> Plugin example </title>

    <body bgcolor="white">

    <h3> The given below applet is imported to this file : </h3>

    <jsp:plugin type="applet" code="Pluginexample.class" codebase="applet"

     height="300" width="300">


    Plugin tag not supported by browser.



    <h4><font color=red>

    The above applet is loaded using the Java Plugin from a jsp page using the

    plugin tag.






    import java.awt.*;

    import java.applet.*;

    public class Pluginexample extends Applet


    // Specify variables that will be needed everywhere, anytime here

    // The font variable

    Font bigFont;

    // The colors you will use

    Color redColor;

    Color weirdColor;

    Color bgColor;

    public void init()


    // Here we will define the varibles further

    // Will use Arial as type, 16 as size and bold as style

    // Italic and Plain are also available

    bigFont = new Font("Arial",Font.BOLD,16);

    // Standard colors can be named like this

    redColor =;

    // lesser known colors can be made with R(ed)G(reen)B(lue).

    weirdColor = new Color(60,60,122);

    bgColor =;

    // this will set the backgroundcolor of the applet



    public void stop()



    // now lets draw things on screen

    public void paint(Graphics g)


    // tell g to use your font


    g.drawString("PLUGIN example",80,20);

    // Now we tell g to change the color


    // This will draw a rectangle (xco,yco,xwidth,height);


    // This will fill a rectangle


    // change colors again


    // a circle (int x, int y, int width, int height,int startAngle, int arcAngle);

    // ovals are also possible this way.



    // Draw a line (int x1, int y1, int x2, int y2)


    // reset the color to the standard color for the next time the applets paints

    // an applet is repainted when a part was'nt visible anymore

    // happens most often because of browser minimizing or scrolling.

    g.setColor(Color. black);}


    OUTPUT :




    Posted on: June 19, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

    Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


    Advertisement null