6 sem practical
6 sem practical
❖ Slip3AServer ❖ Slip5a.jsp
import java.io.*; <%@page contentType="text/html"%>
import java.net.*; <%!int n,f,l;%>
class Slip3AServer <%
{ int
public static void main(String args[])throws n=Integer.parseInt(request.getParameter("t1"));
Exception l=n%10;
{ while(n>0)
ServerSocket ss=new {
ServerSocket(1616); f=n%10;
Socket s=ss.accept(); n=n/10;
DataInputStream dis =new }
DataInputStream(s.getInputStream()); out.println("the sum of first and last digit is");
%>
int n1=Integer.parseInt(dis.readLine()); <font color="red" size="18"><%=f+l%>
int cnt=0; </font>
for(int i=2;i<n1;i++)
{ 5a.html
if(n1%i==0) <html>
{ <body>
cnt++; <form
break; method="post"action="http://localhost:11000/jsp_fol
} der_name/Slip5A.jsp">
} Enter No<input type="text" name="t1"><br><br>
DataOutputStream dos =new <input type="submit" value="sum">
DataOutputStream(s.getOutputStream()); </form>
if(cnt==0) </body>
dos.writeBytes(n1+"is </html>
prime.");
else Slip6A
dos.writeBytes(n1+"is not import java.awt.*;
prime."); import javax.swing.*;
} public class Slip6A extends Canvas implements
} Runnable
❖ Slip4A {
import java.sql.*; int f;
class_Slip4A Thread t1;
{ public Slip6A()
Public static void main(String args[j]throws {
Exception t1=new Thread(this);
t1.start(); <form method="POST"
} action="http://localhost:11000/jsp_folder_name/Slip7
public void paint(Graphics g) A.jsp">
{ enter e-mail id<input type="text"name="t1">
Toolkit t=Toolkit.getDefaultToolkit(); <input type="submit"value="check">
Image i1=t.getImage("car.jpg"); </form>
switch(f) </body>
{ </html>
case 0:
g.drawImage(i1,50,50,this); Slip8B
break; import java.sql.*;
case 1: Class Slip8A
g.clearRect(50,50,290,290); {
break; Public static void main(String args[j]throws Exception
} {
} Class for name(“com.mysql.jdbc.Driver”);
public void run() Connection con=Drivermanager.getconnection
{ (“jdbc.mysql:/localhost:3306/bca2025”;”root”,””);
while(true) Statement stmt=con.createstatement();
{ Resultstate rs=stmt.executequery(“select ename from
repaint(); emp where ename like ‘A%’”);
f=(f+1)%2; System.out.println(rs.next());
try While(rs.next())
{ {S
Thread.sleep(20); System.out.println(rs.getstring(1));
} }
catch(Exception e){} Con.close();
} }
}
} Slip9A
public static void main(String args[]) import java.io.*;
{ import java.sql.*;
JFrame jf=new JFrame(); class Slip9A
Slip6A s1=new Slip6A(); {
jf.add(s1); public static void main(String args[])throws
jf.setSize(300,300); Exception
jf.setVisible(true); {
} Connection con;
} PreparedStatement pstmt;
int no,s;
7A.jsp Class.forName("com.mysql.jdbc.Driver");
<%@page contentType="text/html"%>
<%String str=request.getParameter("t1"); con=DriverManager.getConnection("jdbc:mysql://local
if(str.contains("@")&& str.contains(".")) host:3306/tybba","root","");
out.println("Email valid"); pstmt=con.preparStatement("create table
else employee2(eno int, ename varchar(20),sal float");
out.println("Email Invalid"); pstmt.execute();
%> System.out.println("table created");
pstmt=con.preparStatement("insert into
7a.html employee2 values(?,?,?");
<html> DataInputStream dis = new
<body> DataInputStream(System.in);
System.out.println("enter eno,ename and sal");
no=Integer.parseInt(dis.readLine()); <form method="POST"
nm=dis.readLine(); action="http://localhost:11000/jsp_folder_name/Slip1
pstmt.setInt(1,no); 3B.jsp">
pstmt.setInt(2,nm); enter college id<input
pstmt.setfloat(3,s); type="text"name="t1"><br><br>
System.out.println("record inserted"); enter college name<input
con.close(); type="text"name="t2"><br><br>
} enter address<input
} type="text"name="t3"><br><br>
<input type="submit"value="display">
Slip12A </form>
</body>
import java.sql.*; </html>
class Slip12A
{ 14BServer
public static void main(String args[])throws Exception
{ import java.net.*;
import java.io.*;
Class.forName("com.mysql.jdbc.Driver"); class Slip14BServer
Connection con = {
DriverManager.getConnection("jdbc:mysql://localhost public static void main(String args[])throws Exception
:3306/tybba","root",""); {
Statement stmt = ServerSocket ss=new ServerSocket(1313);
con.createStatement(); Socket s=ss.accept();
ResultSet rs = DataInputStream dis=new
stmt.executeQuery("select * from employee2"); DataInputStream(s.getInputStream());
int cnt=0; String dir=dis.readLine();
while(rs.next()) String ext=dis.readLine();
{ File f1=new File(dir+":");
cnt++; String s1[]=f1.list();
} if(s1==null)
System.out.println("no of records in System.out.println("dir does not
employee2 table"+cnt); exist");
con.close(); else
} {
} for(int i=0;i<s1.length;i++)
{
Slip13b.jsp if(s1[i].endsWith(ext))
<%@page contentType="text/html"%> System.out.println(s1[i]);
<font color="black">
<table border="1"> }
<tr><th>id</th><th>name</th><th>address</th></tr }
> }
<tr><td><%= request.getParameter("t1")%></td> }
<td><%= request.getParameter("t2")%></td>
<td><%= request.getParameter("t3")%></td> 15A
</tr> class Alpha extends Thread
</table> {
</font> public void run()
{
13B.html try
<html> {
<body> Thread.sleep(2000);
} int l;
catch(Exception e){} DataInputStream dis=new
for(int i=97;i<=122;i++) DataInputStream(System.in);
System.out.println((char)i); System.out.println("enter the string");
str=dis.readLine();
} l=str.length();
} for(int i=0;i<l;i++)
class Slip15A {
{ char ch=str.charAt(i);
public static void main(String arg[])
{ if(ch=='a'||ch=='A'||ch=='e'||ch=='E'||ch=='i'||ch=='I
Alpha a1=new Alpha(); '||ch=='o'||ch=='O'||ch=='u'||ch=='U')
a1.start(); {
} Thread.sleep(3000);
} System.out.println(ch);
}
}
16a.jsp }
}
<%@page contentType="text/html"%>
<% 18A
String unm=request.getParameter("t1");
import java.io.*;
String pw=request.getParameter("t2"); class Fact extends Thread
if(unm.equals(pw)) {
response.sendRedirect("login.html"); public void run()
else {
response.sendRedirect("error.html"); try
%> {
DataInputStream dis =new
16a.html DataInputStream(System.in);
<html> System.out.println("enter the no");
<body> int n=Integer.parseInt(dis.readLine());
<form method="POST" int f=1;
action="http://localhost:11000/jsp_folder_name/Slip1 for(int i=1;i<=n;i++)
6A.jsp"> {
enter username<input type="text" f=f*i;
name="t1"><br><br> sleep(2000);
enter password<input type="text"
name="t2"><br><br> }
<input type="submit"value="login"> System.out.println(" factorial is"+f);
</form> }
</body>
</html> catch(Exception e){}
17A }
}
import java.io.*; class Slip18A
class Slip17A
{ {
public static void main(String args[])throws Exception public static void main(String args[])
{ {
String str; Fact f1=new Fact();
f1.start(); System.out.println("record deleted");
con.close();
} }
} }
21A
22AServer setDefaultCloseOperation(JFrame.EXIT_ON_CL
OSE);
import java.net.*; try
import java.io.*; {
import java.util.*; Class.forName("com.mysql.jdbc.Driver");
class Slip22AServer System.out.println("ss");
{
public static void main(String args[])throws Exception con=DriverManager.getConnection("jdbc:mys
{ ql://localhost:3306/tybba","root","");
ServerSocket ss=new ServerSocket(5050); stmt=con.createStatement();
Socket s=ss.accept(); rs=stmt.executeQuery("select
DataInputStream dis=new * from college1");
DataInputStream(s.getInputStream()); while(rs.next())
Date d1=new Date(); {
DataOutputStream dos=new Vector v=new
DataOutputStream(s.getOutputStream()); Vector();
dos.writeBytes(d1+"\n"); v.add(rs.getInt(1));
} v.add(rs.getString(2));
} v.add(rs.getString(3));
v.add(rs.getInt(4));
23A dtm.addRow(v);
}
import java.sql.*; con.close();
}catch(Exception e){} <input type="submit"value="Display">
} </form>
public static void main(String args[]) </body>
{ </html>
new Slip23A();
} 25AClient
}
import java.util.*;
24a.jsp import java.io.*;
<% import java.net.*;
String str=request.getParameter("t1"); public class Slip25AClient
int l=str.length(); {
%> public static void main(String args[])throws
<font color="red"> Exception
<% {
for(int i=0;i<l;i++) Socket s=new Socket("localhost",1111);
{ DataInputStream dis=new
char ch=str.charAt(i); DataInputStream(System.in);
switch(ch) System.out.println("enter the no");
{ DataOutputStream dos=new
case '0': out.println("Zero"); DataOutputStream(s.getOutputStream());
break; dos.writeUTF("Connected \n");
case '1': out.println("One"); int n=Integer.parseInt(dis.readLine());
break; dos.writeUTF(String.valueOf(n));
case '2': out.println("Two"); DataInputStream din=new
break; DataInputStream(s.getInputStream());
case '3': out.println("Three"); System.out.println(new String(din.readUTF()));
break;
case '4': out.println("Four"); }
break; }
case '5': out.println("Five");
break; 25AServer
case '6': out.println("Six"); import java.util.*;
break; import java.io.*;
case '7': out.println("Seven"); import java.net.*;
break; public class Slip25AServer
case '8': out.println("Eight"); {
break; public static void main(String args[])throws
case '9': out.println("Nine"); Exception
break; {
ServerSocket ss=new ServerSocket(1111);
} Socket s=ss.accept();
} DataInputStream dis=new
%> DataInputStream(s.getInputStream());
</font> dis.readUTF();
int n=Integer.parseInt(dis.readUTF());
24A.html
<html> DataOutputStream dos=new
<body> DataOutputStream(s.getOutputStream());
<form method="POST" for(int i=1;i<=n;i++)
action="http://localhost:11000/jsp_folder_name/Slip2 {
4A.jsp"> if(n%i==0)
enter number<input type="text"name="t1"> {
dos.writeUTF(i+"\n"); out.println("You Selected "+hb+"hobby");
System.out.println(i); }
} else
} {
s.close(); String hb=c[0].getValue();
} out.println("You Selected "+hb+"hobby");
} }
}
26A }
30A.jsp
<%@page contentType="text/html"%>
<%
String str=request.getParameter("t1");
StringBuffer sb=new StringBuffer(str);
out.println("reverse string is" +sb.reverse());
%>
30A.html
<html>
<body>
<form method="POST"
action="http://localhost:11000/jsp_folder_name/Slip3
0A.jsp">
enter any string<input
type="text"name="t1"><br><br>
<input type="submit"value="reverse">
</form>
</body>
</html>