Applet is java program that can be embedded into HTML pages. Java applets runs on the java enables web browsers such as mozila and internet explorer.
Applet is java program that can be embedded into HTML pages. Java applets runs on the java enables web browsers such as mozila and internet explorer.Applet is java program that can be embedded into HTML pages. Java applets runs on the java enables web browsers such as mozila and internet explorer. Applet is designed to run remotely on the client browser, so there are some restrictions on it. Applet can't access system resources on the local computer. Applets are used to make the web site more dynamic and entertaining. For reading more detail on apple visit: http://www.roseindia.net/java/example/java/applet/
To use applet in JSP page we can use <jsp:plugin>. By the use of <jsp:plugin> you can include an applet and JavaBean in your JSP page. Syntax of <jsp:plugin> is :
<jsp:plugin type="bean|applet" code="classFile" codebase="classFileDirectory" [ name="instancename" ] [ align="bottom|top|middle|left|right" ] [ height="displayPixels" ] [ width="displayPixels" ] [ jreversion="JREVersion" ] ................. > [<jsp:params> <jsp:param name="parametername" value="parametervalue" /> .......... </jsp:params>] [<jsp:fallback> |
To plugin an applet in JSP page we require an applet. So we have made an applet "ButtonMoveApplet.java". Code for this applet file is given as below:
ButtonMoveApplet.java
import java.io.*;
|
To use this applet we have used <jsp:plugin> in AppletJsp.jsp. This applet is being used in JSP file by the use of following code.
.................... .................... <jsp:plugin type="applet" code="ButtonMoveApplet.class" width="400" height="400"> <jsp:fallback> <p>Unable to load applet</p> </jsp:fallback> </jsp:plugin> .................. .................. |
Full code for AppletJsp.jsp is gievn as below:
AppletJsp.jsp
<%@ page language="java" %> <html> <head> <title>Welcome JSP-Applet Page</title> </head> <body> <jsp:plugin type="applet" code="ButtonMoveApplet.class" width="400" height="400"> <jsp:fallback> <p>Unable to load applet</p> </jsp:fallback> </jsp:plugin> </body> </html> |
Steps for running this example:
You will get following output.
Output:
Ads