CHIKKANNA GOVT.
ARTS COLLEGE
TIRUPUR-641602
(Affiliated to Bharathiyar University,Coimbatore)
ADVANCED JAVA PROGRAMMING LAB
Reg. No :
Name :
[Link] – Computer Science
SEMESTER –ll
PG & RESEARCH
DEPARTMENT OF COMPUTER SCIENCE
CHIKKANNA GOVERNMENT ARTS COLLEGE
TIRUPUR -641602
(Affiliated to Bharathiyar University)
Name :
Reg. No :
Class : I - [Link] [ComputerScience]
This is to certified that it is a bonafide record of the practical work done by the above
student of the [Link](COMPUTER SCIENCE) Degree Examinations Core Practical
ADVNCED JAVA PROGRAMMING LAB during the Academic year 20 -20 .
Staff In-charge Head of the Department
Submitted for the University Practical Examination held on................20 .
[Link] DATE CONTENT [Link] SIGNATURE
1 WELCOME SERVLET
2 PURCHASE ORDER FORM
USING SERVLET
3 MARK LIST PREPARATION
USING JSP
4 PURCHASE ORDER FORM
USING JSP
5 EMPLOYEE PAYROLL
PREPARATION USING JSP
6 CREATE TABLE USING
JDBC
7 FORM DATA HANDLING
USING SERVLET
8 CREATE TABLE USING
SERVLET
9 CREATE SESSION OBJECT
USING JSP
10 CLIENT SERVER
APPLICATION USING RMI
11 CREATE CALCULATOR
USING APPLET
CREATE MESSAGE
12 PASSING PROGRAM USING
SOCKET PROGRAMMING
[Link]
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<div>Servlet Programs</div>
<form action="HelloServlet">
<table border="1">
<tbody>
<tr>
<td>Name:</td>
<td><input type="text" name="name" value="" size="50" /></td>
</tr>
</tbody>
</table>
<input type="submit" value="Enter" name="enter" />
</form>
</center>
</body>
</html>
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class welcome extends HttpServlet
{
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
[Link]("text/html;charset=UTF-8");
PrintWriter out = [Link]();
try
String name=[Link]("name");
[Link]("<h3>Welcome "+name+".You Have able to run servlet programs</h3>");
catch(Exception e)
OUTPUT
RESULT
Thus the above program is executed and the output is verified successfully.
[Link]
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<div><h4>Fruits land<h4></div>
<form action="display">
<table border="1">
<tbody>
<tr>
<td>name:</td>
<td><input type="text" name="cname" value="" size="50" /></td>
</tr>
<tr>
<td>Fruit Name:</td>
<td><input type="text" name="fname" value="" size="50" /></td>
</tr>
<tr>
<td>Fruit Rate:</td>
<td><input type="text" name="frate" value="" size="50" /></td>
</tr>
<tr>
<td>Quantity:</td>
<td><input type="text" name="quantity" value="" size="30" /><select name="type"width="20">
<option>Kg</option>
<option>Nos</option>
</select></td>
</tr>
</tbody>
</table>
<input type="submit" value="Submit" name="submit" />
<input type="reset" value="Clear" name="clear" />
</form>
</center>
</body>
</html>
[Link]
package com;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class display extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
[Link]("text/html");
PrintWriter out = [Link]();
try
String name=[Link]("cname");
String fname=[Link]("fname");
String frate=[Link]("frate");
String quantity=[Link]("quantity");
int frate1=[Link](frate);
int quantity1=[Link](quantity);
int trate=frate1*quantity1;
[Link]("<center><table border=1");
[Link]("<h1>Fruits Land</h1>");
[Link]("<h3>Your Ordered details</h3>");
[Link]("<tr><td>Name:"+name+"</tr></td>");
[Link]("<tr><td>Fruit Name:"+fname+"</tr></td>");
[Link]("<tr><td>Fruit rate:"+frate+"</tr></td>");
[Link]("<tr><td>Quantity:"+quantity+"<td>"+[Link]("type")+"</tr></td></td>");
[Link]("<tr><td>Total Price:"+trate+"</tr></td>");
[Link]("</center></table>");
catch(Exception e)
OUTPUT
RESULT
Thus the above program is executed and the output is verified successfully.
[Link]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Student Mark List</title>
</head>
<center>
<body>
<h1>Student Mark List</h1>
<form action="[Link]" method="POST">
<table border="1">
<tbody>
<tr>
<td>Register No:</td>
<td><input type="text" name="register" value="" size="40" /></td>
</tr>
<tr>
<td>Name:</td>
<td><input type="text" name="name" value="" size="40" /></td>
</tr>
<tr>
<td>Subject1:</td>
<td><input type="text" name="s1" value="" size="40" /></td>
</tr>
<tr>
<td>Subject2:</td>
<td><input type="text" name="s2" value="" size="40" /></td>
</tr>
<tr>
<td>Subject3:</td>
<td><input type="text" name="s3" value="" size="40" /></td>
</tr>
</tbody>
</table>
<input type="submit" value="Submit" name="SUBMIT" />
<input type="reset" value="reset" name="RESET" />
</form>
</body>
</center>
</html>
[Link]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Student Mark List</title>
</head>
<body>
<center>
<h1>Student Mark List</h1>
<%
String reg=([Link]("register"));
Stringname=([Link]("name"));
String s1=([Link]("s1"));
String s2=([Link]("s2"));
String s3=([Link]("s3"));
if(!(s1==null||[Link]()))
int s1m=[Link](s1);
int s2m=[Link](s2);
int s3m=[Link](s3);
if(s1m<40||s2m<40||s3m<40)
[Link]("<table border=5 width=500 height=5><center>");
[Link]("<tr><td>Register No:<td>"+reg+"</tr></td>");
[Link]("<tr><td>Name:<td>"+name+"</tr></td>");
[Link]("<tr><td>Total:<td>Not To Evoluate</tr></td>");
[Link]("<tr><td>Percentage:<td>Not To Evoluate</tr></td>");
[Link]("<tr><td>Grade:<td>Not To Evoluate</tr></td>");
else
int t=s1m+s2m+s3m;
int p=t/3;
String grade="";
if(p>=40&&p<=60){grade="Good";}
else if(p>=61&&p<=80){grade="Very Good";}
else if(p>=81&&p<=100){grade="Excellent";}
[Link]("<table border=5 width=500 height=5><center>");
[Link]("<tr><td>Register No:<td>"+reg+"</tr></td>");
[Link]("<tr><td>Name:<td>"+name+"</tr></td>");
[Link]("<tr><td>Total:<td>"+t+"</tr></td>");
[Link]("<tr><td>Percentage:<td>"+p+"</tr></td>");
[Link]("<tr><td>Grade:<td>"+grade+"</tr></td>");
%>
</center>
</body>
</html>
OUTPUT
RESULT
Thus the above program is executed and the output is verified successfully.
[Link]
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<div>PURCHASE ORDER FORM</div>
<form action="[Link]" method="POST">
<table border="1">
<tbody>
<tr>
<td>Name:</td>
<td><input type="text" name="name" value="" size="50" /></td>
</tr>
<tr>
<td>Product Id:</td>
<td><input type="text" name="pid" value="" size="50" /></td>
</tr>
<tr>
<td>Product name:</td>
<td><select name="pname">
<option>Veg Pizza</option>
<option>Cheese and chicken pizza</option>
<option>chicken pizza</option>
<option>Egg roll Chicken pizza</option>
</select></td>
</tr>
<tr>
<td>Quantity:</td>
<td><input type="text" name="quantity" value="" size="50" /></td>
</tr>
<tr>
<td>Drink ID:</td>
<td><input type="text" name="did" value="" size="50" /></td>
</tr>
<tr>
<td>Drink Name:</td>
<td><select name="dname">
<option>Cocacola</option>
<option>pepsi</option>
<option>Mirenda</option>
<option>Thumpsup</option>
</select></td>
</tr>
<tr>
<td>Quantity:</td>
<td><input type="text" name="dquan" value="" size="50" /></td>
</tr>
<tr>
<td><input type="submit" value="Submit" name="submit" /></td>
<td><input type="reset" value="Clear" name="clear" /></td>
</tr>
</tbody>
</table>
</form>
</center>
</body>
</html>
[Link]
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<center>
<h1>Domino's pizza</h1>
<%
Stringname=[Link]("name");
Stringpid=[Link]("pid");
String pname=[Link]("pname");
Stringquantity=[Link]("quantity");
Stringdid=[Link]("did");
Stringdname=[Link]("dname");
String dquan=[Link]("dquan");
if(!(quantity==null||[Link]()))
int pquan=[Link](quantity);
int dquan1=[Link](dquan);
int pprice=50*pquan;
int dprice=60*dquan1;
if([Link]("Veg Pizza"))
pprice=50*pquan;
else if([Link]("Cheese and chicken pizza"))
pprice=75*pquan;
else if([Link]("chicken pizza"))
{
pprice=60*pquan;
else if([Link]("Egg roll Chicken pizza"))
pprice=100*pquan;
if([Link]("Cocacola"))
dprice=20*dquan1;
else if([Link]("pepsi"))
dprice=60*dquan1;
else if([Link]("Mirenda"))
dprice=10*dquan1;
else if([Link]("Thumpsup"))
dprice=30*dquan1;
int tprice=pprice+dprice;
[Link]("<center><table border=1>");
[Link]("<tr><td>Name:<td>"+name+"</tr></td>");
[Link]("<tr><td>Product Name:<td>"+pname+"</tr></td>");
[Link]("<tr><td>Product Price:<td>"+pprice+"</tr></td>");
[Link]("<tr><td>Drink Name:<td>"+dname+"</tr></td>");
[Link]("<tr><td>Drink Price:<td>"+dprice+"</tr></td>");
[Link]("<tr><td>Total Price:<td>"+tprice+"</tr></td>");
%>
</center></body></html>
OUTPUT
RESULT
Thus the above program is executed and the output is verified successfully.
[Link]
<html>
<head>
<title>EMPLOYEE PAYROLL PREPARATION</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<div>EMPLOYEE PAYROLL PREPARATION</div>
<form action="[Link]" method="POST">
<table border="1">
<tbody>
<tr>
<td>EMPLOYEE ID:</td>
<td><input type="text" name="EID" value="" size="50" /></td>
</tr>
<tr>
<td>EMPLOYEE NAME:</td>
<td><input type="text" name="ENAME" value="" size="50" /></td>
</tr>
<tr>
<td>WORKING HOURS:</td>
<td><input type="text" name="EHRS" value="" size="50" /></td>
</tr>
<tr>
<td>RATE PER HOUR:</td>
<td><input type="text" name="RPH" value="" size="50" /></td>
</tr>
</tbody>
</table>
<input type="submit" value="SUBMIT" name="SUBMIT" />
<input type="reset" value="CLEAR" name="CLEAR" />
</form>
</center>
</body>
</html>
[Link]
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>EMPLOYEE PAYROLL PREPARATION</title>
</head>
<body>
<h1>EMPLOYEE PAYROLL PREPARATION</h1>
<%
String id=([Link]("EID"));
String name=([Link]("ENAME"));
String whrs=([Link]("EHRS"));
String rate=([Link]("RPH"));
if(!(whrs==null||[Link]()))
int whrs1=[Link](whrs);
int rate1=[Link](rate);
int bp=whrs1*rate1;
int da=bp*5/100;
int ta=bp*2/100;
int hra=bp*3/100;
int pf=bp*2/100;
int lic=bp*5/100;
int tax=bp*3/100;
int gp=bp+da+ta+hra;
int np=gp-pf-lic-tax;
[Link]("<table border=5 width=500 height=5><center>");
[Link]("<tr><td>Employee ID:<td>"+id+"</tr></td>");
[Link]("<tr><td>Employee Name:<td>"+name+"</tr></td>");
[Link]("<tr><td>Basic Salary:<td>"+bp+"</tr></td>");
[Link]("<tr><td>DA:<td>"+da+"</tr></td>");
[Link]("<tr><td>TA:<td>"+ta+"</tr></td>");
[Link]("<tr><td>HRA:<td>"+hra+"</tr></td>");
[Link]("<tr><td>PF:<td>"+pf+"</tr></td>");
[Link]("<tr><td>LIC:<td>"+lic+"</tr></td>");
[Link]("<tr><td>TAX:<td>"+tax+"</tr></td>");
[Link]("<tr><td>Gross Salary:<td>"+gp+"</tr></td>");
[Link]("<tr><td>Net Salary:<td>"+np+"</tr></td>");
}
%>
</body>
</html>
OUTPUT
RESULT
Thus the above program is executed and the output is verified successfully.
[Link]
package database;
import [Link];
public class Database
public static void main(String[] args) throws SQLException
abc dr=new abc();
[Link]
package database;
import [Link];
import [Link];
import [Link];
import [Link];
class abc
public abc() throws SQLException
Connection con=[Link]("jdbc:derby://localhost:1527/student", "santhosh",
"santhosh");
PreparedStatement st= [Link]("insert into STUD values(?,?,?)");
[Link](1, 11);
[Link](2, "ram");
[Link](3, 96299);
int a=[Link]();
if(a>0)
{
[Link]("Row updated successfully");
}
OUTPUT
RESULT
Thus the above program is executed and the output is verified successfully.
[Link]
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<div>LoginForm</div>
<formaction="display">
<table border="1">
<tbody>
<tr>
<td>UserName:</td>
<td><input type="text" name="un" value="" size="50" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="pw" value="" size="50" /></td>
</tr>
</tbody>
</table>
<input type="submit" value="Login" name="Login" />
<input type="reset" value="Clear" name="clear" />
</form>
</center>
</body>
</html>
[Link]
package com;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class display extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
[Link]("text/html");
PrintWriter out = [Link]();
try
String name=[Link]("un");
String pass=[Link]("pw");
if([Link]("santhoshk"))
[Link]("<center>Welcome "+name+". You are valid user</center>");
else
[Link]("<center>Welcome "+name+". You are invalid user</center>");
catch(Exception e)
}
OUTPUT
RESULT
Thus the above program is executed and the output is verified successfully.
[Link]
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<div>Employee Entry files</div>
<form action="display" method="POST">
<table border="1">
<tbody>
<tr>
<td>Employee ID:</td>
<td><input type="text" name="eid" value="" size="50" /></td>
</tr>
<tr>
<td>Employee Name:</td>
<td><input type="text" name="ename" value="" size="50" /></td>
</tr>
</tbody>
</table>
<input type="submit" value="Submit" name="Submit" />
<input type="reset" value="Clear" name="Clear" />
</form>
</center>
</body>
</html>
[Link]
import [Link];
import [Link];
import [Link];
[Link];
import [Link];
import [Link];
import [Link];
[Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class display extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
[Link]("text/html");
PrintWriter out = [Link]();
String eid=[Link]("eid");
String ename=[Link]("ename");
if([Link]()||[Link]())
[Link]("Please Enter all requirement fields");
else
[Link]("Record inserted successfully");
try
Object newInstance;
newInstance = [Link]("[Link]").newInstance();
try(Connection con=[Link]("jdbc:derby://localhost:1527/empdb", "santhosh",
"santhosh"))
String query="insert into EMDB(ID,NAME) values(?,?)";
try(PreparedStatement ps = [Link](query))
[Link](1, [Link](eid));
[Link](2, ename);
[Link]();
} catch (SQLException ex) {
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
[Link]([Link]()).log([Link], null, ex);
OUTPUT
RESULT
Thus the above program is executed and the output is verified successfully.
[Link]
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Enter your name</title>
</head>
<body>
<h1>Enter Your name</h1>
<form action="[Link]" method="POST">
<input type="text" name="inputname" value="" size="40" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
[Link]
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Passing the input value to a session variable</title>
</head>
<body>
<h1></h1>
<%
String uname=[Link]("inputname");
[Link]("Welcome"+uname);
[Link]("sessname",uname);
%>
<a href="[Link]">Check output here!</a>
</body></html>
[Link]
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>output page:Fetching the value from session</title>
</head>
<body>
<h1></h1>
<%
String name=(String)[Link]("sessname");
[Link]("Hello user:You have Entered the name:"+name);
%>
</body>
</html>
OUTPUT
RESULT
Thus the above program is executed and the output is verified successfully.
[Link]
import [Link].*;
public interface adder extends Remote
public int add(int n1,int n2)throws RemoteException;
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
public class server extends UnicastRemoteObject implements adder
public server()throws RemoteException
// super();
public int add(int n1, int n2) throws RemoteException
return n1+n2;
public static void main(String[] args) throws RemoteException
try
Registry reg=[Link](4444);
[Link]("hi_server",new server());
[Link]("Server is Ready...");
catch(RemoteException e)
[Link]("Exception:"+e);
}
[Link]
import [Link];
import [Link];
[Link];
import [Link];
[Link];
public class client
public static void main(String args[]) throws RemoteException
client c = new client();
[Link]();
}
private void connectRemote() throws RemoteException
try
Scanner sc= new Scanner([Link]);
Registry reg = [Link]("LocalHost",4444);
adder ad = (adder)[Link]("hi_server");
[Link]("Enter two values");
int a = [Link]();
int b = [Link]();
[Link]("Addition is:"+[Link](a, b));
catch(NotBoundException|RemoteException e)
[Link]("Exception "+e);
}}
OUTPUT
RESULT
Thus the above program is executed and the output is verified successfully.
[Link]
package calc;
import [Link].*;
[Link].*;
public class Calc extends Applet {
Label lab;
boolean firstDigit=true;
float savedValue=0.0f;
String operator= "=";
public void addButtons (Panel p,String labels){
int count=[Link]();
for(int i=0;i<count;i++)
[Link] (new Button([Link](i,i+1)));
public void init(){
setLayout (new BorderLayout());
add("North",lab=new Label("0",[Link]));
Panel p=new Panel();
[Link](new GridLayout(4,4));
addButtons(p,"789/");
addButtons(p,"456*");
addButtons(p,"123-");
addButtons(p,".0=+");
add ("Center",p);
public boolean action(Event e,Object o){
if([Link] instanceof Button){
String s=(String)o;
if("0123456789.".indexOf(s) !=-1){
if(firstDigit){
firstDigit=false;
[Link] (s);
else{
[Link]([Link]()+s);
}else{
if(!firstDigit){
compute([Link]());
firstDigit=true;
operator=s;
return true;
return false;
public void compute(String s){
float sValue=new Float (s).floatValue();
char c=[Link](0);
switch(c){
case '=': savedValue =sValue;
break;
case '+': savedValue+=sValue;
break;
case '-': savedValue-=sValue;
break;
case '*': savedValue*=sValue;
break;
case '/': savedValue/=sValue;
break;
[Link]([Link](savedValue));
}
OUTPUT
RESULT
Thus the above program is executed and the output is verified successfully.
[Link]
import [Link].*;
import [Link].*;
public class server
public static void main(String args[])throws IOException
ServerSocket ss=new ServerSocket(4999);
Socket s=[Link]();
[Link]("Client connected");
InputStreamReader in=new InputStreamReader([Link]());
BufferedReader bf=new BufferedReader(in);
String str=[Link]();
[Link]("Client:"+str);
PrintWriter pr= new PrintWriter([Link]());
[Link]("hello");
[Link]();
[Link]
import [Link].*;
import [Link].*;
public class client
public static void main(String args[])throws IOException
Socket s=new Socket("localhost",4999);
PrintWriter pr= new PrintWriter([Link]());
[Link]("hello");
[Link]();
InputStreamReader in=new InputStreamReader([Link]());
BufferedReader bf=new BufferedReader(in);
String str=[Link]();
[Link]("Server:"+str);
OUTPUT
RESULT
Thus the above program is executed and the output is verified successfully.