Sunday, 25 March 2018

JSP Program to run a applet




Write a JAVA JSP Program which uses<jsp:plugin>tag to run a applet.

Steps to run Applet in JSP page.

i) click -> java web and webapplication
ii)Give project name and click next 
iii) select java 5 version click next and finish.


   




iv)  Right click on the default package 
      click on new Applet 
      give the class name ButtonMoveApplet and click on finish
      Add the following applet code 
      Run the ButtonMoveApplet.java file
      




import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class ButtonMoveApplet extends Applet
{
  public void paint(Graphics g)
  {
            setBackground(Color.pink);
             setForeground(Color.black);
             g.drawString("Welcome JSP-Applet",100,100);
  }
}

V) open the index.jsp and add the following JSP code

Go to mydocuments
select our  netbeans project that you have created
click on build and click on web folder
click on WEB-INF folder
click on classes
copy ButtonMoveApplet.class and paste in webpagefolder of your web application
both index.jsp and  ButtonMoveApplet.class must be in the same folder.




<%@ 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>

VI.Deploy and run your  project you will notice this error 




now copy the Url
go to control Panel
click on program 


VII  )click on java 

VIII click on security

iX )copy the URL which you have copied in the exception list and click ok


 X)  go to project and deploy and run you will get the following output.




1 comment:

PUBLISHER & SUBSCRIBER PATTERN

Using the UML Drawing Tool by implementing the code in Java demonstrate the Observer  Design Pattern. The Publisher-Subscriber desig...