Applet In Jsp

In this example we are going to show you how you can use an applet in jsp.

Applet In Jsp

Applet In Jsp

        

In this example we are going to show you how you can use an applet in jsp. Before going deep into this program it is important to understand what is the meaning of an applet. Applets are small programs or applications written in java. These applets are those small programs that runs on web browsers, usually written in java. We can use the applets in jee also. In jee it runs on the context of web application on a client computer. This applet run in a container, which is provided by a browser or by through a plug- in. 

In this program we have made one applet in java. After making an applet in java we are using the applet class in the jsp by using the html tag <APPLET CODE = "JavaApplet.class" WIDTH = 200 HEIGHT = 150></APPLET>. This is one of the way by which can use an applet in jsp.

The code of the program is given below:

 

import java.applet.*;
import java.awt.*;
public class javaApplet extends Applet{
  public void paint(Graphics g){
    g.drawString("Welcome in Java Applet.",40,20);
  }
}

 

<HTML>
<HEAD><title>Applet In Jsp</title>
</HEAD>
<BODY>
<APPLET ALIGN="CENTER" CODE="javaApplet.class" WIDTH="800" HEIGHT="500">
</APPLET>
</BODY>
</HTML>

The output of the program:

Welcome in Java Applet.

Download this example.