PROGRAMS
1. Design an applet to create bio data using following
components Button, Choice, List ,Text field ,Text area
,Label,RadioButton
import [Link].*;
import [Link].*;
import [Link].*;
/* <applet code="[Link]" width=600
height=600>
</applet> */
Public class NullLayout extends Applet implements
ActionListener,ItemListener
{
TextField t3,t4,t5,t6,t7;
Button b1,b2;
Checkbox c1,c2,c3,c4,m,f;
CheckboxGroup cbg;
List l1;
Label l2,l3,l4,l5;
TextArea tx1;
public void init()
{
setLayout(null);
l2=new Label("NAME");
[Link](0,0,50,50);
add(l2);
t3=new TextField(20);
[Link](130,10,150,20);
add(t3);
l3=new Label("ADDRESS");
[Link](0,40,70,50);
add(l3);
t4=new TextField(20);
[Link](130,50,150,20);
add(t4);
l4=new Label("SEX");
[Link](0,80,70,50);
add(l4);
cbg=new CheckboxGroup();
m=new Checkbox("male",false,cbg);
[Link](130,90,75,20);
add(m);
[Link](this);
f=new Checkbox("female",false,cbg);
[Link](225,90,75,20);
add(f);
[Link](this);
l5=new Label("PURSUING");
[Link](0,120,70,50);
add(l5);
c1= new Checkbox("GRADUATE");
[Link](80,130,100,20);
add(c1);
[Link](this);
c2= new Checkbox(" POST GRADUATE");
[Link](180,130,130,20);
add(c2);
[Link](this);
c3= new Checkbox("UNDER GRADUATE");
[Link](310,130,130,20);
add(c3);
[Link](this);
c4= new Checkbox("PROFESSIONAL");
[Link](450,130,130,20);
add(c4);
[Link](this);
l5=new Label("LANGUAGE KNOWN");
[Link](0,160,120,50);
add(l5);
l1=new List(4,true);
[Link]("C");
[Link]("C++");
[Link]("JAVA");
[Link](".NET");
[Link]("FORTRAN");
[Link]("PHP");
[Link]("JAVASCRIPT");
[Link]("C#");
[Link]("COBOL");
[Link](130,170,150,80);
add(l1);
b1= new Button("SUBMIT");
[Link](150,280,70,20);
add(b1);
[Link](this);
b2= new Button("RESET");
[Link](300,280,70,20);
add(b2);
[Link](this);
tx1=new
TextArea("",10,20,TextArea.SCROLLBARS_BOTH);
[Link](0,350,600,100);
add(tx1);
}
String selections[];
public void actionPerformed(ActionEvent e){
if([Link]()==b1){
[Link]([Link]()+"*********",0);
[Link]([Link]()+"**********",0);
}
String msg= new String("");
if([Link]()==b2)
{
[Link](msg);
[Link](msg);
[Link](msg);
}
String outString=new String("you selected");
if([Link]()==b1){
selections=[Link]();
for(int loop=0;loop<[Link];loop++)
{ outString +=" " + selections[loop];
}
[Link](outString,0);
}
}
public void itemStateChanged(ItemEvent e){
[Link](((Checkbox)[Link]()).getLabel() +
"clicked**********",0);
}
}
2. Develop a program illustrating the use of checkbox &
checkbox Group.
import [Link];
import [Link];
import [Link];
public class exp1 extends Applet
{
public void init()
{
Checkbox c1=new Checkbox("MSCIT",true);
Checkbox c2=new Checkbox("MS",false);
add(c1);
add(c2);
CheckboxGroup checkboxGroup = new
CheckboxGroup();
Checkbox java = new Checkbox("Java",
checkboxGroup, true);
Checkbox cpp = new Checkbox("C++",
checkboxGroup, true);
add(java);
add(cpp);
}
}
/*<applet code="exp1" width=300 height=300>
</applet>*/
3. Develop a program which makes use of Flow Layout.
import [Link].*;
import [Link].*;
/*
<applet code="FlowLayoutDemo1" width=400
height=400>
</applet>
*/
public class FlowLayoutDemo1 extends Applet {
String msg;
Button b1,b2,b3;
public void init()
{
setLayout(new FlowLayout([Link]));
b1 = new Button("ok");
b2 = new Button("cancel");
b3 = new Button("exit");
add(b1);
add(b2);
add(b3);
}
}
4. Develop a program to create six buttons & apply Grid
Layout.
import [Link].*;
import [Link].*;
/*
<applet code="GridLayoutDemo1" width=300
height=300>
</applet>
*/
public class GridLayoutDemo1 extends Applet
{
public void init()
{
setLayout(new GridLayout(4, 4));
Button b1=new Button("one0");
Button b2=new Button("one1");
Button b3=new Button("one2");
Button b4=new Button("one3");
Button b5=new Button("one4");
Button b6=new Button("one5");
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
add(b6);
}
}
5. Write a program which will create checkable menu item
„Picture‟ under Insert Menu & „Paste „Menu item under the
menu Home.
import [Link].*;
class MenuExample
{
MenuExample()
{
Frame f= new Frame("Menu and MenuItem
Example");
MenuBar mb=new MenuBar();
Menu menu1=new Menu("Home");
Menu menu2=new Menu("Insert");
CheckboxMenuItem c=new
CheckboxMenuItem("picture",true);
MenuItem m=new MenuItem("paste");
[Link](c);
[Link](m);
[Link](menu1);
[Link](menu2);
[Link](mb);
[Link](200,200);
[Link](null);
[Link](true);
}
public static void main(String args[])
{
new MenuExample();
}
}
6. Develop a program that includes three menus such as Page
Layout, References & mailing .Also disable the mailing
menu.
import [Link].*;
class MenuExample1
{
MenuExample1(){
Frame f= new Frame("Menu and MenuItem Example");
MenuBar mb=new MenuBar();
Menu menu1=new Menu("Page Layout");
Menu menu2=new Menu("References ");
Menu menu3=new Menu("mailing ");
[Link](false);
[Link](menu1);
[Link](menu2);
[Link](menu3);
[Link](mb);
[Link](200,200);
[Link](null);
[Link](true);
}
public static void main(String args[])
{
new MenuExample1();
}
}
7. Develop a frame having title as “changing Color” with a
Provision to select a particular among Red, Green & Blue.
Make the use of JComboBox.
import [Link].*;
import [Link].*;
import [Link].*;
public class ComboBox1 extends JFrame implements
ItemListener
{
JComboBox CmbBx = new JComboBox();
String s = " ";
JLabel l=new JLabel();
public ComboBox1()
{
setVisible(true);
setTitle("Changing Color");
setSize(300,350);
Container cntnr = getContentPane();
[Link]("RED");
[Link]("green");
[Link]("blue");
[Link](new FlowLayout());
[Link](CmbBx);
[Link](this);
[Link](l);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void itemStateChanged(ItemEvent e1)
{
s="Item Selected:"+
[Link]([Link]());
[Link](s);
}
public static void main(String args[])
{
ComboBox1 c=new ComboBox1();
}
8. Develop a program to create a frame in swing with size 300
pixels in width & 350 pixels in height
Above Program
9. Develop a code for output given below.
import [Link].*;
/*
<applet code="JTabbedPaneDemo" width=400
height=100>
</applet>
*/
public class JTabbedPaneDemo extends JApplet {
public void init() {
JTabbedPane jtp = new JTabbedPane();
JButton b1 = new JButton("New York");
[Link]("Cities", new CitiesPanel());
[Link]("Colors", new ColorsPanel());
[Link]("Flavors", new FlavorsPanel());
add(jtp);
}
}
class CitiesPanel extends JPanel {
public CitiesPanel() {
JButton b1 = new JButton("New York");
add(b1);
JButton b2 = new JButton("London");
add(b2);
JButton b3 = new JButton("Hong Kong");
add(b3);
JButton b4 = new JButton("Tokyo");
add(b4);
}
}
class ColorsPanel extends JPanel {
public ColorsPanel() {
JCheckBox cb1 = new JCheckBox("Red");
add(cb1);
JCheckBox cb2 = new JCheckBox("Green");
add(cb2);
JCheckBox cb3 = new JCheckBox("Blue");
add(cb3);
}
}
class FlavorsPanel extends JPanel {
public FlavorsPanel() {
JComboBox jcb = new JComboBox();
[Link]("Vanilla");
[Link]("Chocolate");
[Link]("Strawberry");
add(jcb);
}
}
10. Develop Program to create three buttons & apply three
different images on button.
import [Link].*;
import [Link].*;
/*
<applet code="JButtonDemo" width=250 height=300>
</applet>
*/
public class JButtonDemo extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
[Link](new
FlowLayout([Link]));
ImageIcon france = new ImageIcon("[Link]");
ImageIcon f1 = new ImageIcon("[Link]");
ImageIcon f2 = new ImageIcon("[Link]");
JButton jb1 = new JButton(f1);
[Link](jb1);
JButton jb2 = new JButton(f2);
[Link](jb2);
JButton jb = new JButton(f1);
[Link](jb);
}
}
11. Develop a program to create three radio button once
user click on button background color will changes such as
“Red”, “Green” &”Blue”.
import [Link].*;
import [Link].*;
import [Link].*;
public class radio extends JApplet implements ItemListener
{
JRadioButton b1,b2,b3;
Container contentPane = getContentPane();
public void init()
{
[Link](new FlowLayout());
b1 = new JRadioButton("RED",true);
[Link](b1);
b2 = new JRadioButton("GREEN",false);
[Link](b2);
b3 = new JRadioButton("BLUE",false);
[Link](b3);
[Link](this);
[Link](this);
[Link](this);
ButtonGroup bg = new ButtonGroup();
[Link](b1);
[Link](b2);
[Link](b3);
}
public void itemStateChanged(ItemEvent eve)
{
if([Link]())
{
[Link]([Link]);
}
else if([Link]())
{
[Link]([Link]);
}
else
{
[Link]([Link]);
}
}
}
/*<applet code="radio" width=300 height=300>
</applet>
*/
12. To develop a program to create JTable.
import [Link].*;
import [Link].*;
/*
<applet code="JTableDemo" width=400 height=200>
</applet>
*/
public class JTableDemo extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
[Link](new FlowLayout());
final String[] colHeads = { "Name", "Phone", "Fax" };
final Object[][] data = {
{ "Gail", "4567", "8675" },
{ "Ken", "7566", "5555" },
{ "Viviane", "5634", "5887" },
{ "Melanie", "7345", "9222" },
{ "Helen", "6751", "1415" }
};
JTable table = new JTable(data, colHeads);
int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NE
EDED;
int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_
NEEDED;
JScrollPane jsp = new JScrollPane(table, v, h);
[Link](jsp);
}
}
13. Develop a program which wills implements various
methods of Mouse Motion Listener.
import [Link].*;
import [Link].*;
import [Link].*;
/*
<applet code="MouseEvents" width=300 height=100>
</applet>
*/
public class MouseEvents extends Applet
implements MouseMotionListener {
String msg = "";
int mouseX = 0, mouseY = 0;
public void init() {
addMouseMotionListener(this);
}
public void mouseDragged(MouseEvent me) {
showStatus("Dragging mouse at " + [Link]() + ", " +
[Link]());
}
public void mouseMoved(MouseEvent me) {
showStatus("Moving mouse at " + [Link]() + ", " +
[Link]());
}
public void paint(Graphics g) {
[Link](msg, mouseX, mouseY);
}
}
14. Develop a program to create an applet to accept a
number in 2 text field & display the larger of two numbers
when a button with the caption “Largest” is pressed.
import [Link].*;
import [Link].*;
import [Link].*;
public class TwoNumbers extends Applet implements
ActionListener
{
TextField firstNum, secondNum, resultNum;
Button b;
Label l1,l2,l3;
public void init()
{
setLayout(new GridLayout(5,5));
firstNum = new TextField(15);
secondNum = new TextField(15);
resultNum = new TextField(15);
l1=new Label("Enter First Number");
l2=new Label("Enter Second Number");
l3=new Label("Largest no");
b=new Button("Press to find Largest No");
add(l1);
add(firstNum);
add(l2);
add(secondNum);
add(l3);
add(resultNum);
add(b);
[Link](this);
}
public void actionPerformed(ActionEvent e)
{
int a=[Link]([Link]());
int b=[Link]([Link]());
if(a<b)
{
[Link]([Link](b));
}
else
{
[Link]([Link](a));
}
}
}
/*<applet code="TwoNumbers" width=400 height=200>
</applet>*/
15. Develop a program to create an applet to accept a
number in a text field & display the square of the number
when a button with caption Square is pressed.
import [Link].*;
import [Link].*;
import [Link].*;
public class Square extends Applet implements
ActionListener
{
TextField firstNum, resultNum;
Button b;
Label l1,l3;
public void init()
{
firstNum = new TextField(15);
resultNum = new TextField(15);
l1=new Label("Enter First Number");
l3=new Label("Square no");
b=new Button("Press to find Largest No");
add(l1);
add(firstNum);
add(resultNum);
add(b);
[Link](this);
}
public void actionPerformed(ActionEvent e)
{
int a=[Link]([Link]());
int res=a*a;
[Link]([Link](res));
}
}
/*<applet code="Square" width=400 height=200>
</applet>*/
16. Develop a program to create three buttons “yes”,
“No”, ”Exit” using an applet once user click on button
“yes” it will show the message “you pressed yes” if user
pressed “No” it will show the message “you pressed No”
else it show “you pressed exit ”
import [Link].*;
import [Link].*;
import [Link].*;
public class ButtonDemo1 extends Applet implements
ActionListener
{
Button a,b,c;
String msg="";
public void init()
{
setLayout(new FlowLayout([Link]));
a = new Button("yes");
b = new Button("no");
c=new Button("exit");
[Link](this);
[Link](this);
[Link](this);
add(a);
add(b);
add(c);
}
public void actionPerformed(ActionEvent e)
{
String str = [Link]();
if([Link]("yes"))
msg ="You clicked yes button, Thank you for accepting
the agreement";
else if([Link]("no"))
msg= "You clicked no button, Sorry for no the
agreement";
else
msg= "You clicked exit button, Sorry for exit the
agreement";
repaint();
}
public void paint(Graphics g)
{
[Link](msg,100,100);
}
}
/*<applet code="ButtonDemo1" width=200 height=200>
</applet>
*/
17. Develop a program to create an applet to change the
background color of an applet according to the scolling of
scrollbars namely „RED‟, „Green‟ & ‟Blue‟.
import [Link].*;
import [Link].*;
import [Link].*;
public class ScrollChanging extends Applet implements
AdjustmentListener
{
Scrollbar s1, s2, s3;
GridLayout g;
public void init()
{
g = new GridLayout(10,1,10,10);
setLayout(g);
s1 = new
Scrollbar([Link],0,50,0,255);
s2 = new
Scrollbar([Link],0,50,0,255);
s3 = new
Scrollbar([Link],0,50,0,255);
[Link](this);
[Link](this);
[Link](this);
add(s1);
add(s2);
add(s3);
}
public void
adjustmentValueChanged(AdjustmentEvent e)
{
repaint();
}
public void paint(Graphics g)
{
int x, y, z;
x = [Link]();
y = [Link]();
z = [Link]();
showStatus("Red : " + x + " Green : " + y + "
Blue : " + z);
Color c = new Color(x,y,z);
setBackground(c);
}
}
/*<applet code="ScrollChanging" height=400 width=300>
</applet>*/
18. Write any program that implements the concepts of
adapter class.
import [Link].*;
import [Link].*;
import [Link].*;
/*<applet code="AdapterExample" width=400
height=400>
</applet>*/
public class AdapterExample extends Applet
{
public void init()
{
Label l=new Label("MOuse Entered");
add(l);
addMouseListener(new MyAdapterExample(this));
}
}
class MyAdapterExample extends MouseAdapter // second
class
{
AdapterExample ae;
public MyAdapterExample(AdapterExample ae )
{
[Link]=ae;
}
public void mouseClicked(MouseEvent e)
{
[Link]("You clicked mouse at coordinates " +
[Link]() + ", " + [Link]());
}
}
19. Develop a program to retrieve IPaddress of local
machine.
import [Link].*;
import [Link].*;
public class InetDemo
{
public static void main(String[] args)
{
try
{
InetAddress ip=[Link]();
[Link]("Host Name: "+ip);
}
catch(UnknownHostException e)
{
[Link]("Exception "+e);
}
}
}
20. Develop a program to send user name to the server &
server will send “hello <USER NAME>” to the client using
UDP.
//Clientside
import [Link].*;
import [Link].*;
class UDPClient
{
public static void main(String args[]) throws Exception
{
[Link]("Enter the UserName");
BufferedReader inFromUser =new
BufferedReader(new InputStreamReader([Link]));
DatagramSocket clientSocket = new DatagramSocket();
InetAddress IPAddress =
[Link]("localhost");
byte[] sendData = new byte[1024];
byte[] receiveData = new byte[1024];
String sentence = [Link]();
sendData = [Link]();
DatagramPacket sendPacket = new
DatagramPacket(sendData, [Link], IPAddress,
9876);
[Link](sendPacket);
DatagramPacket receivePacket = new
DatagramPacket(receiveData, [Link]);
[Link](receivePacket);
String modifiedSentence = new
String([Link]());
[Link]("FROM SERVER: HELLO" +
modifiedSentence);
[Link]();
}
}
//ServerSide
import [Link].*;
import [Link].*;
class UDPServer
{
public static void main(String args[]) throws Exception
{
DatagramSocket serverSocket = new
DatagramSocket(9876);
byte[] receiveData = new byte[1024];
byte[] sendData = new byte[1024];
while(true)
{
DatagramPacket receivePacket = new
DatagramPacket(receiveData, [Link]);
[Link](receivePacket);
String sentence = new String(
[Link]());
[Link]("RECEIVED: " + sentence);
InetAddress IPAddress =
[Link]();
int port = [Link]();
String capitalizedSentence =
[Link]();
sendData = [Link]();
DatagramPacket sendPacket =new
DatagramPacket(sendData, [Link], IPAddress,
port);
[Link](sendPacket);
}
}
}
21. When the user enters a URL in the text field your
program should connect to the URL read its contents &
display them in the text area.
22. Use the HTTP URL connection class to read the
content of the URL.
23. Develop a program using getInputStream () method.
For 21 to 23 same program.
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
class exp10 extends JFrame
{
JTextArea ta = new JTextArea();
JTextField tf = new JTextField();
JButton b = new JButton("Content view");
exp10()
{
add(ta,"Center");
add(tf,"South");
add(b,"North");
[Link](new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
[Link](" ****following are Contents of web-page
****");
try
{
URL u=new URL([Link]());
URLConnection uc=[Link]();
InputStream is=[Link]();
int i;
int len = [Link]();
if (len != 0)
{
[Link](" **** Contents of web-page ****");
while((i=[Link]())!=-1)
{
[Link]([Link](i));
}
}
else
[Link](" **** Contents not found ****");
}catch(MalformedURLException e)
{}
catch(IOException e)
{}
}
});
}
public static void main(String s[])
{
exp10 fr = new exp10();
[Link](300,300);
[Link](true);
[Link](EXIT_ON_CLOSE);
}
}
24. Develop a program to print protocol, port ,host ,file of
[Link]
import [Link].*;
import [Link].*;
public class exp121
{
public static void main(String[] args)
{
Try
{
URL url=new URL("[Link]
[Link]("Protocol: "+[Link]());
[Link]("Host Name: "+[Link]());
[Link]("Port Number: "+[Link]());
[Link]("File Name: "+[Link]());
}catch(Exception e){[Link](e);
}
}
}
25. Develop a program to send a password through client
to the server & server will send the message to the client
that the password is valid or invalid.
//clientside
import [Link].*;
import [Link].*;
public class Client1
{
public static void main( String args[]) throws
Exception
{
Socket cs = new Socket("localhost",1234);
BufferedReader kb = new BufferedReader(new
InputStreamReader([Link]));
BufferedReader br = new BufferedReader(new
InputStreamReader([Link]()));
DataOutputStream dos = new
DataOutputStream([Link]());
[Link](" Enter password");
[Link](" if client 'quit' type exit");
[Link](" Enter password");
String s1,s4=null;
while(!(s1=[Link]()).equals("exit"))
{
[Link](" data send to server
machine");
[Link](s1+"\n");
}
[Link]("Terminated..");
[Link]();
[Link]();
[Link]();
}
}
//serverside
import [Link].*;
import [Link].*;
public class Server1
{
public static void main( String args[]) throws
Exception
{
ServerSocket srs = new ServerSocket(1234);
[Link]("Server is running...");
Socket ss=[Link]();
[Link]("connection establised");
BufferedReader kb = new BufferedReader(new
InputStreamReader([Link]));
BufferedReader br = new BufferedReader(new
InputStreamReader([Link]()));
DataOutputStream dos = new
DataOutputStream([Link]());
while(true)
{
String s2,s1="password";
while((s2=[Link]())!=null)
{
[Link]("Client Entered Password: "+s2);
if([Link](s1))
{
[Link]("your password is correct");
}
else
{
[Link]("your password is incorrect");
}
}
[Link]("Terminated..");
[Link]();
[Link]();
[Link]();
[Link]();
[Link](0);
}
}
}
For Database Program:
Steps to create Data Source Name
Control Panel\All Control Panel Items\Administrative
Tools\ODBC DATA Source (32 bit)
Click on add\select driver(Driver do Microsoft
Acess(.mdb))
Data source Name- write it .Then Database create or select
.
26. Develop a program to create employee table in
database having two columns “emp_id” & “emp_name”
import [Link].*;
import [Link];
import [Link];
public class create
{
public static void main(String args[]) throws
ClassNotFoundException
{
try
{
[Link]("[Link]");
[Link]("driver Loaded");
String dsn="jdbc:odbc:abc";
Connection con=[Link](dsn);
[Link]("connection established");
String sql="Create table employee(empname
varchar(255),empid number)";
Statement st=[Link]();
[Link](sql);
[Link]("is created");
[Link]();
[Link]();
}
catch(Exception e)
{
[Link](e);
}
}
}
27. Develop a program to display the name & roll_no of
student from “student table” having percentage>70.
import [Link].*;
class Select{
public static void main(String ar[]){
try{
String url="jdbc:odbc:abc";
[Link]("[Link]");
[Link]("dr");
Connection c=[Link](url);
[Link]("cn");
Statement st=[Link]();
[Link]("s");
ResultSet rs=[Link]("Select name,rollno from
student where per>70");
while([Link]())
{
[Link]("name is"+[Link](1));
[Link]("rollno is"+[Link](2));
//[Link]("per is"+[Link](3));
}
}catch(Exception ee){[Link](ee);}
}}
28. Develop a program to change the name of the product
from “tv” to “Computer” in the database product.
import [Link].*;
import [Link];
import [Link];
public class update
{
public static void main(String args[]) throws
ClassNotFoundException
{
try
{
[Link]("[Link]");
[Link]("driver LOaded");
String dsn="jdbc:odbc:abc";
Connection con=[Link](dsn);
Statement st=[Link]();
String sql="update product set name='computer' where
name='tv'";
[Link](sql);
[Link]("Table is updated");
[Link]();
[Link]();
}
catch(Exception e)
{
[Link](e);
}
}
}
How to run servlet program
Steps:
[Link] Netbeans IDE, Select File -> New Project
[Link] Java Web -> Web Application, then click on
Next,
[Link] a name to your project and click on Next,
4. then, Click Finish
[Link] complete directory structure required for the Servlet
Application will be created automatically by the IDE.
6. To create a Servlet, open Source Package, right click
on default packages -> New -> Servlet.
[Link] a Name to your Servlet class file,
[Link], your Servlet class is ready, and you just need to
change the method definitions and you will good to go.
9. Write some code inside your Servlet class.
[Link] Webpages->WEB-INF->[Link]
[Link] some code inside your HTML file.
29. Develop a program to verify that the password is not
more than 6 characters.
[Link]
<form action="check" method="post">
Enter Username :
<input type="text" name="username"><br/>
Enter Password :
<input type="text" name="pass"><br/>
<input type="submit" value="submit">
</form>
Add this code : in new servlet file ie [Link]
(in this processRequest())
String p;
p = [Link]("pass");
String u;
u = [Link]("username");
if([Link]("payal") && ([Link]() > 6))
//if(([Link]() > 6))
{
[Link]("password is too long"+p);
}
else
{
[Link]("Your password is less than 6");
}
30. Develop a JSP to perform basic arithmetic operations.
1. Start by creating a "Java web" -> "web application project".
2. Then right click on web pages->new ->JSP->file name -
>finish
3. Also for second jsp page
First JSP File :- save as [Link]
<form action="[Link]" method="post">
Enter First No :
<input type="text" name="no1"><br/>
Enter Second No :
<input type="text" name="no2"><br/>
<input type="submit" value="submit">
</form>
Second JSP FILE :- save as [Link] Add<% ---code--%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
int n1=[Link]([Link]("no1"));
int n2=[Link]([Link]("no2"));
int add=n1+n2;
int sub=n1-n2;
int mul=n1*n2;
int div=n1/n2;
[Link]("Addition is"+add);
[Link]("Subtraction is"+sub);
[Link]("multiplication is"+mul);
[Link]("Division is"+div);
%>
</body>
</html>