i p programing lab
TRANSCRIPT
-
8/3/2019 i p Programing Lab
1/75
LAYOUT
import java.applet.*;
import java.awt.*;import java.awt.event.*;
/* */
public class layout extends Applet{
Panel[] p1;
Panel p2;static int border=0;
static int card=1;
static int flow=2;
static int grid=3;
static int gridBag=4;String[] l={"Border","Card","Flow","Grid","GridBag"};
String[] c={"First","Last","Next","Previous"};Button[] lb=new Button[l.length];
Button[] nb=new Button[c.length];
Panel lbp=new Panel();Panel nbp=new Panel();
public void init()
{
setLayout(new BorderLayout());setupButtons();
add("North",lbp);setupDisplayPanels();}
void setupButtons()
{for(int i=0;i
-
8/3/2019 i p Programing Lab
2/75
{
p1=new Panel[5];
for(int i=0;i
-
8/3/2019 i p Programing Lab
3/75
void switchPanels(Panel newPanel,boolean setNavigateButtons)
{
remove(p2);p2=newPanel;
add("Center",p2);
remove(nbp);if(setNavigateButtons)
add("South",nbp);
validate();}
class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent ev){
String s=ev.getActionCommand();
if(s.equals("Border"))
switchPanels(p1[border],false);else if(s.equals("Card"))
switchPanels(p1[card],true);else if(s.equals("Flow"))
switchPanels(p1[flow],false);
else if(s.equals("Grid"))
switchPanels(p1[grid],false);else if(s.equals("GridBag"))
switchPanels(p1[gridBag],false);
else if(s.equals("First")){
CardLayout cl=(CardLayout)p2.getLayout();
cl.first(p2);}
else if(s.equals("Last"))
{CardLayout cl=(CardLayout)p2.getLayout();
cl.last(p2);
}
else if(s.equals("Next")){
CardLayout cl=(CardLayout)p2.getLayout();
cl.next(p2);}
else if(s.equals("Previous"))
{CardLayout cl=(CardLayout)p2.getLayout();
cl.previous(p2);
}}}}
-
8/3/2019 i p Programing Lab
4/75
OUTPUT:
-
8/3/2019 i p Programing Lab
5/75
-
8/3/2019 i p Programing Lab
6/75
-
8/3/2019 i p Programing Lab
7/75
AWT CONTROLS
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
*/
public class awt extends Applet implements ActionListener,ItemListener,TextListener
{
Label l1,l2,l3,l4,l5,l6;
Checkbox c1,c2,c3;
TextField t1;
List li1,li2,li3;
Choice c;
Button b1,b2;
TextArea t;
public void init()
{
setLayout(null);
l1=new Label("CUSTOMER NAME:");
l1.setBounds(100,20,100,20);
add(l1);
t1=new TextField(60);
t1.setBounds(300,20,200,20);
-
8/3/2019 i p Programing Lab
8/75
t1.addTextListener(this);
add(t1);
l2=new Label("TYPES OF BOOKS:");
l2.setBounds(100,80,120,20);
add(l2);
c1=new Checkbox("NOVEL");
c1.setBounds(300,70,140,20);
c1.addItemListener(this);
add(c1);
c2=new Checkbox("MAGAZINES");
c2.setBounds(300,100,140,20);
c2.addItemListener(this);
add(c2);
c3=new Checkbox("SOFTWARE BOOKS");
c3.setBounds(500,70,140,26);
c3.addItemListener(this);
add(c3);
l3=new Label("NOVEL");
l3.setBounds(200,140,100,20);
li1=new List();
li1.add("Oliver Twist");
li1.add("Harry Porter");
li1.add("Raja deysingh");
li1.setBounds(200,170,150,60);
li1.addItemListener(this);
-
8/3/2019 i p Programing Lab
9/75
l4=new Label("MAGAZINES");
l4.setBounds(400,140,100,20);
li2=new List();
li2.add("india today");
li2.add("Success competition");
li2.add("competition refreshers");
li2.setBounds(400,170,150,60);
li2.addItemListener(this);
l6=new Label("SOFTWARE BOOKS");
l6.setBounds(600,140,100,20);
li3=new List();
li3.add("JAVA");
li3.add("C");
li3.add("C++");
li3.setBounds(600,170,100,50);
li3.addItemListener(this);
l5=new Label("DURATION");
l5.setBounds(100,240,150,20);
add(l5);
c=new Choice();
c.add("1 Week");
c.add("3 Week");
c.add("Month");
c.setBounds(300,240,100,20);
c.addItemListener(this);
-
8/3/2019 i p Programing Lab
10/75
add(c);
b1=new Button("SUBMIT");
b1.addActionListener(this);
b1.setBounds(300,300,100,20);
add(b1);
b2=new Button("RESET");
b2.addActionListener(this);
b2.setBounds(400,330,100,20);
add(b2);
t=new TextArea();
t.setBounds(200,330,300,100);
t.addTextListener(this);
add(t);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
String s="CUSTOMER NAME:";
s+=t1.getText();
s+="\n";
s+="TYPE OF BOOKS:";
s+="\n\t";
s+=li1.getSelectedItem();
s+="\n\t";
-
8/3/2019 i p Programing Lab
11/75
s+=li2.getSelectedItem();
s+="\n\t";
s+=li3.getSelectedItem();
s+="\nDURATION:";
s+=c.getSelectedItem();
t.setText(s);
}
if(ae.getSource()==b2)
{
t1.setText(null);
li1.setVisible(false);
li2.setVisible(false);
li3.setVisible(false);
t.setText(null);
if(c1.getState()==true)
{
c1.setState(false);
}
if(c2.getState()==true);
{
c2.setState(false);
}
if(c3.getState()==true)
{
c3.setState(false);
-
8/3/2019 i p Programing Lab
12/75
}
}
}
public void textValueChanged(TextEvent te)
{}
public void itemStateChanged(ItemEvent ie)
{
if(ie.getSource()==c1)
{
if(c1.getState()==true)
{
add(l3);
l3.setVisible(true);
add(li1);
li1.setVisible(true);
}
else
{
l3.setVisible(false);
li1.setVisible(false);
}
}
if(ie.getSource()==c2)
{
if(c1.getState()==true)
-
8/3/2019 i p Programing Lab
13/75
{
add(l4);
l4.setVisible(true);
add(li2);
li2.setVisible(true);
}
else
{
l4.setVisible(false);
li2.setVisible(false);
}
}
if(ie.getSource()==c3)
{
if(c3.getState()==true)
{
add(l6);
l6.setVisible(true);
add(li3);
li3.setVisible(true);
}
else
{
l6.setVisible(false);
li3.setVisible(false);
-
8/3/2019 i p Programing Lab
14/75
}
}
}
}
OUTPUT:
-
8/3/2019 i p Programing Lab
15/75
CHAT APPLICATION
-
8/3/2019 i p Programing Lab
16/75
CHAT CLIENT:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
/**/
public class chatclient extends Applet implements ActionListener,KeyListener,Runnable
{
String buffer,clear,str;
TextArea text1,text2;
Button send,exit;
byte ns[];
byte bs[];
byte br[];
int key,input;
DatagramSocket clientSocket1=null;
DatagramSocket clientSocket2=null;
DatagramPacket dpr;
DatagramPacket dps;
Thread t;
public void init(){
setLayout(null);
text1=new TextArea(buffer,10,40);
text2=new TextArea(buffer,5,40);
-
8/3/2019 i p Programing Lab
17/75
send=new Button("send");
exit=new Button("exit");
text1.setBounds(5,5,300,300);
text2.setBounds(5,310,300,150);
send.setBounds(310,310,50,50);
exit.setBounds(310,370,50,50);
exit.addActionListener(this);
send.addActionListener(this);
text1.addKeyListener(this);
text2.addKeyListener(this);
add(text1);
add(text2);
add(send);
add(exit);
try
{
clientSocket1=new DatagramSocket();
}
catch(Exception e)
{}
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==send)
{
t.suspend();
buffer=text2.getText();
-
8/3/2019 i p Programing Lab
18/75
text2.setText(clear);
text1.append("\n client:"+buffer);
try
{
bs=new byte[250];
bs=buffer.getBytes();
dps=new DatagramPacket(bs,bs.length,InetAddress.getLocalHost(),2000);
clientSocket1.send(dps);
}
catch(Exception ex)
{}
t.resume();
}
if(ae.getSource()==exit)
{
System.exit(0);
}}
public void keyPressed(KeyEvent ke)
{
key=ke.getKeyCode();
if(key==KeyEvent.VK_ENTER)
{
t.suspend();
buffer=text2.getText();
text2.setText(clear);
text1.append("\n client:"+buffer);
try
-
8/3/2019 i p Programing Lab
19/75
{
bs=new byte[250];
bs=buffer.getBytes();
dps=new DatagramPacket(bs,bs.length,InetAddress.getLocalHost(),2200);
clientSocket1.send(dps);
}
catch(Exception ex)
{}
t.resume();
}}
public void keyReleased(KeyEvent ke)
{
showStatus("the user is idle");
}
public void keyTyped(KeyEvent ke)
{
showStatus("the user is typing");
}
public void start()
{
t=new Thread(this);
t.start();
}
public void run()
{
try
{
-
8/3/2019 i p Programing Lab
20/75
System.out.println("thread");
while(true)
{
br=new byte[300];
dpr=new DatagramPacket(br,br.length);
clientSocket1.receive(dpr);
str=new String(br);
text1.append("\n server:"+str);
System.out.println("thread received");
}
}
catch(Exception e)
{}
}
}
-
8/3/2019 i p Programing Lab
21/75
CHAT SERVER:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
/**/
public class chatserver extends Applet implements ActionListener,KeyListener,Runnable
{
String buffer,clear,str;
TextArea text1,text2;
Button send,exit;
byte bs[];
byte br[];
int key,input;
DatagramSocket clientSocket2=null;
DatagramPacket dpr;
DatagramPacket dps;
Thread t;
int port;
public void init()
{
setLayout(null);
-
8/3/2019 i p Programing Lab
22/75
text1=new TextArea(buffer,10,40);
text2=new TextArea(buffer,5,40);
send=new Button("send");
exit=new Button("exit");
text1.setBounds(5,5,300,300);
text2.setBounds(5,310,300,150);
send.setBounds(310,310,50,50);
exit.setBounds(310,370,50,50);
exit.addActionListener(this);
send.addActionListener(this);
text1.addKeyListener(this);
text2.addKeyListener(this);
add(text1);
add(text2);
add(send);
add(exit);
try
{
clientSocket2=new DatagramSocket(2000);
}
catch(Exception e)
{}
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==send)
{
-
8/3/2019 i p Programing Lab
23/75
t.suspend();
buffer=text2.getText();
text2.setText(clear);
text1.append("\n server:"+buffer);
try
{
bs=new byte[250];
bs=buffer.getBytes();
dps=new DatagramPacket(bs,bs.length,InetAddress.getLocalHost(),port);
clientSocket2.send(dps);
}
catch(Exception ex)
{}
t.resume();
}
if(ae.getSource()==exit)
{
System.exit(0);
}}
public void keyPressed(KeyEvent ke)
{
key=ke.getKeyCode();
if(key==KeyEvent.VK_ENTER)
{
t.suspend();
buffer=text2.getText();
text2.setText(clear);
-
8/3/2019 i p Programing Lab
24/75
text1.append("\n server:"+buffer);
try
{
bs=new byte[250];
bs=buffer.getBytes();
dps=new DatagramPacket(bs,bs.length,InetAddress.getLocalHost(),port);
clientSocket2.send(dps);
}
catch(Exception ex)
{}
t.resume();
}}
public void keyReleased(KeyEvent ke)
{
showStatus("the user is idle");
}
public void keyTyped(KeyEvent ke)
{
showStatus("the user is typing");
}
public void start()
{
t=new Thread(this);
t.start();
}
public void run()
{
-
8/3/2019 i p Programing Lab
25/75
try
{
while(true)
{
br=new byte[300];
dpr=new DatagramPacket(br,br.length);
clientSocket2.receive(dpr);
port=dpr.getPort();
str=new String(br);
text1.append("\n server:"+str);
}
}
catch(Exception e)
{}
}
public void stop()
{
try
{
clientSocket2.close();
}
catch(Exception ex)
{}
}
}
-
8/3/2019 i p Programing Lab
26/75
OUTPUT:
-
8/3/2019 i p Programing Lab
27/75
-
8/3/2019 i p Programing Lab
28/75
String colours[]={"Red","Blue","Green","Yellow","Magenta"};
Image img;
CheckboxGroup cbg=new CheckboxGroup();
Checkbox box1=new Checkbox("Background Color",cbg,true);
Checkbox box2=new Checkbox("Text Color",cbg,false);
Checkbox box3=new Checkbox("Loading Image",cbg,false);
public void init()
{
for(int i=0;i
-
8/3/2019 i p Programing Lab
29/75
if(box1.getState()==true)
flag=1;
else if(box2.getState()==true)
{
text="Default color is black";
flag=2;
}
else if(box3.getState()==true)
{
img=getImage(getDocumentBase(),"Sunset.jpg");
flag=3;
}
repaint();
}
public void paint(Graphics g)
{
if(flag==2)
{
g.drawString(text,30,100);
switch(currcolor)
{
case 0:
g.setColor(Color.red);
break;
case 1:
g.setColor(Color.blue);
break;
-
8/3/2019 i p Programing Lab
30/75
case 2:
g.setColor(Color.green);
break;
case 3:
g.setColor(Color.yellow);
break;
case 4:
g.setColor(Color.magenta);
break;
case 5:
g.setColor(Color.black);
break;
}
g.drawString(text,30,100);
}
else if(flag==1)
{
g.drawString(text,30,100);
switch(currcolor)
{
case 0:
setBackground(Color.red);
break;
case 1:
setBackground(Color.blue);
break;
case 2:
-
8/3/2019 i p Programing Lab
31/75
setBackground(Color.green);
break;
case 3:
setBackground(Color.yellow);
break;
case 4:
setBackground(Color.magenta);
break;
case 5:
setBackground(Color.white);
break;
}
}
else if(flag==3)
{
g.drawImage(img,20,90,this);
}
}
public boolean action(Event e,Object o)
{
for(int i=0;i
-
8/3/2019 i p Programing Lab
32/75
return true;
}
}
return false;
}
}
OUTPUT:
-
8/3/2019 i p Programing Lab
33/75
-
8/3/2019 i p Programing Lab
34/75
WEBPAGE CREATION
COLLEGE WEBSITE
COLLEGE.HTML
AARUPADAI VEEDU INSTITUTE OF TECHNOLOGY
about
sports
academic
hostel
INFORMATION.HTML
about
-
8/3/2019 i p Programing Lab
35/75
ABOUT OUR COLLEGE
Aarupadai Veedu Institute Of Technology Engg. Collegewas started at the year 2001
At first it was started with onlythreeDeaprtments.
Because of its good administration one more department be included within next year itself.
Now it has four departments.
FOUR DEPARTMENTS ARE:
CSE DEPARTMENT
ECE DEPARTMENT
EEE DEPARTMENT
IT DEPARTMENT
ACADEMIC.HTML
-
8/3/2019 i p Programing Lab
36/75
academic
ACADEMIC COURCES
Courses available in our college are:
Computer Science & Engineering
Electronic & Communication Engineering
Electrical & Electronics Engineering
Information & Technology
SPORTS.HTML
sports
SPORTS
AVITEChas several facilities for sports.
-
8/3/2019 i p Programing Lab
37/75
They try to involve their students to participate in the inter_college competitions.
NCC & NSS camps are also available.
In college campus itself they are allowing to practising all
indoor & outdoorgames.
HOSTEL.HTML
hostel
HOSTEL FACILITIES
The college hostel is separated into Girl's HostelandBoy's Hostel.
Girl's Hostel is situated at PaiyanoornearMahabalipuram
It is a Working Women's Hostel.Many Facilities are available.
A swimming pool is also available.
Facilities like:
-
8/3/2019 i p Programing Lab
38/75
Browsing center,Bus facility,Medical Camp,Coaching center,etc.
Boy's Hostel is situated in the college campus itself.
Here also lots of facilities are available.
-
8/3/2019 i p Programing Lab
39/75
OUTPUT:
-
8/3/2019 i p Programing Lab
40/75
WEBPAGE CREATION
IMAGE MAP
IMAGE.HTML:-
iimage
INDIA MAP
delhi
kolkata
mumbai
-
8/3/2019 i p Programing Lab
41/75
chennai
DELHI.HTML
delhi
DELHI
In Delhi lots of place is there to visit.
Most of the places are so attractive.
Once we visit the place, we wish to visit it aagain there every summer holidays.
One of the place is Taj Mahal
-
8/3/2019 i p Programing Lab
42/75
kolkata
KOLKATA
Kolkata is the capital of
-
8/3/2019 i p Programing Lab
43/75
Mumbai is one of thedevelopd city in India.
CHENNAI.HTML
chennai
CHENNAI
Chennai is the busiest city.
Here lots of shopping complex are available.
EEveryday there be a lots of people come for Shopping.
Moreover employment is large in chennai.
Nowadays the eeeflat systems are improved in Chennai.
Here also lot of place for visiting.
for.eg.
Museum,
marina beach,
basin nagar beach,etc.,
-
8/3/2019 i p Programing Lab
44/75
OUTPUT:
-
8/3/2019 i p Programing Lab
45/75
-
8/3/2019 i p Programing Lab
46/75
CASCADING STYLE SHEETS
EARTHQUAKE.HTML
earthquake
EARTHQUAKE-EXTERNAL
The earthquake occurs due to the rubbing of one rock over the another rock.
The earthquake is off different speed, direction, strength,etc.
It consists of several layers and each layer moves in different way.
Primary layer flows in length wise.
Secondary layer flows cross wise.
Next layer flows around that particular area.
This can be measured using ritcher scale.
Actually in that instrument a chart be present.
-
8/3/2019 i p Programing Lab
47/75
This instrument befixed rigidlyon the ground and so whenever the earthquake occurs it never
distracted and measure accurately.
A.CSS
body
{
background:000000;
font size:14;
color:999000;
}
H1
{
text-align:center;
color:555566;
}
#one
{
color:ff00ff;
font size: 15;
}
#two
{
font size: 11;
color:0088ff;
-
8/3/2019 i p Programing Lab
48/75
}
ul
{
font size:13;
font-family:Comic Sans MS;
}
i
{
color:ff00ff;
}
EARTHQUAKE1.HTML:-
Eartquake1
body
{
background:green;
font-size:18;
color:black;
}
H1
{
text-align:center;
color:555566;
}
-
8/3/2019 i p Programing Lab
49/75
#one
{
color:ff00ff;
font-size:15;
}
#two
{
font-size:11;
color:0088ff;
}
ul
{
font size 13;
font-family: Comic Sans MS;
}
i
{
color:ff00ff;
}
The earthquake occurs due to the rubbibng of one rock over the onother rock.
The earthquake is off different sprrd, direction,strength,etc;
-
8/3/2019 i p Programing Lab
50/75
It consist of several layers and each layer moves in differnet way.
Primary layer flows in length wise.
Secondary layer flows across wise.
Next layer flows around that particular area.
This can be measured using ritcher scale.
Actually in that instrument a chart be present.
This instrument be fixed rigidlyon the ground and so whenever the earthquake occurs it never
distracted and measure accirately.
EARTHQUAKE2.HTML:-
earthquake
EARTHQUAKE-INLINE
-
8/3/2019 i p Programing Lab
51/75
The earthquake occurs due to the rubbing of one rock over the another rock.
The earthquake is off different speed, direction, strength,etc.
It consists of several layers and each layer moves in different way.
Primary layer flows in length wise.
Secondary layer flows cross wise.
Next layer flows around that particular area.
This can be measured using ritcher scale.
Actually in that instrument a chart be present.
This instrument befixed rigidlyon the ground and so whenever the earthquake occurs it never
distracted and measure accurately.
-
8/3/2019 i p Programing Lab
52/75
OUTPUT:
-
8/3/2019 i p Programing Lab
53/75
WEBPAGE CONTENT RETRIVAL USING URL
Program:-
import java.net.*;
import java.io.*;
import java.util.Date;
class url
{
public static void main(String args[])throws Exception
{
int ch;
URL handle=new URL("http://www.google.com");
URLConnection handle_connection=handle.openConnection();
-
8/3/2019 i p Programing Lab
54/75
long date_info;
int length,i;
date_info=handle_connection.getDate();
System.out.println("Date:"+new Date(date_info));
System.out.println("Content-Type:"+handle_connection.getContentType());
length=handle_connection.getContentLength();
System.out.println("Content length:"+length);
if(length!=0)
{
System.out.println("\n\t*** Contents of web page are ****");
InputStream input_string=handle_connection.getInputStream();
while((ch=input_string.read())!=-1)
{
System.out.println((char)ch);
}
input_string.close();
}
else
{
System.out.println("There are no Content for this site");
}
}
}
-
8/3/2019 i p Programing Lab
55/75
OUTPUT:
Date:Thu Jan 01 00:00:00 GMT+05:30 1970
Content-Type:null
Content length:-1
*** Contents of web page are ****
java.net.UnknownHostException: www.google.com
-
8/3/2019 i p Programing Lab
56/75
at java.net.InetAddress.getAllByName0(InetAddress.java:479)
at java.net.InetAddress.getByName(InetAddress.java:355)
at java.net.Socket.(Socket.java:97)
at sun.net.NetworkClient.doConnect(NetworkClient.java:62)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:267)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:329)
at sun.net.www.http.HttpClient.(HttpClient.java:210)
at sun.net.www.http.HttpClient.(HttpClient.java:218)
at sun.net.www.http.HttpClient.New(HttpClient.java:229)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
.java:235)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:315)
at Get_Web_Page.main(Get_Web_Page.java:21)
C:\JDK11~1.3\bin>
-
8/3/2019 i p Programing Lab
57/75
SOCKETS- HTTP REQUEST
import java.io.*;
import java.net.*;
public class HTTP_Request
{
public static void main(String args[]) throws Exception
{
try
{
String Request="www.google.com";
Socket client_Socket=new Socket(Request,80);
System.out.println("The client is \n"+client_Socket);
Get_Web_Page(client_Socket);
}
catch(UnknownHostException e)
{
System.err.println("UnknownHostException:"+e.getMessage());
-
8/3/2019 i p Programing Lab
58/75
}
catch(IOException e)
{
System.err.println("IOException:" +e.getMessage());
}
}
public static void Get_Web_Page(Socket client_Socket)
{
try
{
DataOutputStream output=new DataOutputStream(client_Socket.getOutputStream());
DataInputStream input=new DataInputStream(client_Socket.getInputStream());
output.writeBytes("GET/HTTP/1.0\r\n\r\n");
String input_txt;
while((input_txt=input.readLine())!=null)
{
System.out.println(input_txt);
if(input_txt.indexOf("")!=-1)
break;
}
output.close();
input.close();
client_Socket.close();
}
catch(Exception e)
{
System.err.println("Exception:"+e.getMessage());
-
8/3/2019 i p Programing Lab
59/75
}}}
OUTPUT:
The client is
Socket[addr=www.google.com/209.85.231.104,port=80,localport=3788]
HTTP/1.0 400 Bad Request
Content-Type: text/html; charset=UTF-8
Content-Length: 1350
Date: Fri, 01 Oct 2010 13:30:25 GMT
Server: GFE/2.0
400 Bad Request
-
8/3/2019 i p Programing Lab
60/75
var rc=400;
//-->
Google
Error
Bad Request
Your client has issued a malformed or illegal request.
-
8/3/2019 i p Programing Lab
61/75
-
8/3/2019 i p Programing Lab
62/75
STUDENT MARK LIST
/*student.java*/
import java.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class student extends HttpServlet
{
int m1,m2,m3.n1;
String s1;
Connection cn;
Statement st;
public void init(ServletConfig c)throws ServletException
{
try
-
8/3/2019 i p Programing Lab
63/75
{
Class.forName("sun.jdbc.odbcDriver");
st=cn.createStatement();
System.out.println("try");
}
catch(Exception e)
{
System.out.println("e");
}
public void doGet(HttpServletRequest req,HttpServletResponse rs)tthrows
ServletException,IOException
{
try
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String e=req.getParameter("t1");
int i=Integer.println(e);
System.out.println("s");
ResultSet re=st.executeQuery("select*from std where id="+i+"");
while(re.next(());
{
s1=re.getString(1);
n1=re.getInt(2);
m1=re.getInt(3);
m2=re.getInt(4);
-
8/3/2019 i p Programing Lab
64/75
m3=re.getInt(5);
}
out.println("Student marklist");
out.println("");
out.println("STUDENT MARKSHEET");
System.out.println("hjhfdhfds");
out.println("
");out.println("NAME:"+S1);
out.println("reg no:"+n1);
out.println("maths:"+m2);
out.println("chemistry:"+m3);
out.println("");
out.println("");
out.println("");
out.println("");
}
catch(Exception e)
{
System.out.println(e);
}
}
}
/* student.html*/
-
8/3/2019 i p Programing Lab
65/75
stud
STUDENT MARKLIST
ID
-
8/3/2019 i p Programing Lab
66/75
OUTPUT:
-
8/3/2019 i p Programing Lab
67/75
-
8/3/2019 i p Programing Lab
68/75
ONLINE EXAMINATION
/*online.java*/
import javax.servlet.http.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class online extends HttpServlet
{
int total;
-
8/3/2019 i p Programing Lab
69/75
Connection cn;
Statement st;
public oid init(ServerConfig c)throws ServletException
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbc:dbonline");
cn=DriverManager.getConnection("jdbc:odbc:dbonline")
st=cn.createStatement();
System.out.println("try");
}
catch(exception e)
{
System.out.println("e");
}
}
public void doGet(HttpServletRequest reg,HttpServerResponse res)throws
ServerException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String ans[]=new String[4];
String answer[]=new String[4];
ans[0]=req.getParameter("q1");
ans[1]=req.getParameter("q2");
ans[2]=req.getParameter("q3");
-
8/3/2019 i p Programing Lab
70/75
int n=0;
try
{
ResultSet re=st.executeQuery("select * from questions");
n=0;
while(re.next())
{
answer[n]=re.getString(2);
n++;
}
}
catch(Exception e) {
}
total=0;
for(int i=0;i
-
8/3/2019 i p Programing Lab
71/75
if(answer[i].equals(ans[i]))
out.println(""+e+">correct
");else
{
out.println(""+e+">Wronganswer
");out.println(
The correct answer is:"+answer[i]+"
");}
e++;
}
System.out.println("hjhfdhfds");
out.println("");
}
}
/* online.html*/
online
ONLINE EXAMINATION
I>Feature not supported by java
-
8/3/2019 i p Programing Lab
72/75
pointer  
inheritance  
objects  
2>platform Independent language
java  
c  
c++  
3>Automated object desructors in java
destructor  
constructor  
Garbage collector  
-
8/3/2019 i p Programing Lab
73/75
OUTPUT:
-
8/3/2019 i p Programing Lab
74/75
-
8/3/2019 i p Programing Lab
75/75