JSP STANDARD ACTION jsp:plugin

Jsp:plugin 

1.    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).
2.     The <jsp:params> element sends parameter names and values to an applet or Bean at startup.
3.     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" 
          code="classFileName" 
          codebase="classFileDirectoryName"
</jsp:plugin>

Attributes:
1.    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.

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

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

4.     name="instanceName"
A name for the Bean or applet instance, which makes it possible for applets or Beans called by the same JSP file to communicate with each other.

Example:
pluginstandardaction.jsp
<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">
<jsp:fallback>
Plugin tag not supported by browser.
</jsp:fallback>
</jsp:plugin>
<h4><font color=red>
The above applet is loaded using the Java Plugin from a jsp page using the
plugin tag.
</font>
</h4>
</body>
</html>

Pluginexample.java (Applet)
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 = Color.red;
// lesser known colors can be made with R(ed)G(reen)B(lue).
weirdColor = new Color(60,60,122);
bgColor = Color.blue;
// this will set the backgroundcolor of the applet
setBackground(bgColor);
}
public void stop()
{

}
// now lets draw things on screen
public void paint(Graphics g)
{
// tell g to use your font
g.setFont(bigFont);
g.drawString("PLUGIN example",80,20);
// Now we tell g to change the color
g.setColor(redColor);
// This will draw a rectangle (xco,yco,xwidth,height);
g.drawRect(100,100,100,100);
// This will fill a rectangle
g.fillRect(110,110,80,80);
// change colors again
g.setColor(weirdColor);
// a circle (int x, int y, int width, int height,int startAngle, int arcAngle);
// ovals are also possible this way.
g.fillArc(120,120,60,60,0,360);
g.setColor(Color.yellow);
// Draw a line (int x1, int y1, int x2, int y2)
g.drawLine(140,140,160,160);
// 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:


Thanks For Making This Possible! Kindly Bookmark and Share it.

Technorati Digg This Stumble Stumble Facebook Twitter

No comments:

Post a Comment