by Dinesh Thakur Category: JSP Action Tags

In this Example we will discuss that we can include an applet or JavaBeans component in a JSP page by using the jsp:plugin element.

 

This will generates the HTML content that will contain the client-browser constructs. In the program we use java class for fetching the result an applet code also.Whenever this will be executed the appropriate output on the web browser.

<jsp:plugin type="applet" code="Pluginjsp.class" codebase="p1"  width = "250" height = "250">

<jsp:fallback>

       <p>Applet can't be load</p>

</jsp:fallback>

</jsp:plugin>

 

Pluginjsp.java

import java.applet.*;

import java.awt.*;

import java.util.*;

import java.io.*;

public class Pluginjsp extends Applet

{

   public void paint(Graphics gr)

    {

      Calendar cl = new GregorianCalendar();

      String hr = String.valueOf(cl.get(Calendar.HOUR));

      String mnt = String.valueOf(cl.get(Calendar.MINUTE));

      String scnd = String.valueOf(cl.get(Calendar.SECOND));

      gr.drawString(hr + ":" + mnt + ":" + scnd, 20, 30);

   }

}





About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.