Вы находитесь на странице: 1из 44

TYBCA SLIPS - 25 Marks 2016

Slip 1 : Write a JSP script to accept username, store it into the session, compare it with
password in another jsp file, if username matches with password then display appropriate
message in html file.

Slip1_checklogin.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!DOCTYPE html>

<%

String username = request.getParameter("username");


String password = request.getParameter("password");
out.println("Checking login<br>");
if (username == null || password == null) {

out.print("Invalid paramters ");


}

// Here you put the check on the username and password


if (username.toLowerCase().trim().equals("admin")&&
password.toLowerCase().trim().equals("admin")) {
out.println("Welcome " + username + " <a href=\"Slip1.jsp\">Back to main</a>");
session.setAttribute("username", username);
}
else
{
out.println("Invalid username and password");
}

%>

Slip1.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE>Login using jsp</TITLE>
</HEAD>

<BODY>
<H1>LOGIN FORM</H1>

<%

String myname = (String)session.getAttribute("username");

if(myname!=null)
{

NR CLASSES, PUNE (8796064387/90)


out.println("Welcome "+myname+" , <a href=\"Slip1_logout.jsp\" >Logout</a>");
}
else
{
%>
<form action="Slip1_checkLogin.jsp">
<table>
<tr>
<td> Username : </td><td><input name="username" size=15 type="text"
/></td>
</tr>
<tr>
<td> Password : </td><td><input name="password" size=15
type="password" /></td>
</tr>
</table>
<input type="submit" value="login" />
</form>
<%
}

%>

</BODY>
</HTML>

Slip1_logout.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!DOCTYPE html>

<%

String username=(String)session.getAttribute("username");
if(username!=null)
{
out.println(username+" loged out, <a href=\"Slip1.jsp\">Back</a>");
session.removeAttribute("username");

}
else
{
out.println("You are already not login <a href=\"Slip1.jsp\">Back</a>");
}

%>

SLIP 2 :
Write a servlet which counts how many times a user has visited a web page. If the user is
visiting the page for the first time, display a welcome message. If the user is revisiting the
page, display the number of times visited. (Use cookies)

NR CLASSES, PUNE (8796064387/90)


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HitCount extends HttpServlet


{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Cookie c[]=request.getCookies();
if(c==null)
{ Cookie cookie = new Cookie("count","1");
response.addCookie(cookie);
out.println("<h3>Welcome Servlet<h3>"+ "Hit Count:<b>1</b>"); }
else
{
int val=Integer.parseInt(c[0].getValue())+1;
c[0].setValue(Integer.toString(val));
response.addCookie(c[0]);
out.println("Hit Count:<b>"+val+"</b>");
}
}
}

Slip 3 :Write a java program to simulate traffic signal using multithreading.

Slip3_2.java

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

class Slip3_2 extends Applet implements Runnable


{
Thread t;
int r,g1,y,i;
public void init()
{
T=new Thread(this);
t.start();
r=0; g1=0;I=0; y=0;
}
public void run()
{
try
{
for(I =24; I >=1;i--)
{
if (I >16&& I <=24)
{
t.sleep(200);
r=1;

NR CLASSES, PUNE (8796064387/90)


repaint();
}
if (I >8&& I <=16)
{
t.sleep(200);
y=1;
repaint();
}
if(I >1&& I <=8)
{
t.sleep(200);
g1=1;
repaint();
}
}
if (I ==0)
{
run();
}
}
catch(Exception e)
{ System.out.println(e);
}
}

public void paint(Graphics g)


{
g.drawRect(100,100,100,300);
if (r==1)
{
g.setColor(Color.red);
g.fillOval(100,100,100,100);
g.setColor(Color.black);
g.drawOval(100,200,100,100);
g.drawOval(100,300,100,100);
r=0;
}
if (y==1)
{
g.setColor(Color.black);
g.drawOval(100,100,100,100);
g.drawOval(100,300,100,100);
g.setColor(Color.yellow);
g.fillOval(100,200,100,100);
y=0;
}
if (g1==1)
{
g.setColor(Color.black);
g.drawOval(100,100,100,100);
g.drawOval(100,200,100,100);
g.setColor(Color.green);
g.fillOval(100,300,100,100);
g1=0;
}

NR CLASSES, PUNE (8796064387/90)


}
}

Slip 4 : Write a JSP program to create a shopping mall. User must be allowed to do
purchase from two pages. Each page should have a page total. The third page should
display a bill, which consists of a page total of whatever the purchase has been done and
print the total.

Slip4_first.jsp

<%@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>
<form action="Slip4_Second.jsp" method="post">
<h1>Shopping Mall</h1>

Rice :
<select name="rice">
<option value="2">2 Kg</option>
<option value="5">5 Kg</option>
<option value="10">10 Kg</option>
<option value="15">15 Kg</option>
</select>

Wheat :
<select name="wheat">
<option value="2">2 Kg</option>
<option value="5">5 Kg</option>
<option value="10">10 Kg</option>
<option value="15">15 Kg</option>
</select>
<input type="submit" value="Submit">
</form>
</body>
</html>

Slip4_Second.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!DOCTYPE html>

<%
String rice = request.getParameter("rice");
int r = Integer.parseInt(rice);

String wheat = request.getParameter("wheat");


int w = Integer.parseInt(wheat);

NR CLASSES, PUNE (8796064387/90)


int tr = r * 40;
int wt = w * 60;
int pt = tr + wt;

session.setAttribute("first_Total", pt);
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Shopping Mall</h1>
<form action="Slip4_Third.jsp" method="post">
Maggi :
<select name="maggi">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>

Good Day :
<select name="good">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>

<input type="submit" value="Submit">


</form>
</body>
</html>

Slip4_Third.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!DOCTYPE html>

<%
String m = request.getParameter("maggi");
String g = request.getParameter("good");

int mp = Integer.parseInt(m);
int gp = Integer.parseInt(g);

int mpt = mp * 10;


int gpt = gp * 10;

int secont_total = mpt + gpt;


int first_Total = (Integer)request.getSession().getAttribute("first_Total");

NR CLASSES, PUNE (8796064387/90)


int grand_Total = first_Total + secont_total;
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Shopping Mall</h1>

<h1>First Page Total <%=first_Total%></h1><br>


<h1>Second Page Total <%=secont_total%></h1><br>
<h1>Total Bill<%=grand_Total%></h1><br>

</body>
</html>

Slip 5 : Write a MultiThreading program in java using Runnable interface to draw temple flag
on an applet container.

Slip5_2.java

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

public class Slip5_2 extends Applet implements Runnable


{
Thread t;
int x1,x2,x3,y3,x4,y4,x5,ln;
public void init()
{
t =new Thread(this);
t.start();
ln=1;
}
public void run()
{
try
{ if(ln==1)
{ for(x1=200;x1>100;)
{
t.sleep(200);
repaint();
}
}
ln=2;
if(ln==2)
{ for(x2=100;x2<150;)
{
t.sleep(200);
repaint();

NR CLASSES, PUNE (8796064387/90)


}
}
ln=3;
if(ln==3)
{ for(x3=150,y3=100;x3>125&&y3<125;)
{
t.sleep(200);
repaint();
}
}
ln=4;
if(ln==4)
{ for(x4=125,y4=125;x4<150&&y4<150;)
{
t.sleep(200);
repaint();
}
}
ln=5;
if(ln==5)
{ for(x5=150;x5>100;)
{
t.sleep(200);
repaint();
}
}
ln=1;
}
catch(Exception e)
{ System.out.println(e);

}
run();
}
public void paint(Graphics g)
{
if(ln==1&&x1>100)
{
g.drawLine(100,200,100,x1-=5);
}
if(ln==2&&x2<150)
{
g.drawLine(100,200,100,100);
g.drawLine(100,100,x2+=5,100);
}
if(ln==3&&x3>125&&y3<125)
{
g.drawLine(100,200,100,100);
g.drawLine(100,100,150,100);
g.drawLine(150,100,x3-=5,y3+=5);
}
if(ln==4&&x4<150&&y4<150)
{
g.drawLine(100,200,100,100);
g.drawLine(100,100,150,100);

NR CLASSES, PUNE (8796064387/90)


g.drawLine(150,100,125,125);
g.drawLine(125,125,x4+=5,y4+=5);
}
if(ln==5&&x5>100)
{
g.drawLine(100,200,100,100);
g.drawLine(100,100,150,100);
g.drawLine(150,100,125,125);
g.drawLine(125,125,150,150);
g.drawLine(150,150,x5-=5,150);
}
}
}

Slip 6 : Write a socket program in java to check whether given file is present on server or
not, If it present then display its content on the server’s machine.

S_Slip6_2.java

import java.io.*;
import java.net.*;

class S_Slip6_2
{
public static void main(String a[]) throws Exception
{
ServerSocket ss = new ServerSocket(1000);
System.out.println("Server is waiting for client : ");
Socket s =ss.accept();
System.out.println("Client is connected");
DataInputStream dis=new DataInputStream(s.getInputStream());
DataOutputStream dos=new DataOutputStream(s.getOutputStream());

String fname =(String)dis.readUTF();


File f = new File(fname);
if(f.exists())
{
System.out.println("file is exists");
FileInputStream fin = new FileInputStream(fname);
int ch;
String msg = "";
while((ch=fin.read())!=-1)
{
msg=msg+(char)ch;
}
dos.writeUTF(msg);
}
else
dos.writeUTF("0");
}
}

C_Slip6_2.java

NR CLASSES, PUNE (8796064387/90)


import java.io.*;
import java.net.*;

class C_Slip6_2
{
public static void main(String a[]) throws Exception
{
Socket s = new Socket("localhost",1000);
System.out.println("client is connected : ");
DataInputStream dis=new DataInputStream(s.getInputStream());
DataOutputStream dos=new DataOutputStream(s.getOutputStream());

BufferedReader br = new BufferedReader(new


InputStreamReader(System.in));
System.out.println("Enter file name : ");
String fname = br.readLine();
dos.writeUTF(fname);

String msg = (String)dis.readUTF();


if(msg.equals("0"))
System.out.println("File not present ");
else
{
System.out.println("Content of the file is : \n");
System.out.println(msg);
}
}
}

Slip 7 : Write a multithreading application in java for racing car.

Slip7_2.java

import java.awt.*;
import java.util.*;
import java.applet.*;

//The basic applet class.The applet shows 4 cars crossing each other at a square.
class Slip7_2 extends Applet implements Runnable
{
Thread t;
//4 variables used to vary the car's positions.
int x1=0,x2=380,y1=50,y2=250;
public void start()
{
if(t==null)
{
t =new Thread(this,"New Thread");//New side Thread created on start
of applet.
t.start();
}
}

NR CLASSES, PUNE (8796064387/90)


public void stop()
{
if(t!=null)
{
t =null;//On stop of applet the created thread is destroyed.
}
}
//Implementation of method run() of Runnable interface.
public void run()
{
Thread t1=Thread.currentThread();
while(t==t1)
{
repaint();
try
{
Thread.sleep(100);
}
catch(Exception e)
{ }
}
}
public void paint(Graphics g)
{
setBackground(Color.cyan);
g.setColor(Color.BLACK);
x1=(x1+16)%400;
x2=x2-16;
y1=(y1+12)%300;
y2=y2-12;
if(y2<0)
y2=288;
if(x2<0)
x2=384;

//Draw the roads using 2 filled rectangles using black color.


g.fillRect(0,130,400,40);
g.fillRect(180,0,40,305);
//Draw the white colored lines.
g.setColor(Color.white);
for(int i =0; i <20;i++)
{
if(i !=9 &&i !=10)
g.drawLine(i*20,150,i*20+10,150);
}
for(int j=0;j<15;j++)
{
if(j!=7 && j!=8)
g.drawLine(200,j*20,200,j*20+10);
}
//Draw 4 colored cars using filled round rectangles.
g.setColor(Color.red);
g.fillRoundRect(x2,152,20,8,2,2);
g.fillRoundRect(x1,140,20,8,2,2);
g.fillRoundRect(190,y1,8,20,2,2);

NR CLASSES, PUNE (8796064387/90)


g.fillRoundRect(202,y2,8,20,2,2);
}
}

SLIP 8:
Write a SERVLET application to accept username and password, search them into
database,if found then display appropriate message on the browser otherwise display error
message.

HTML FILE:

<HTML>

<BODY>

<form method=get action=”Slip17.java”>

Name : <input type=”text” name=”name”>

Password : <input type=”password” name=”password”>

<input type=SUBMIT>

</BODY>

</HTML>

JAVA FILE :

import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

import java.sql.*;

public class Slip4 extends HttpServlet

public void doGet(HttpServletRequest request, HttpServletResponse response)


throws IOException, ServletException

response.setContentType(“text/html”);

PrintWriter out= res.getWriter();

NR CLASSES, PUNE (8796064387/90)


String name=req.getParmeter(“name”),msg;

String password=req.getParmeter(“password”);

Connection con=null;

Statement st=null;

ResultSet rs=null;

out.println(“<HTML>”);

out.println(“<BODY>”);

try

Class.forName(“org.postgresql.Driver”);

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection("jdbc:odbc:dsn");
if(con==null)

msg=”Connection to databse failed”;

else

st=con.createStatement();

rs=st.executeQuery(“select * from Login where name = ‘”+


name+ “’ and password=’”+password+”’”);

if(rs==null)

out.println(“No such user);

else

out.println(“Welcome: ‘”+name+”’”);

catch(Exception e) { }

out.println(“</BODY>”);

out.println(“</HTML>”);

NR CLASSES, PUNE (8796064387/90)


Slip 9 : Write a multithreading program in java using Runnable interface to move text on the
frameas follow :

Starting Postion of Text

Slip 9_2.java

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

class Slip9_2 extends Frame implements Runnable


{ Label l1;
Thread t;
int x,y,side;
Slip9_2()
{
setLayout(null);
l1=new Label(" Hello Java");
l1.setFont(new Font("",Font.BOLD,14));
l1.setForeground(Color.red);
setSize(400,400);
setVisible(true);
t=new Thread(this);
t.start();
x=5; y=200; side=1;
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{ System.exit(0); }
});
}
public void run()
{
try
{
if(side==1)
{ t.sleep(50);
l1.setBounds(x+=5,y-=5,80,15);
add(l1);
if(y==20)
side=2;
}
if(side==2)
{ t.sleep(50);
l1.setBounds(x+=5,y+=5,80,15);
add(l1);
if(y==200)

NR CLASSES, PUNE (8796064387/90)


side=3;
}
if(side==3)
{ t.sleep(50);
l1.setBounds(x-=5,y+=5,80,15);
add(l1);
if(y==390)
side=4;
}
if(side==4)
{ t.sleep(50);
l1.setBounds(x-=5,y-=5,80,15);
add(l1);
if(x==0)
{ side=1; x=0; y=200;

}
}
}
catch(Exception e)
{
System.out.println(e);
}
run();
}
public static void main(String args[])
{
new Slip9_2();
}
}

Slip 10 : Write a multithreading application in java for bouncing ball.

Slip 10_2.java

import java.awt.*;

class Slip10_2 extends java.applet.Applet implements Runnable


{
Thread t;
int f,y,f1,f2,f3;
public void init()
{
t=new Thread(this);
t.start();
f=0; y=0; f1=0;
}
public void run()
{ try
{
if (f==0)

NR CLASSES, PUNE (8796064387/90)


{ t.sleep(10);
y=y+5;
repaint();
if(f1==6)
f1=0;
}
if(f==1)
{ t.sleep(10);
y=y-5;
repaint();
if(f1==6)
f1=0;
}
}
catch(Exception e)
{System.out.println(e); }
run();
}
public void paint(Graphics g)
{
if(f==0)
{
if(f1==1)
g.setColor(Color.green);
if(f1==2)
g.setColor(Color.blue);
if(f1==3)
g.setColor(Color.red);
if(f1==4)
g.setColor(Color.yellow);
if(f1==5)
g.setColor(Color.orange);
g.fillOval(150,y+10,20,20);
if(y==400)
{
f1++; f=1;
}
}
if(f==1)
{
if(f1==1)
g.setColor(Color.green);
if(f1==2)
g.setColor(Color.blue);
if(f1==3)
g.setColor(Color.red);
if(f1==4)
g.setColor(Color.yellow);
if(f1==5)
g.setColor(Color.orange);
g.fillOval(150,y-10,20,20);
if(y==0)
{
f1++; f=0;
}

NR CLASSES, PUNE (8796064387/90)


}
}

Slip 12 :Write a JSP program to accept the details of Account (ANo, Type, Bal) and store it
into database and display it in tabular form. (Use PreparedStatement interface)

Slip12.html

<!-- To change this template, choose Tools | Templates and open the template in the editor.
-->

<!DOCTYPE html>
<html><body>
<form method=get action="Slip12.jsp">
Enter Account No. : <input type=text name=ano><br><br>
Enter Account Type:<input type=text name=type><br><br>
Enter Balance : <input type=text name=bal><br><br>
<input type=submit value="Save">
</form>
</body></html>

Slip12.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!DOCTYPE html>

<html><body>
<%@ page import="java.sql.*;" %>
<%! int ano,bal;
String type; %>
<%
ano=Integer.parseInt(request.getParameter("ano"));
type=request.getParameter("type");
bal=Integer.parseInt(request.getParameter("bal"));
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection("jdbc:odbc:acnt","","");
PreparedStatement s=cn.prepareStatement("insert into Account values(?,?,?)");
s.setInt(1,ano);
s.setString(2,type);
s.setInt(3,bal);
s.executeUpdate();
out.println("Record is saved");
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery("select * from Account");
%>
<table border="1" width="40%">
<% while(rs.next())
{
%>
<tr><td><%= rs.getInt("ano") %></td>

NR CLASSES, PUNE (8796064387/90)


<td><%= rs.getString("type") %></td>
<td><%= rs.getInt("bal") %></td>
</tr>
<%
}
cn.close();
}catch(Exception e)
{
out.println(e);
}
%>
</body></html>

Slip 13 : Write a socket program in java for simple stand alone chatting application */

S_Slip13_2.java

import java.io.*;
import java.net.*;

class S_Slip13_2
{
public static void main(String a[]) throws Exception
{
ServerSocket ss = new ServerSocket(1000);
System.out.println("Server is waiting for client : ");
Socket s =ss.accept();
System.out.println("Client is connected");
DataInputStream ios=new DataInputStream(s.getInputStream());
DataOutputStream dos=new DataOutputStream(s.getOutputStream());

BufferedReader br = new BufferedReader(new


InputStreamReader(System.in));
String s1,s2;
while(true)
{
s1 = (String)ios.readUTF();
if(s1.equals("end") || s1.equals("END"))
{
System.out.println("chatting terminated");
break;
}
System.out.println("Client "+s1);
System.out.println("Server ...");
s2 = br.readLine();
dos.writeUTF(s2);
if(s2.equals("end") || s2.equals("END"))
{
System.out.println("chatting terminated");
break;
}
}
}

NR CLASSES, PUNE (8796064387/90)


}

C_Slip13_2.java

import java.io.*;
import java.net.*;

class C_Slip13_2
{
public static void main(String a[]) throws Exception
{
Socket s = new Socket("localhost",1000);
System.out.println("client is connected : ");
DataInputStream ios=new DataInputStream(s.getInputStream());
DataOutputStream dos=new DataOutputStream(s.getOutputStream());

BufferedReader br = new BufferedReader(new


InputStreamReader(System.in));
String s1,s2;
while(true)
{
System.out.println("Server ....");
s1=br.readLine();
dos.writeUTF(s1);
s2=(String)ios.readUTF();
if(s2.equals("end") || s2.equals("END"))
{
System.out.println("chatting terminated");
break;
}
System.out.println("Client "+s2);
}
}
}

Slip 14_2 : Write a JDBC program in java to display details of Book_Sales(SalesID, Date,
Amount)
*of selected month in JTable. Book_sales table is already created. (Use JCombo
component for Month selection)

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;

class Slip14_2 extends JFrame implements ItemListener


{
JComboBox cb;

String head[]={"SalesID","Date","Amount"};

NR CLASSES, PUNE (8796064387/90)


String as[][]=new String[10][10];

Slip14_2()
{
setLayout(null);
cb=new JComboBox();
cb.setBounds(350,20,100,20);
cb.addItem("JAN");
cb.addItem("FEB");
cb.addItem("MARCH");
cb.addItem("APRIL");
cb.addItem("MAY");
cb.addItem("JUN");
cb.addItem("JULY");
cb.addItem("AUG");
cb.addItem("SEP");
cb.addItem("OCT");
cb.addItem("NOV");
cb.addItem("DEC");
add(cb);
cb.addItemListener(this);
setSize(500,400);
setVisible(true);

}
public void itemStateChanged(ItemEvent ie)
{
String str=cb.getSelectedItem().toString();

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection("jdbc:odbc:dsn");
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery("select * from BookSales where Date like '"+str+"%'");
int i=0;

while(rs.next())
{
as[i][0]=rs.getString("SalesID");
as[i][1]=rs.getString("Date");
as[i][2]=rs.getString("Amount");
i++;
}
cn.close();
JTable jt=new JTable(as,head);
JScrollPane pane=new JScrollPane(jt);
pane.setBounds(0,0,300,400);
add(pane);

}catch(Exception e)
{
System.out.println(e);
}

NR CLASSES, PUNE (8796064387/90)


}
public static void main(String args[])
{
new Slip14_2();
}

Slip 17 :Write a JDBC application using swing for the following:

Add table Alter Table Drop Table

Slip17.java

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
class Slip17 extends JFrame implements ActionListener
{
JLabel l1;
JButton b1,b2,b3;
JTextArea t1;

Connection con;
Statement stmt;
String str;
Slip17()
{
l1=new JLabel("Type DDL Query");
b1=new JButton("create table");
b2=new JButton("Alter table");
b3=new JButton("Drop table");

t1=new JTextArea(20,20);
add(l1);
add(b1);
add(b2);
add(b3);
add(t1);

b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
setVisible(true);

NR CLASSES, PUNE (8796064387/90)


setSize(500,500);
setLayout(new FlowLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
if(b1==e.getSource())
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:dsn");
stmt=con.createStatement();
str=t1.getText();
int ans= stmt.executeUpdate(str);
if(ans==0)
JOptionPane.showMessageDialog(null,"Table
created");
else
JOptionPane.showMessageDialog(null,"Table NOT
created");

}
catch(Exception ex)
{
System.out.println(ex);
}
}
else if(b2==e.getSource())
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:dsn");
stmt=con.createStatement();
str=t1.getText();
int ans= stmt.executeUpdate(str);
if(ans==0)
JOptionPane.showMessageDialog(null,"Table Alter");
else
JOptionPane.showMessageDialog(null,"Table NOT
Alter");

}
catch(Exception ex)
{
System.out.println(ex);
}
}
else if(b3==e.getSource())
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:dsn");

NR CLASSES, PUNE (8796064387/90)


stmt=con.createStatement();
str=t1.getText();
int ans= stmt.executeUpdate(str);
if(ans==0)
JOptionPane.showMessageDialog(null,"Drop Table");
else
JOptionPane.showMessageDialog(null,"Table NOT
Droped");

}
catch(Exception ex)
{
System.out.println(ex);
}
}
}

public static void main(String a[])


{
Slip17 ob = new Slip17();
}
}

Slip 18:
Design a servlet that provides information about a http request from client, such as IP
address and browser type. The servlet also provides information about the server on which
the servlet is running, such as the operating system type, and the names of currently loaded
servlet.

import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

public class Slip4 extends HttpServlet

public void doGet(HttpServletRequest request, HttpServletResponse response)


throws IOException, ServletException

response.setContentType(“text/html”);

PrintWriter out= res.getWriter();

out.println(“<HTML>”);

out.println(“<BODY>”);

NR CLASSES, PUNE (8796064387/90)


out.println(“Information Of Client: ”);

out.println(“IP Address : ” + req.getRemoteAddr() + ”\n”);

out.println(“Name : ” + req.getRemoteHost() + ”\n”);

out.println(“Information Of Server: ”);

out.println(“Name : ” + req.getServerName() + ”\n”);

out.println(“Port : ” + req.getServerPort() + ”\n”);

out.println(“</BODY>”);

out.println(“</HTML>”);

Slip 19 : Write a multithreading program in java to convert smile face into the crying face
after 5 seconds.

Slip19_2.java

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

public class Slip19_2 extends Applet implements Runnable


{
Thread t;
int f;
public void init()
{
t=new Thread(this);
t.start();
f=0;
}
public void run()
{
try
{
if (f==0)
{
t.sleep(1000);
f=1;
repaint();
}
else

NR CLASSES, PUNE (8796064387/90)


{
t.sleep(1000);
repaint();
f=0;
}
}
catch(Exception e)
{ System.out.println(e);
}
run();
}
public void paint(Graphics g)
{
g.drawOval(100,100,100,100);
g.fillOval(120,125,20,20);
g.fillOval(160,125,20,20);
g.drawLine(150,125,150,150);
if (f==0)
{
g.drawArc(130,135,40,40,0,-180);
f=1;
}
else
{
g.drawArc(130,170,40,40,0,180);
f=0;
}
}
}

SLIP 20:
Chatting Application using AWT

Awtschat.java

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;

class Awtschat extends Frame implements ActionListener


{
TextField t1;
Button b1;
ServerSocket ss;
Socket s;
Scanner sc;
DataOutputStream dos;
DataInputStream dis;
String msg;
Label l1,l2;
Awtschat() throws Exception
{

NR CLASSES, PUNE (8796064387/90)


setVisible(true);
setSize(600,600);
t1=new TextField(50);
b1=new Button("send");
l1=new Label("Client");
l2=new Label();
setLayout(new FlowLayout());
add(l1);
add(l2);
add(t1);
add(b1);
b1.addActionListener(this);
ss=new ServerSocket(5000);
sc=new Scanner(System.in);
s=ss.accept();
dos=new DataOutputStream(s.getOutputStream());
dis=new DataInputStream(s.getInputStream());

public void actionPerformed(ActionEvent ae)


{
if(ae.getSource()==b1)
{
try
{

String reply=(String)dis.readUTF();
l2.setText(reply);

msg=t1.getText();
dos.writeUTF(msg);
t1.setText("");

}
catch(Exception e){}
}
}

public static void main(String a[]) throws Exception


{
Awtschat ob=new Awtschat();
}

Awtcchat.java
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;

NR CLASSES, PUNE (8796064387/90)


class Awtcchat extends Frame implements ActionListener
{
TextField t1;
Button b1;
Socket s;
Scanner sc;
DataOutputStream dos;
DataInputStream dis;
String msg;
Label l1,l2;
Awtcchat() throws Exception
{
setVisible(true);
setSize(600,600);
t1=new TextField(50);
b1=new Button("send");
l1=new Label("Sever");
l2=new Label();
setLayout(new FlowLayout());
add(l1);
add(l2);
add(t1);
add(b1);
b1.addActionListener(this);
s=new Socket("localhost",5000);
sc=new Scanner(System.in);
dos=new DataOutputStream(s.getOutputStream());
dis=new DataInputStream(s.getInputStream());

public void actionPerformed(ActionEvent ae)


{
if(ae.getSource()==b1)
{
try
{
msg=t1.getText();
dos.writeUTF(msg);
t1.setText("");

String reply=(String)dis.readUTF();
l2.setText(reply);
}
catch(Exception e){}
}
}

public static void main(String a[]) throws Exception


{
Awtcchat ob=new Awtcchat();
}

NR CLASSES, PUNE (8796064387/90)


}

SLIP 21:

Design an HTML page containing 4 options ,buttons(painting,drawing,singing and


swimming) and 2 buttons reset and submit. When the user clicks submit button , the server
response by adding a cookie containing the selected hobby and sends a message back to
client. Program should not allow duplicate cookie to written.

/* Slip21_2 :*/
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<body>

<form action="Slip21.jsp" method="post">

<input type="checkbox" name="id" value="Painting"><br>


<input type="checkbox" name="id" value="Drawing"><br>
<input type="checkbox" name="id" value="Singing"><br>
<input type="checkbox" name="id" value="Swimming"><br>

<input type="submit" name="submit" value="Submit">


<input type="reset" value="Reset">

<%
Cookie c1 = new Cookie("p", "Paintaing");
response.addCookie(c1);

Cookie c2 = new Cookie("d", "Drawing");


response.addCookie(c2);

Cookie c3 = new Cookie("s", "Singing");


response.addCookie(c3);

Cookie c4 = new Cookie("sw", "Swimming");


response.addCookie(c4);
%>
</form>
</body>
</html>

/* Slip21 :*/

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%

NR CLASSES, PUNE (8796064387/90)


Cookie c[] = request.getCookies();
for(int i=0;i < c.length;i++)
{
Cookie c1 = c[i];
out.println("\nName : "+c1.getValue());
}

%>

Slip 22 : Write a java program to create a student table with field’s rno, name and per.
Insert values in the table. Display all the details of the student on screen. (Use
PreparedStatement Interface)

Slip22_2.java

import java.sql.*;
import java.io.*;

public class Slip22_2


{
public static void main(String args[])
{
Connection con;
PreparedStatement ps;
ResultSet rs;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:dsn");
if(con==null)
{
System.out.println("Connection Failed......");
System.exit(1);
}
System.out.println("Connection Esatablished......");
Statement stmt=con.createStatement();
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
String query="insert into student values(?,?,?)";
ps=con.prepareStatement(query);
System.out.println("Enter roll no : ");
int rno=Integer.parseInt(br.readLine());

System.out.println("Enter name : ");


String name=br.readLine();

System.out.println("Enter per : ");

NR CLASSES, PUNE (8796064387/90)


int per=Integer.parseInt(br.readLine());

ps.setInt(1,rno);
ps.setString(2,name);
ps.setInt(3,per);

int no=ps.executeUpdate();
if(no!=0)
System.out.println("Data inserted succesfully.....");
else
System.out.println("Data not inserted");
//display details

rs=stmt.executeQuery("select * from Student");


System.out.println("rno\t"+"sname\t"+"perc");
while(rs.next())
{

System.out.println("\n"+rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getInt(3));
}

con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

Slip 23_2 :
Write a Java Program to Read, Update and Delete any record from “Elements†table.
The table has following fields (Atomic_weight , Name (primary key), Chemical_symbol). The
input should be provided through Command Line Arguments along with the appropriate data.
The operations are: R : Read, U: Update, D: Delete.
The syntax for Read: R
The syntax for Delete: D name

import java.sql.*;
import java.io.*;

class Slip23_2
{
static BufferedReader br =new BufferedReader(new InputStreamReader(System.in));

Connection con;
PreparedStatement ps;
Statement st;
ResultSet rs;

NR CLASSES, PUNE (8796064387/90)


void modify()throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:dbc:dsn");
System.out.print("Enter Roll no to be updated:");
int rno=Integer.parseInt(br.readLine());

System.out.print("Enter new Percentage :");


float per=Float.parseFloat(br.readLine());

String sql="update student set per=? where rno=?";


ps=con.prepareStatement(sql);

ps.setFloat(1,per);
ps.setInt(2,rno);

int n=ps.executeUpdate();
if(n>0)
System.out.println("Record Updated...");
}

void delete()throws Exception


{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:dbc:dsn");
System.out.println("Enter Roll No to be deleted :");
int rno=Integer.parseInt(br.readLine());
String sql="delete from student where rno=?";
ps=con.prepareStatement(sql);
ps.setInt(1,rno);
int n=ps.executeUpdate();
if(n>0)
System.out.println("Record Deleted...");
}

void viewAll()throws Exception


{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:dbc:dsn");
String sql="select * from student";
st=con.createStatement();
rs=st.executeQuery(sql);
System.out.println("Roll No\t Name \t Percentage");
while(rs.next())
{
System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getFloat(3));
}
}

public static void main(String a[]) throws Exception


{
Slip23_2 ob = new Slip23_2();

NR CLASSES, PUNE (8796064387/90)


char ch;
do
{

String str = (a[0]);


ch=str.charAt(0);
switch(ch)
{
case 'U' : ob.modify();
break;
case 'D' : ob.delete();
break;
case 'R' : ob.viewAll();
break;
case 'E' : break;
}
}while(ch!='E');

}
}

Slip 24 : Write a java program to accept the details of college (CID, CName, Address, year)
and store it into database (Use Swing and PreparedStatement interface)

Slip24_2.java

import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

class Slip24_2 extends JFrame implements ActionListener


{
JLabel l1,l2,l3,l4;
JTextField t1,t2,t3,t4;
JButton b1,b2;
String sql;
JPanel p,p1;
Connection con;
PreparedStatement ps;

JTable t;
JScrollPane js;
Statement stmt ;
ResultSet rs ;
ResultSetMetaData rsmd ;
int columns;

NR CLASSES, PUNE (8796064387/90)


Vector columnNames = new Vector();
Vector data = new Vector();

Slip24_2()
{

l1 = new JLabel("Cust id :");


l2 = new JLabel("Enter name :");
l3 = new JLabel("Adderss :");
l4 = new JLabel("Year:");

t1 = new JTextField(20);
t2 = new JTextField(20);
t3 = new JTextField(20);
t4 = new JTextField(20);

b1 = new JButton("Save");
b2 = new JButton("Clear");

b1.addActionListener(this);
b2.addActionListener(this);

p=new JPanel();
p1=new JPanel();
p.add(l1);
p.add(t1);
p.add(l2);
p.add(t2);
p.add(l3);
p.add(t3);
p.add(l4);
p.add(t4);

p.add(b1);
p.add(b2);

add(p);
setLayout(new GridLayout(2,1));
setSize(600,800);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

public void actionPerformed(ActionEvent e)


{
if((JButton)b1==e.getSource())
{
int no = Integer.parseInt(t1.getText());
String name = t2.getText();
int p = Integer.parseInt(t3.getText());
int yr = Integer.parseInt(t4.getText());

NR CLASSES, PUNE (8796064387/90)


System.out.println("Accept Values");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:dsn");
sql = "insert into customer values(?,?,?)";
ps = con.prepareStatement(sql);
ps.setInt(1,no);
ps.setString(2, name);
ps.setInt(3,p);
ps.setInt(4,yr);
System.out.println("values set");
int n=ps.executeUpdate();
if(n!=0)
{
JOptionPane.showMessageDialog(null,"Record insered
...");
}

else
JOptionPane.showMessageDialog(null,"Record NOT
inserted ");

}//end of try
catch(Exception ex)
{
System.out.println(ex);
//ex.printStackTrace();
}

}//end of if

else
{
t1.setText(" ");
t2.setText(" ");
t3.setText(" ");
t4.setText(" ");

}
}//end of method

public static void main(String a[])


{
Slip24_2 ob = new Slip24_2();
}
}

Slip 25 : Write a java program for implementation scrollable ResultSet. Consider Emp table
(eno, ename, sal)
- moveFirst
- moveNext
- movePrevious

NR CLASSES, PUNE (8796064387/90)


- moveLast

Slip 25_2

import java.io.*;
import java.sql.*;
import java.util.*;
class Slip25_2
{
public static void main(String args[])
{
Connection conn= null;
Statement stmt = null;
ResultSet rs = null;
int ch;
Scanner s=new Scanner(System.in);
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:dsn");

stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery("select * from employee");
int count=0;
while(rs.next())
count++;

System.out.println("Which Record u want");


System.out.println("Records are = "+count);

do
{ System.out.println("1 First \n2 last \n3 next \n4 prev \n0 Exit");
ch=s.nextInt();
switch(ch)
{
case 1: rs.first();
System.out.println("Roll :"+rs.getInt(1)+" Name
:"+rs.getString(2)); break;
case 2: rs.last();
System.out.println("Roll :"+rs.getInt(1)+" Name
:"+rs.getString(2)); break;

case 3 : rs.next();
if(rs.isAfterLast())
System.out.println("can't move
forword");
else

System.out.println("Roll :"+rs.getInt(1)+"
Name :"+rs.getString(2));
break;
case 4 : rs.previous();

NR CLASSES, PUNE (8796064387/90)


if(rs.isBeforeFirst())
System.out.println("can't move
backword");
else
System.out.println("Roll :"+rs.getInt(1)+"
Name :"+rs.getString(2));
break;
case 0 : break;
default:System.out.println("Enter valid operation");

}//switch
}while(ch!=0);

}//end of try
catch(Exception e)
{
System.out.println(e);
}
}//main
}//class

Slip 27 : Write program to create a window that has a textbox/label to show current time. The
time should be displayed in hh:mm:ss format. The thread should start displaying the time
when the user clicks the Start button and stop when the user clicks the Stop button.

Slip27_2.java

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

class MyThread extends Thread


{
JTextField tf;
MyThread(JTextField tf)
{
this.tf = tf;
}
public void run()
{
while(true)
{
Date d = new Date();
int h = d.getHours();
int m = d.getMinutes();
int s = d.getSeconds();
tf.setText(h+":"+m+":"+s);
try
{
Thread.sleep(300);
}

NR CLASSES, PUNE (8796064387/90)


catch(Exception e){}
}
}
}

class Slip27_2 extends JFrame implements ActionListener


{
JTextField txtTime;
JButton btnStart,btnStop;
MyThread t;
Slip27_2()
{
txtTime = new JTextField(20);
btnStart = new JButton("Start");
btnStop = new JButton("Stop");
setTitle("Stop Watch");
setLayout(new FlowLayout());
setSize(300,100);
add(txtTime);
add(btnStart);
add(btnStop);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

btnStart.addActionListener(this);
btnStop.addActionListener(this);
t = new MyThread(txtTime);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==btnStart)
{
if(!t.isAlive()) t.start();
else t.resume();
}
if(ae.getSource()==btnStop)
{
t.suspend();
}
}

public static void main(String a[])


{
new Slip27_2();
}
}

NR CLASSES, PUNE (8796064387/90)


SLIP 28:
Write a java program to display the selected employee details in JTable. (use database,
combo box for employee selection ) Employee having fields eno, ename, sal, desg.

import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import java.util.Vector;

class Slip28_2 implements ItemListener


{

JFrame f;
JComboBox cb;
JPanel p;
JLabel l,l1,l2,l3;

Connection conn = null;


Statement stmt = null;
PreparedStatement ps = null;
ResultSet rs,rs1 = null;

Slip28_2()
{
f = new JFrame("Employee Information");
p = new JPanel();

l = new JLabel("Select emp No : ");


l1 = new JLabel();
l2 = new JLabel();
l3 = new JLabel();

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:dsn11");
stmt = conn.createStatement();
Vector v = new Vector();

rs = stmt.executeQuery("select eno from employee");


while(rs.next())
{
v.add(rs.getInt(1));
}

cb = new JComboBox(v);
cb.addItemListener(this);
}
catch(Exception e)
{

NR CLASSES, PUNE (8796064387/90)


e.printStackTrace();
}

p.add(l);
p.add(cb);

p.add(l1);
p.add(l2);
p.add(l3);

f.add(p);
f.setSize(400, 400);
f.setVisible(true);
}

public void itemStateChanged(ItemEvent e)


{
JComboBox source = (JComboBox)e.getSource();
Integer emp_no = (Integer)source.getSelectedItem();

try
{
rs1 = stmt.executeQuery("select * from employee where eno ="+emp_no);
if(rs1.next())
{
l1.setText("\nEmp No : "+rs1.getInt(1));
l2.setText("\nName : "+rs1.getString(2));
l3.setText("\nSalary : "+rs1.getInt(3));

}
}
catch(Exception ex)
{
System.out.println(ex);
}
}

public static void main(String args[])


{
Slip28_2 obj = new Slip28_2();
}
}

Slip 29_2 : Write a menu driven java program for the following:
Insert
Update
Delete
Search
Display
Exit

NR CLASSES, PUNE (8796064387/90)


Consider Student (rno, sname, per) table for this.

Slip29_2.java

import java.sql.*;
import java.io.*;

class Slip29_2
{
static BufferedReader br =new BufferedReader(new InputStreamReader(System.in));

Connection con;
PreparedStatement ps;
Statement st;
ResultSet rs;
Slip29_2() throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:dsn");
if(con==null)
{
System.out.println("Connection Failed....");
System.exit(1);
}
}

void insert()throws Exception


{
System.out.print("Enter Roll no :");
int rno=Integer.parseInt(br.readLine());

System.out.print("Enter Name :");


String name=br.readLine();

System.out.print("Enter Percentage :");


float per=Float.parseFloat(br.readLine());

String sql="insert into student values(?,?,?)";


ps=con.prepareStatement(sql);

ps.setInt(1,rno);
ps.setString(2,name);
ps.setFloat(3,per);

int n=ps.executeUpdate();
if(n>0)
System.out.println("Record Inserted...");
}

void modify()throws Exception


{
System.out.print("Enter Roll no to be updated:");
int rno=Integer.parseInt(br.readLine());

NR CLASSES, PUNE (8796064387/90)


System.out.print("Enter new Percentage :");
float per=Float.parseFloat(br.readLine());

String sql="update student set per=? where rno=?";


ps=con.prepareStatement(sql);

ps.setFloat(1,per);
ps.setInt(2,rno);

int n=ps.executeUpdate();
if(n>0)
System.out.println("Record Updated...");
}

void delete()throws Exception


{
System.out.println("Enter Roll No to be deleted :");
int rno=Integer.parseInt(br.readLine());
String sql="delete from student where rno=?";
ps=con.prepareStatement(sql);
ps.setInt(1,rno);
int n=ps.executeUpdate();
if(n>0)
System.out.println("Record Deleted...");
}

void search()throws Exception


{

System.out.println("Enter Roll No :");


int rno=Integer.parseInt(br.readLine());
String searchsql="select * from student where rno=?";
ps=con.prepareStatement(searchsql);
ps.setInt(1,rno);

rs=ps.executeQuery();
if(rs.next())
{
System.out.println("Roll No :"+rs.getInt(1)
+"\nName :"+rs.getString(2)
+"\nPercentage :"+rs.getFloat(3));
}
else
System.out.println("Roll no not found...");
}

void viewAll()throws Exception


{
String sql="select * from student";
st=con.createStatement();
rs=st.executeQuery(sql);
System.out.println("Roll No\t Name \t Percentage");
while(rs.next())
{
System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getFloat(3));

NR CLASSES, PUNE (8796064387/90)


}
}

public static void main(String a[]) throws Exception


{
Slip29_2 ob = new Slip29_2();
int ch;
do
{
System.out.println(" 1.Insert\n 2.Modify \n 3.Delete \n 4.Search \n
5.view All \n 0.Exit");
System.out.println("Enter your choice : ");
ch = Integer.parseInt(br.readLine());

switch(ch)
{
case 1 :ob.insert();
break;
case 2 : ob.modify();
break;
case 3 : ob.delete();
break;
case 4 : ob.search();
break;
case 5 : ob.viewAll();
break;
case 0 : break;
}
}while(ch!=0);

}
}

Slip 30:
Write a servlet program to display the details of Product (ProdCode, PName, Price) on the
browser in tabular format. (Use database)

JAVA FILE:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class Slip4 extends HttpServlet
{

NR CLASSES, PUNE (8796064387/90)


public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType(“text/html”);
PrintWriter out= res.getWriter();
Connection con=null;
Statement st=null;
ResultSet rs=null,rs1=null;
out.println(“<HTML>”);
out.println(“<BODY>”);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection("jdbc:odbc:dsn");
if(con==null)
msg=”Connection to databse failed”;
else
{
st=con.createStatement();
rs=st.executeQuery(“select * from product);
if(rs==null || rs1==null)
{
rs.next();
rs1.next();
int i=1;
out.println(“prod code:”+rs.getInt(1)+”
\t\t\tpname:”+rs.getString(3)+”\n”+”price”+rs.getString(2)+”\n”);
int netB=0,sumT=0;
while(rs1.next())
{
sumT=rs1.getInt(2)*rs1.getInt(3);
out.println(i +”\t\t\t”+rs1.getString(1)+”\t\t”+
rs1.getInt(2)+”\t\t”+ rs1.getInt(3)+”\t\t”+sumT+”\n”);

}
}
catch(Exception e) { }
out.println(“</BODY>”);
out.println(“</HTML>”);
}
}

NR CLASSES, PUNE (8796064387/90)


NR CLASSES, PUNE (8796064387/90)

Вам также может понравиться