How to Include Applet Program in a JSP Page:
1.Create a Applet Java Program
sample.java
import javax.swing.JApplet; import java.awt.*; import java.awt.event.*; import java.applet.*; public class sample extends Applet { sampleCanvas canvas; // The drawing area to display arcs public static String s=null; public void init() { setLayout(new BorderLayout()); canvas = new sampleCanvas(); add("Center", canvas); s=this.getParameter("data"); } public void destroy() { remove(canvas); } public void start() { } public void stop() { } public void processEvent(AWTEvent e) { if (e.getID() == Event.WINDOW_DESTROY) { System.exit(0); } } } class sampleCanvas extends Canvas { font = new java.awt.Font("SansSerif", Font.PLAIN, 12); public void paint(Graphics g) { Rectangle r = getBounds(); if(sample.s==null) sample.s="0"; int a = Integer.parseInt(sample.s); a=(a*600)/1000; g.fillRect(10, 200,a, 25); } public void redraw(int value) { this.filled = filled; this.startAngle = value; repaint(); } }
2.Complie the Applet Program
3.Import the applet Program in the JSP File
<%@page import="com.sample">
4.Include this Tag in the JSP File
<jsp:plugin type="applet" code="sample.class" width="620" height="450"> <jsp:params> <jsp:param name="data" value="10"/> </jsp:params> </jsp:plugin>
Popularity: 2% [?]

October 26th, 2008
admin
Posted in
Tags: 
