Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Slip no 1
- Q1 : Server1 :
- import java.io.*;
- import java.net.*;
- class server1
- {
- 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");
- }
- }
- Client1 :
- import java.io.*;
- import java.net.*;
- class client1
- {
- public static void main(String a[]) throws Exception
- {
- Socket ss = new Socket("localhost",1000);
- System.out.println("IP Address = "+ss.getInetAddress());
- System.out.println("Client port = "+ss.getPort());
- }
- }
- Q2: 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)
- {
- 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_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_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>");
- }
- %>
- Q3 :
- <HTML>
- <BODY>
- <FORM method=POST action="<?php echo $_SERVER['PHP_SELF'] ?>">
- Enter First Value : <INPUT type=text name=a> <BR>
- Enter Second Value: <INPUT type=text name=b> <BR>
- <b>Select Arithmetic Operation</b> <BR>
- <INPUT type=radio name="choice" value="1"> Addition <BR>
- <INPUT type=radio name="choice" value="2"> Subtraction <BR>
- <INPUT type=radio name="choice" value="3"> Multiplication <BR>
- <INPUT type=radio name="choice" value="4">Division <BR>
- <INPUT type=submit name=submit value="Calculate"><BR>
- </FORM>
- <?php
- $c="";
- if(isset($_POST['submit']))
- { $a=$_POST['a'];
- $b=$_POST['b'];
- $ch=$_POST['choice'];
- if($ch=='1')
- {
- $c=$a+$b;
- echo"Addition = $c";
- }
- if($ch=='2')
- {
- $c=$a-$b;
- echo"Subtraction = $c";
- }
- if($ch=='3')
- {
- $c=$a*$b;
- echo"Multiplication = $c";
- }
- if($ch=='4')
- {
- $c=$a/$b;
- echo"Division = $c";
- }
- }
- ?>
- </BODY>
- </HTML>
- Q4 :
- <html>
- <body>
- <form method=get action="emp.php">
- Enter Employee Code : <input type=text name=ecode> <br>
- Enter Employee Name : <input type=text name=ename><br>
- Enter Designation : <input type=text name=des><br>
- <input type=submit value=Save>
- </form>
- </body>
- </html>
- Display.php :
- <?php
- $ecode=$_GET['ecode'];
- $ename=$_GET['ename'];
- $des=$_GET['des'];
- if(isset($_COOKIE['ecode'])&&isset($_COOKIE['ename'])&&isset($_COOKIE['d es']))
- {
- echo"<br><b> Employee Details </b><br>";
- echo"Employee Code : ".$_COOKIE['ename']." <br>";
- echo"Employee Name:".$_COOKIE['ename']."<br>";
- echo"Designation. : ".$_COOKIE['des']."<br>";
- echo"<br><b>EMPLOYESS Details</b><br>";
- echo"Account No. : $ano<br>";
- echo"Joining Date : $jdate<br>";
- }
- ?>
- Emp.php :
- <?php
- $ecode=$_GET['ecode'];
- $ename=$_GET['ename'];
- $designation=$_GET['des'];
- setcookie("ecode",$ecode);
- setcookie("ename",$ename);
- setcookie("des",$des);
- echo"Hello $ename enter your details <br><br>";
- echo"<form method=get action=display.php>
- echo"Account No. : $ano<br>";
- echo"Joining Date : $jdate<br>";
- echo"Hello $ename enter your salary <br><br>";
- echo"<form method=get action=display.php>
- echo"Basic pay. : $bpay<br>";
- echo"Earnings : $earnings<br>";
- echo"Deduction : $deduction<br>";
- <input type=submit value=Display>
- </form>";
- ?>
- Slip no 2
- Q1 :
- import java.util.*;
- import java.io.*;
- class slip2 extends Thread
- {
- String s1;
- slip2(String s)
- {
- s1=s;
- start();
- }
- public void run()
- {
- System.out.println("Vowels are ");
- for(int i=0;i<s1.length();i++)
- {
- char ch=s1.charAt(i);
- if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
- System.out.print(" "+ch);
- }
- }
- public static void main(String a[]) throws Exception
- {
- DataInputStream di = new DataInputStream(System.in);
- System.out.println("Enter a string");
- String str=di.readLine();
- slip2 s=new slip2(str);
- }
- }
- Q2 :
- import java.io.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
- public class VisitServlet extends HttpServlet
- {
- static int i=1;
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException
- {
- response.setContentType("text/html");
- PrintWriter out = response.getWriter();
- String k=String.valueOf(i);
- Cookie c = new Cookie("visit",k);
- response.addCookie(c);
- int j=Integer.parseInt(c.getValue());
- if(j==1)
- {
- out.println("Welcome");
- }
- else
- {
- out.println("You visited "+i+" times");
- }
- i++;
- }
- }
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <web-app>
- <servlet>
- <servlet-name>VisitServlet</servlet-name>
- <servlet-class>VisitServlet</servlet-class>
- </servlet>
- <servlet-mapping>
- <servlet-name>VisitServlet</servlet-name>
- <url-pattern>/servlet/VisitServlet</url-pattern>
- </servlet-mapping>
- </web-app>
- Q3 :
- <html> <body> <form method=get action="student.php"> Enter Roll No. <input type=text name="a"><br> <input type=submit value=submit> </form> </body> </html>
- Student.php <?php $a=$_GET['a']; if(ereg("^BC|A|S([1-3])([0-9][0-9][0-9])$",$a)) { echo"Roll no = ".substr($a,3)."<br>"; $year=substr($a,2,1); if($year=='1') echo"Year = 1st <br>"; if($year=='2') echo"Year = 2nd <br>"; if($year=='3') echo"Year = 3rd <br>";
- $fac=substr($a,0,2); if($fac=='BA') echo"Faculty = BA"; if($fac=='BC') echo"Faculty = BCA"; if($fac=='BS') echo"Faculty = B.Sc."; }
- else { echo"Invalid Roll No."; } ?>
- Q4 :
- <?php interface Cyl { function area(); function volume(); } class Cylinder implements Cyl { public $PI=3.14; public $a; public $r; public $h; function __construct($r,$h) { $this->r=$r; $this->h=$h; } function area() { $this->a=2*$this->PI*($this->h*$this->r); echo"Area = ".$this->a."<br>"; } function volume() { $this->a=$this->PI*$this->r*$this->r*$this->h; echo"Volume = ".$this->a."<br>"; }
- } $c=new Cylinder(5,5); $c->area(); $c->volume(); ?>
- Slip no 3
- Q1 :
- import java.sql.*;
- public class slip3
- {
- public static void main(String args[])
- {
- Connection con;
- try{
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:dsn");
- Statement stmt=con.createStatement();
- ResultSet rs=stmt.executeQuery("select * From employee Where dept='computer science'");
- System.out.println("eno\t"+"ename\t"+"department\t"+"sal");
- while(rs.next())
- {
- System.out.println("\n"+rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getString(3)+""+rs.getInt(4));
- }
- con.close();
- }
- catch(Exception e)
- {
- }
- }
- }
- Q2 :
- import java.awt.*;
- import java.applet.*;
- /*<applet code="slip3.java" height=450 width=350>
- </applet>*/
- public class slip3 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;
- 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){
- }
- }
- 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;
- }
- }
- }
- Q3 :
- <?php
- class Myclass
- {
- public $a;
- public $b=10;
- public $c='ABC';
- function Myclass()
- {
- //Myclass function
- }
- function myfun1()
- {
- //functin
- }
- function myfun2()
- {
- //functin
- }
- }
- $class=get_declared_classes();
- foreach($class as $cname)
- {
- echo"$cname <br>";
- }
- echo"<br>Class Methods are : <br>";
- $m=get_class_methods('Myclass');
- foreach($m as $mname)
- {
- echo"$mname <br>";
- }
- $cp=get_class_vars('Myclass');
- echo"class variables are :<br>";
- foreach($cp as $cpname => $v)
- {
- echo"$cpname : $v <br>";
- } ?>
- Q4 :
- <?php
- interface Area
- {
- function area();
- }
- class Rectangle implements Area
- {
- public $w;
- public $l;
- function __construct($w,$l)
- {
- $this->w=$w;
- $this->l=$l;
- }
- function area()
- {
- return($this->w*$this->l);
- }
- }
- class Square extends Rectangle implements Area
- {
- public $l;
- function __construct($l)
- {
- parent::__construct(12,3);
- echo "<br>Area of Rectangle : ".parent::area()."<br>";
- $this->l=$l;
- }
- function area()
- {
- return($this->l*$this->l);
- }
- }
- class Circle implements Area
- {
- public $PI=3.14;
- public $r;
- function __construct($r)
- {
- $this->r=$r;
- }
- function area()
- {
- return($this->PI*$this->r*$this->r);
- }
- }
- $sq=new Square(4);
- echo "Area of Square : ".$sq->area();
- $cr=new Circle(5);
- echo "<br>Area of Circle : ".$cr->area();
- ?>
- Slip no 4
- Q1 :
- import java.io.*;
- public class slip4 implements Runnable{
- int i,no;
- slip4(int n)
- {
- no = n;
- }
- public void run()
- {
- try
- {
- for(i = 1; i<=no; i++)
- {
- System.out.println("\nHello Java");
- Thread.sleep(150);
- }
- }
- catch(Exception e)
- {
- }
- }
- public static void main(String args[])
- {
- try
- {
- int n;
- System.out.println("\nEnter Number : ");
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- String s = br.readLine();
- n = Integer.parseInt(s);
- Thread t = new Thread(new slip4(n));
- t.start();
- }
- catch(Exception e)
- {
- }
- }
- }
- Q2 :
- <form method='post' action='page1.jsp'>
- <h3>Page 1</h3>
- <h4>Select Your Product:</h4>
- <input type='checkbox' name='prod' value=10>Pencil<br>
- <input type='checkbox' name='prod' value=30>Pen<br>
- <input type='checkbox' name='prod' value=5>Eraser<br>
- <input type='checkbox' name='prod' value=8>Scale<br>
- <input type='checkbox' name='prod' value=45>Note Book<br>
- <input type='submit'><input type='reset'>
- </form>
- Page1.jsp :
- <%
- String s[] = request.getParameterValues("prod");
- int tot=0;
- for(int i=0;i<s.length;i++){
- tot+=Integer.parseInt(s[i]);
- }
- session.setAttribute("tot1", tot);
- response.sendRedirect("Page2.html");
- %>
- <form method='post' action='page2.jsp'>
- <h3>Page 2</h3>
- <h4>Select Your Product:</h4>
- <input type='checkbox' name='prod' value=1300>Jeans<br>
- <input type='checkbox' name='prod' value=500>Shirt<br>
- <input type='checkbox' name='prod' value=2500>Saree<br>
- <input type='checkbox' name='prod' value=750>Trouser<br>
- <input type='checkbox' name='prod' value=400>T-Shirt<br>
- <input type='submit'><input type='reset'>
- </form>
- Page2.jsp :
- <%
- String s[] = request.getParameterValues("prod");
- int tot=0;
- for(int i=0;i<s.length;i++){
- tot+=Integer.parseInt(s[i]);
- }
- int tot1 = Integer.parseInt(session.getAttribute("tot1").toString());
- %>
- <table border=1>
- <tr><td><b>Page 1:</b></td><td>Rs.<%=tot1%>/-</td></tr>
- <tr><td><b>Page 2:</b></td><td>Rs.<%=tot%>/-</td></tr>
- <tr><td><b>Grand Total:</b></td><td>Rs.<%=tot1+tot%>/-</td></tr>
- </table>
- Q3 :
- Calulate.html :
- <HTML>
- <BODY>
- <FORM method=get action="Calulate.php">
- Enter first value: <INPUT type=text name="a"><br>
- Enter second value:<INPUT type=text name="b"><br>
- <INPUT type=submit>
- </FORM>
- </BODY>
- </HTML>
- Calulate.php :
- <?php
- class Calculate
- {
- public $a;
- public $b;
- function __construct($a,$b)
- {
- $this->a=$a;
- $this->b=$b;
- }
- public function add()
- {
- $c=$this->a+$this->b;
- echo"Addition = $c<br>";
- }
- public function subtract()
- {
- $c=$this->a-$this->b;
- echo"Subtract = $c<br>";
- }
- public function multiply()
- {
- $c=$this->a*$this->b;
- echo"Multiplication = $c<br>";
- }
- public function div()
- {
- $c=$this->a/$this->b;
- echo"Division = $c";
- }
- }
- $x=$_GET['a'];
- $y=$_GET['b'];
- $calc=new Calculate($x,$y);
- $calc->add();
- $calc->subtract();
- $calc->multiply();
- $calc->div();
- ?>
- Q4 :
- LoginSession.html :
- <html>
- <body>
- <form method=get action=details.php>
- user name : <input type=text name=uname><br><br>
- password : <input type=text name=pass><br><br>
- <input type=submit value=Login>
- </form>
- </body>
- </html>
- Details.php :
- <?php
- session_start();
- if(set_time_limit(20))
- echo"time expired";
- if(($_REQUEST['uname']=='ABC') && ($_REQUEST['pass']=='abc'))
- {
- echo"<form method=post action='display.php'>";
- echo"Name : <input type=text name=name><br>";
- echo"city : <input type=text name=city><br>";
- echo"PhoneNo.:<input type=text name=pno><br>";
- echo"<input type=submit value='Display'></form>";
- }
- else
- echo"Wrong Information...<a href=LoginSession.html>LoginSession.html</a>";
- ?>
- Slip no 5
- Q1 :
- import java.sql.*;
- class slip5
- {
- public static void main(String args[])
- { Connection con;
- try
- {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:dsn");
- System.out.println("Connection Established...");
- Statement stmt=con.createStatement();
- //create a table teacher
- String query="create table Teacher1"+"(TNo int ,"+" TName varchar(20),"+" sal int,"+" desg varchar(20))";
- stmt.executeUpdate(query);
- System.out.println("given table created in database");
- //insert record into teacher table
- stmt.executeUpdate("insert into Teacher1 "+"values(1,'NRC',50000,'MCS')");
- stmt.executeUpdate("insert into Teacher1 "+"values(2,'ABC',10000,'MCA')");
- stmt.executeUpdate("insert into Teacher1 "+"values(3,'XYZ',40000,'MCA')");
- stmt.executeUpdate("insert into Teacher1 "+"values(4,'PQR',20000,'MCS')");
- System.out.println("Succesfully inserted in table....");
- //display details
- ResultSet rs=stmt.executeQuery("select * From Teacher1");
- System.out.println("TNo\t"+"TName\t"+"sal\t"+"desg");
- while(rs.next())
- {
- System.out.println("\n"+rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getInt(3)+"\t"+rs.getString(4));
- }
- }
- catch(Exception e)
- {
- }
- }
- }
- Q2 :
- import java.awt.*;
- import java.applet.*;
- /*
- <APPLET
- code = "Flag.java"
- width = "500"
- height = "300"
- >
- </APPLET>
- */
- public class Flag 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();
- }
- }
- 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);
- 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);
- }
- }
- }
- Q3 :
- Search.php :
- <?php
- function searchcustomerName(Array $array,$value)
- {
- $firstresult ="";
- foreach ($array as $subarray)
- {
- if(isset($subarray[1])&& stristr($subarray[1],$value)&&$ value!="")
- {
- $firstresult .= $subarray[0]." ".$subarray[1]."".$subarray[2]."<br/>";
- }
- }
- return $firstresult;
- }
- $file= fopen("Customer.dat", "r");
- $filestring =" ";
- while(!feof($file))
- {
- $tempstring = fgets($file);
- $filestring.=$tempstring."<br />";
- $line_of_text.=$tempstring;
- }
- $customer = explode("\n",$line_of_text);
- fclose($file);
- foreach ($customer as $key =>$value)
- {
- $customer[$key] =explode(",",$value);
- }
- $term=strip_tags(substr(_POST['search_term'],0,100));
- $string = ' ' ;
- if($term !=" "&& $term != " ")
- {
- $string.=searchcustomerName($customer,$term);
- }
- if ($string ! =" ")
- echo $string;
- else
- echo'<div class="alter_yellow">No results found</div>';
- ?>
- index.php :
- <?php
- if(isset($_POST['field'])) $selectedoption =$_POST['field'];
- else $selectedoption = "customername";
- ?>
- <head>
- <script type="text/javascript"src="jquery.js"> </script>
- <script type='text/javascript'> $(document).ready(function()
- { $("#search_result").slideUP();
- $("#search_button").click(function(e)
- {
- e.preventDefault();
- ajax_search();
- });
- });
- function ajax_search()
- {
- $"#search_results.show();
- var search_val=$("#search_term").val();
- var.post("./search.php",{search_term : search_val, field : search_type},function(data)
- {
- if(data.length>0)
- {
- $("#search_results").html(data);
- }
- })
- }
- </script> <meta http-equiv=Content-Type" content="text/html;charset=UTF-8"/> <link href="style.css"media="all"rel="stylesheet" title="www"type="text/css"/>
- </head>
- <body> <div id="wrapper"> <form name="search"id=searchform" method="post"> <div> Search for:<input type="text"name"search_term" id="search_term"/>in
- <Select NAME="field"id="searchtype">
- <Option <?php if ($selectedoption=='customername')echo'selected'?>VALUE="customername" >customer Name</option> </Select>
- <input type="hidden"name="searching" value="yes" />
- <input type="submit"id=search_button"name="search" value="search" /> </div> </form> <br /> <hr /> <div id="search_result"></div> <br />
- </div> </body> </html>
- Q4 :
- <?php
- class Employee
- {
- private $eid,$ename,$edept,$sal;
- function __construct($a,$b,$c,$d)
- {
- $this->eid=$a;
- $this->ename=$b;
- $this->edept=$c;
- $this->sal=$d;
- }
- public function getdata()
- {
- return $this->sal;
- }
- public function display()
- {
- echo $this->eid."</br>";
- echo $this->ename."</br>";
- echo $this->edept."</br>";
- //echo $this->ename."</br>";
- }
- }
- class Manager extends Employee
- {
- private $bonus;
- public static $total1=0;
- function __construct($a,$b,$c,$d,$e)
- {
- parent::__construct($a,$b,$c,$d);
- $this->bonus=$e;
- }
- public function max($ob)
- {
- $sal=$this->getdata();
- $total=$sal+$this->bonus;
- if($total>self::$total1)
- {
- self::$total1=$total;
- return $this;
- }
- else { return $ob;
- }
- }
- public function display()
- {
- parent::display();
- echo self::$total1;
- }
- }
- $ob=new Manager(0,"ABC","",0,0);
- $ob1=new Manager(1,"ramdas","computer",28000,2000);
- $ob=$ob1->max($ob);
- $ob2=new Manager(2,"ramdas1","computer",30000,2500);
- $ob=$ob2->max($ob);
- $ob3=new Manager(3,"ramdas2","computer",32000,3000);
- $ob=$ob3->max($ob);
- $ob4=new Manager(4,"ramdas","computer",28000,4000);
- $ob=$ob4->max($ob);
- $ob5=new Manager(5,"ramdas","computer",28000,5000);
- $ob=$ob5->max($ob);
- $ob->display();
- ?>
- Slip no 6
- Q1 :
- import java.sql.*;
- import java.io.*;
- class slip6
- {
- public static void main(String a[])
- {
- PreparedStatement ps;
- Connection con;
- try{
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:dsn");
- con.setAutoCommit(false);
- System.out.println("Connection Esatablished......");
- Statement stmt=con.createStatement();
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- String query="insert into Customer values(?,?,?,?)";
- ps=con.prepareStatement(query);
- System.out.println("Customer Details....");
- System.out.println("Enter CID");
- int cid=Integer.parseInt(br.readLine());
- ps.setInt(1,cid);
- System.out.println("Enter name");
- String name=br.readLine();
- ps.setString(2,name);
- System.out.println("Enter Address");
- String add=br.readLine();
- ps.setString(3,add);
- System.out.println("Enter Ph_No");
- int phno=Integer.parseInt(br.readLine());
- ps.setInt(4,phno);
- ps.executeUpdate();
- con.setAutoCommit(true);
- con.close();
- }
- catch(Exception e)
- {
- }
- }
- }
- Q2 :
- Server :
- import java.io.*;
- import java.net.*;
- class Server{
- public static void main(String args[])
- throws Exception{
- ServerSocket ss = new ServerSocket(7080);
- while(true)
- {
- Socket s = ss.accept();
- DataOutputStream toClient = new DataOutputStream(
- s.getOutputStream());
- DataInputStream fromClient = new DataInputStream(
- s.getInputStream());
- String fileName = fromClient.readLine();
- File f = new File(fileName);
- if(f.exists()){
- String str=null;
- DataInputStream dis = new DataInputStream(
- new FileInputStream(f));
- while((str=dis.readLine())!=null)
- {
- toClient.writeBytes(str+"\n");
- }
- }
- else{
- toClient.writeBytes("File "+fileName+" not found.\n");
- }
- toClient.writeBytes("END\n");
- }
- }
- }
- Client :
- import java.io.*;
- import java.net.*;
- class Client{
- public static void main(String args[])
- throws Exception{
- Socket s = new Socket("localhost",7080);
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- System.out.print("Enter file name:");
- String fileName = br.readLine();
- DataInputStream fromServer = new DataInputStream(s.getInputStream());
- DataOutputStream toServer = new DataOutputStream(s.getOutputStream());
- toServer.writeBytes(fileName+"\n");
- String str="";
- while(true)
- {
- str = fromServer.readLine();
- if(str.equals("END")) break;
- System.out.println(str);
- }
- }
- }
- Q3 :
- <html>
- <head>
- <title>Sticky Form</title>
- </head>
- <body>
- <form action="<?php echo $_SERVER['PHP_SELF']?>" method=post>
- <input type=text name=txtuname value="<?php if(isset($_POST['txtuname']))echo $_POST['txtuname'];?>" >
- </br>
- <input type=password name=txtupass value="<?php if(isset($_POST['txtupass']))echo $_POST['txtupass'];?>" >
- </br>
- <input type=submit value="Login" name=submit>
- <?php
- if(isset($_POST['submit']))
- $nm=$_POST['txtuname'];
- $ps=$_POST['txtupass'];
- $con=mysql_connect("localhost","root","rsb");
- mysql_elect_db("slip6db",$con);
- $result=mysql_query("select * from login where uname='$nm' and upass='$ps'");
- $flag=0;
- while($row=mysql_fetch_array($result))
- {
- $flag++;
- }
- if($flag==1)
- echo "Login validated";
- else echo "username or password invalid";
- ?>
- </body>
- Q4 :
- <?php
- class vehicle
- {
- public $company,$price;
- public function __construct($a,$b)
- {
- $this->company=$a;
- $this->price=$b;
- }
- }
- class Lightmotorvehicle extends vehicle
- {
- public $milege;
- public function __construct($a,$b,$c)
- {
- $this->company=$a;
- $this->price=$b;
- $this->milege=$c;
- }
- public function display()
- {
- echo "<table border=1 width=300><tr><td>".$this>company."</td><td>".$this->price."</td><td>".$this->milege."</td></tr>";
- }
- }
- class Heavymotorvehicle extends vehicle
- {
- public $capacity;
- public function __construct($a,$b,$c)
- {
- $this->company=$a;
- $this->price=$b;
- $this->capacity=$c;
- }
- public function display()
- {
- echo "<table border=1 width=300>";
- echo "<tr><td>".$this->company."</td><td>".$this->price."</td><td>".$this>capacity;
- echo "</td></tr></table>";
- }
- }
- $ob1=new Lightmotorvehicle("Maruti",200000,25);
- $ob1->display();
- $ob2=new Lightmotorvehicle("Toyota",500000,20);
- $ob2->display();
- $ob3=new Lightmotorvehicle("skoda",400000,15);
- $ob3->display();
- $ob4=new Heavymotorvehicle("Tata Truck",1220000,25);
- $ob4->display();
- $ob5=new Heavymotorvehicle("Bajaj",200000,25);
- $ob5->display();
- $ob6=new Heavymotorvehicle("mahindra",900000,25); $ob6->display();
- ?>
- Slip no 10
- Q1 :
- import java.sql.*;
- class slip10
- {
- public static void main(String args[])
- {
- Connection con;
- Statement stmt;
- try
- {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:dsn");
- System.out.println("Connection Established......");
- stmt=con.createStatement();
- ResultSet rs=stmt.executeQuery("select * from employee");
- int cnt=0;
- while(rs.next())
- {
- cnt++;
- }
- System.out.println("Number of records in Table are:"+cnt);
- }
- catch(Exception e)
- {
- }
- }
- }
- Q2 :
- 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)
- {
- 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;
- }
- }
- }
- Q3 :
- Html File :
- <html>
- <head>
- <script>
- function getans()
- {
- st1=document.getElementById('txtname').value;
- st2=document.getElementById('txtpass').value;
- ob=new XMLHttpRequest();
- if(ob)
- alert("object created");
- ob.onreadystatechange=function()
- {
- if(ob.readyState==4 && ob.status==200)
- {
- if(ob.responseText==3)
- {
- alert("sorry you lost the chances to login");
- location="error.html";
- }
- else if(ob.responseText=="correct")
- {
- alert("you entered correct details");
- }
- else
- alert(ob.responseText);
- }
- }
- ob.open("GET","slip10.php?n="+st1+"&p="+st2); ob.send();
- }
- </script>
- </head>
- <body>
- <input type=text id=txtname placeholder="username"></br>
- <input type=password id=txtpass placeholder="password"></br>
- <input type="button" onclick="getans()" value="Login">
- </body>
- </html>
- php file :
- <?php
- $nm=$_GET['n'];
- $ps=$_GET['p'];
- if($nm==$ps)
- {
- echo "correct";
- }
- else if(isset($_COOKIE['cnt']))
- {
- $x=$_COOKIE['cnt'];
- $x=$x+1;
- setcookie('cnt',$x);
- echo $_COOKIE['cnt'];
- if($_COOKIE['cnt']>=3)
- setcookie('cnt',1);
- }
- else
- {
- setcookie('cnt',1);
- echo "1";
- }
- ?>
- Q4 :
- Html file :
- <html>
- <body>
- <form action="slip_10-1.php" method="post"> <center> <h2>Enter Students information :</h2>
- <table>
- <tr>
- <td>Name : </td>
- <td><input type="text" name="name"></td>
- </tr>
- <tr>
- <td>Address : </td>
- <td><input type="text" name="addr"></td>
- </tr>
- <tr>
- <td>Class : </td>
- <td><input type="text" name="class"></td>
- </tr>
- <tr>
- <td></td>
- <td><input type="submit" value=Next></td>
- </tr>
- </table> </center>
- </form>
- </body>
- </html>
- Php file : Slip_10-1.php : <html> <body>
- <form action="slip_10-2.php" method="post"> <center> <h2>Enter Marks for Student:</h2>
- <table>
- <tr>
- <td>Java : </td>
- <td><input type="text" name="m1"></td>
- </tr>
- <tr><td>PHP : </td>
- <td><input type="text" name="m2"></td>
- </tr>
- <tr><td>ST : </td>
- <td><input type="text" name="m3"></td>
- </tr>
- <tr><td>IT : </td>
- <td><input type="text" name="m4"></td>
- </tr>
- <tr>
- <td>Practical : </td>
- <td>
- <input type="text" name="m5"></td>
- </tr>
- <tr><td>Project : </td>
- <td><input type="text" name="m6"></td>
- </tr>
- <tr><td></td>
- <td><input type="submit" value=Next></td>
- </tr>
- </table> </center>
- </form> </body>
- </html>
- <?php
- setcookie("stud1",$_POST['name'],time()+3600);
- setcookie("stud2",$_POST['addr'],time()+3600);
- setcookie("stud3",$_POST['class'],time()+3600);
- ?>
- Slip_10-2.php :
- <?php
- echo "<h3>Marksheet</h3> ";
- echo "Name : ".$_COOKIE['stud1']."<br>";
- echo "Address : ".$_COOKIE['stud2']."\n";
- echo "Class : ".$_COOKIE['stud3']."\n";
- echo "Java : ".$_POST['m1']."\n";
- echo "PHP : ".$_POST['m2']."\n";
- echo "ST : ".$_POST['m3']."\n";
- echo "IT : ".$_POST['m3']."\n";
- echo "Practical : ".$_POST['m3']."\n";
- echo "Project : ".$_POST['m3']."\n";
- ?>
- Slip no 12
- Q1 :
- import java.awt.event.*;
- import javax.swing.*;
- class slip12 extends JFrame implements ActionListener,Runnable
- {
- JTextField t;
- JButton b;
- Thread t1;
- slip12()
- {
- setLayout(null);
- setSize(300,300);
- setVisible(true);
- t = new JTextField(60);
- b = new JButton("Start");
- t1 = new Thread(this);
- b.addActionListener(this);
- t.setBounds(70,70,80,40);
- add(t);
- b.setBounds(70,150,100,30);
- add(b);
- }
- public void actionPerformed(ActionEvent e)
- {
- t1.start();
- }
- public void run()
- {
- for(int i =1; i<=100;i++)
- {
- t.setText(""+i);
- try
- {
- Thread.sleep(150);
- }
- catch(Exception e)
- {
- }
- }
- }
- public static void main(String args[])
- {
- new slip12();
- }
- }
- Q2 :
- Account :
- <form method='post' action='add_account.jsp'>
- <table>
- <tr>
- <td><b>Account No:</b></td>
- <td><input type='text' name='ano'></td>
- </tr>
- <tr>
- <td><b>Account Type:</b></td>
- <td>
- <select name='type'>
- <option value=''>Select Type</option>
- <option value='Saving'>Saving</option>
- <option value='Current'>Current</option>
- </select>
- </td>
- </tr>
- <tr><td><b>Balance:</b></td><td><input type='text' name='bal'></td></tr>
- <tr><td><input type='submit'></td><td><input type='reset'></td></tr>
- </table>
- </form>
- <a href='view_accounts.jsp'>View Accounts</a>
- Add_accounts.jsp :
- <%@page import="java.sql.*" errorPage="err.jsp"%>
- <%
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- Connection con = DriverManager.getConnection("jdbc:odbc:lab.dsn");
- int ano = Integer.parseInt(request.getParameter("ano"));
- String type = request.getParameter("type");
- float bal = Float.parseFloat(request.getParameter("bal"));
- PreparedStatement ps = con.prepareStatement("insert into account values(?,?,?)");
- ps.setInt(1,ano);
- ps.setString(2,type);
- ps.setFloat(3,bal);
- ps.executeUpdate();
- %>
- Account created successfully.<br>
- <a href='account.html'>Add Account</a> <a href='view_accounts.jsp'>View Accounts</a>
- Err .jsp :
- <%@page isErrorPage="true"%>
- Error:<%=exception%><br>
- <a href='account.html'>Home</a>
- View_accounts.jsp :
- <%@page import="java.sql.*"%>
- <%
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- Connection con = DriverManager.getConnection("jdbc:odbc:lab.dsn");
- Statement s = con.createStatement();
- ResultSet rs = s.executeQuery("select * from account");
- %>
- <table border=1>
- <tr><th>Account No</th><th>Type</th><th>Balance</th></tr>
- <%
- while(rs.next()){
- %>
- <tr><td><%=rs.getInt(1)%></td><td><%=rs.getString(2)%></td><td><%=rs.getFloat(3)%></td>
- </tr>
- <%
- }
- %>
- </table><br>
- <a href='account.html'>Home</a>
- Q3 :
- <html> <head> <title>slip12</title> </head> <body> <?php if($_SERVER['REQUEST_METHOD']=="GET") { ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method=POST> <input type name=txtnumber placeholder="Enter a number "> <input type=submit value="calculate"> </form>
- <?php } else if($_SERVER['REQUEST_METHOD']=="POST") { function fact($n) { if($n==1) { return 1; } else { return($n*fact($n-1)); } } function singleval($n) { while($n>9) {$sum=0; while($n) { $r=$n%10; $sum=$sum+$r; $n=$n/10; } $n=$sum; } return $n; } echo fact($_POST['txtnumber']); echo "</br>"; echo singleval($_POST['txtnumber']); } ?> </body>
- Q4 :
- <html> <body> <form action="slip_12.php" method="get"> Enter student name Name:<input type="text" name=sname><br> <input type="submit" value=submit> </form> </body> </html>
- Php file : <?php $sname=$_GET['sname']; $con=mysql_connect("localhost","root",""); $d=mysql_select_db("bca_programs",$con); $result=mysql_query("select *from student where sname='$sname'"); while($row=mysql_fetch_array($result)) { echo $row['sno']."--".$row['sname']."--".$row['per']."<br>"; } ?>
- Slip no 13
- Q1 :
- import java.sql.*;
- class slip13
- {
- public static void main(String a[])
- {
- Connection con;
- Statement stmt;
- try
- {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:dsn");
- System.out.println("Connection Established....");
- stmt=con.createStatement();
- String sql="create table mobile"+"(Model_No int,"+"Company_Name varchar(20),"+"price float(6,2),"+"color varchar(20))";
- stmt.executeUpdate(sql);
- System.out.println("Table Created sucessfully...");
- con.close();
- }
- catch(Exception e)
- {
- }
- }
- }
- Q2 :
- GossipClient :
- import java.io.*;
- import java.net.*;
- public class GossipClient
- {
- public static void main(String[] args) throws Exception
- {
- Socket sock = new Socket("127.0.0.1", 3000);
- // reading from keyboard (keyRead object)
- BufferedReader keyRead = new BufferedReader(new InputStreamReader(System.in));
- // sending to client (pwrite object)
- OutputStream ostream = sock.getOutputStream();
- PrintWriter pwrite = new PrintWriter(ostream, true);
- // receiving from server ( receiveRead object)
- InputStream istream = sock.getInputStream();
- BufferedReader receiveRead = new BufferedReader(new InputStreamReader(istream));
- System.out.println("Start the chitchat, type and press Enter key");
- String receiveMessage, sendMessage;
- while(true)
- {
- sendMessage = keyRead.readLine(); // keyboard reading
- pwrite.println(sendMessage); // sending to server
- pwrite.flush(); // flush the data
- if((receiveMessage = receiveRead.readLine()) != null) //receive from server
- {
- System.out.println(receiveMessage); // displaying at DOS prompt
- }
- }
- }
- }
- GossipServer :
- import java.io.*;
- import java.net.*;
- public class GossipServer
- {
- public static void main(String[] args) throws Exception
- {
- ServerSocket sersock = new ServerSocket(3000);
- System.out.println("Server ready for chatting");
- Socket sock = sersock.accept( );
- // reading from keyboard (keyRead object)
- BufferedReader keyRead = new BufferedReader(new InputStreamReader(System.in));
- // sending to client (pwrite object)
- OutputStream ostream = sock.getOutputStream();
- PrintWriter pwrite = new PrintWriter(ostream, true);
- // receiving from server ( receiveRead object)
- InputStream istream = sock.getInputStream();
- BufferedReader receiveRead = new BufferedReader(new InputStreamReader(istream));
- String receiveMessage, sendMessage;
- while(true)
- {
- if((receiveMessage = receiveRead.readLine()) != null)
- {
- System.out.println(receiveMessage);
- }
- sendMessage = keyRead.readLine();
- pwrite.println(sendMessage);
- pwrite.flush();
- }
- }
- }
- Q3 :
- HTML File <html> <head> <title>Slip13.html</title> <script> function search() { srch=document.getElementById('txtsrch').value; ob=new XMLHttpRequest(); ob.onreadystatechange=function() { if(ob.readyState==4 && ob.status==200) {
- document.getElementById('o').innerHTML=ob.responseText; } } ob.open("GET","slip13.php?s="+srch); ob.send(); } </script> </head> <body> <table align=center border=0> <tr><td><input type=text id=txtsrch placeholder="enter search string"><input type=button value="SEARCH" onclick="search()"> </table> <span id=o></span>
- </body>
- </html>
- PHP File :
- <?php $search=$_GET['s']; $con=mysql_connect("localhost","root","rsb"); mysql_select_db("slip13db",$con); $r=mysql_query("select * from slip13 where des='$search'"); echo "<table align=center"> while($row=mysql_fetch_array($r)) { echo "<tr><td>".$row[0]."</td></tr>"; } echo "</table>"; ?>
- Q4 :
- Html file :
- <html> <body>
- <form action="slip_13.php" method="get"> Enter the name of competition : <input type=text name=cname><br> <input type=submit value=SUBMIT> </form> </body> <html>
- Php file :
- <?php $c_name = $_GET['cname'];
- $con = mysql_connect("localhost","root",""); $d = mysql_select_db("bca_programs",$con); $q = mysql_query("select student_slip_13.stud_id,stud_name,stud_class from student_slip_13,compitition_slip_13,sc_slip_13 where student_slip_13.stud_id=sc_slip_13.stud_id and sc_slip_13.c_no=compitition_slip_13.c_no and c_name='$c_name' and rank=1");
- echo "<table>"; echo "<tr><td>Student Id |</td><td>Student Name |</td><td>Student Class</td></tr>"; while($row = mysql_fetch_array($q)) { echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td></tr>";
- } echo "</table>";
- mysql_close();
- ?>
- Slip no 15
- Q1 :
- import java.sql.*;
- import java.io.*;
- class slip15
- {
- public static void main(String args[])
- {
- Connection con;
- Statement stmt;
- PreparedStatement ps;
- String name;
- try
- {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:dsn");
- System.out.println("Connection Established...");
- stmt=con.createStatement();
- String query="Update Customer set address=? where name=?";
- ps=con.prepareStatement(query);
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Enter Customer name for Update:");
- name=br.readLine();
- System.out.println("Enter new Address:");
- String addr=br.readLine();
- ps.setString(1,addr);
- ps.setString(2,name);
- ps.executeUpdate();
- System.out.println("Succesfully updated in table....");
- ps=con.prepareStatement("select * from Customer where name=?");
- ps.setString(1,name);
- ResultSet rs=ps.executeQuery();
- System.out.println("cid\t"+"Name\t"+"address\t"+"ph_no");
- while(rs.next())
- {
- System.out.println("\n"+rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getString(3)+"\t"+rs.getString(4));
- }
- }
- con.close();
- }
- catch(Exception e)
- {
- System.out.println(e);
- }
- }
- Q2 :
- import java.io.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
- public class Student extends HttpServlet
- {
- public void doPost(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException
- {
- int sno,s1,s2,s3,total;
- String snm,sclass;
- float per;
- res.setContentType("text/html");
- PrintWriter out=res.getWriter();
- sno=Integer.parseInt(req.getParameter("txtsno"));
- snm=req.getParameter("txtnm");
- sclass=req.getParameter("txtclass");
- s1=Integer.parseInt(req.getParameter("txtsub1"));
- s2=Integer.parseInt(req.getParameter("txtsub2"));
- s3=Integer.parseInt(req.getParameter("txtsub3"));
- total=s1+s2+s3;
- per=(total/3);
- out.println("<html><body>");
- out.print("<h2>Result of student</h2><br>");
- out.println("<b><i>Roll No :</b></i>"+sno+"<br>");
- out.println("<b><i>Name :</b></i>"+snm+"<br>");
- out.println("<b><i>Class :</b></i>"+sclass+"<br>");
- out.println("<b><i>Subject1:</b></i>"+s1+"<br>");
- out.println("<b><i>Subject2:</b></i>"+s2+"<br>");
- out.println("<b><i>Subject3:</b></i>"+s3+"<br>");
- out.println("<b><i>Total :</b></i>"+total+"<br>");
- out.println("<b><i>Percentage :</b></i>"+per+"<br>");
- if(per<50)
- out.println("<h1><i>Pass Class</i></h1>");
- else if(per<55 && per>50)
- out.println("<h1><i>Second class</i></h1>");
- else if(per<60 && per>=55)
- out.println("<h1><i>Higher class</i></h1>");
- out.close();
- }
- }
- Html :
- <html>
- <body>
- <form name="f1" method="Post" action="http://localhost:8080/Stud">
- Enter Roll No :  <input type="text" name="txtsno"><br><br>
- Enter Name :    <input type="text" name="txtnm"><br><br>
- Enter class :      <input type="text" name="txtclass"><br><br>
- Subject 1 :      <input type="text" name="txtsub1"><br><br>
- Subject 2 :      <input type="text" name="txtsub2"><br><br>
- Subject 3 :      <input type="text" name="txtsub3"><br><br>
- <input type="submit" value="Result">
- </div>
- </form>
- </body>
- </html>
- Q3 :
- HTML File <html>
- <form action=slip15.php method=post enctype=multipart/form-data>
- <input type=file name=file></br>
- <input type=submit value="Upload">
- </form>
- </html>
- PHP File :
- <?php
- echo "File name : ".$_FILES['file']['name']."</br>";
- $f=$_FILES['file']['size'];
- echo "Size :".$f."</br>";
- echo "File Name on Sever: ".$_FILES['file']['tmp_name']."</br>";
- echo "File Error: ".$_FILES['file']['error']."</br>";
- print_r($_FILES);
- ?>
- Q4 :
- Html file :
- <html>
- <head>
- <script type="text/javascript" >
- function m1(str)
- {
- var ob=false;
- ob=new XMLHttpRequest();
- ob.open("GET","slip_15.php?q="+str);
- ob.send();
- ob.onreadystatechange=function()
- {
- if(ob.readyState==4 && ob.status==200)
- {
- document.getElementById("a").innerHTML=ob.res ponseText;
- }
- }
- }
- </script>
- </head>
- <body> <form>
- Search<input type=text name=search size="20" onkeyup="m1(form.search.value)">
- <input type=button value="submit" onclick="m1(form.search.value)">
- </form> suggestions :<span id="a"></span><br>
- </body> </html>
- Php file :
- <?php
- $a=array("pune","satara","nashik","sangli","mumbai","murud","akola","dound ","dhule","ratnagiri","rajpur");
- $q=$_GET['q'];
- if(strlen($q)>0)
- {
- $match="";
- for($i=0;$i<count($a);$i++)
- {
- if(strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))
- {
- if($match=="")
- $match=$a[$i];
- else $match=$match.",".$a[$i];
- }
- }
- if($match=="")
- echo "No Suggestios";
- else echo $match;
- }
- ?>
- Slip no 16
- Q1 :
- <HTML>
- <HEAD>
- <TITLE> 4.JSP SET B:1 </TITLE>
- </HEAD>
- <BODY>
- <form action="http://localhost:8080/ty/a3.jsp" method="POST">
- Enter the user name:
- <input type="text" name="a">
- <br><br>
- <input type="Submit" value="Submit"/>
- </form>
- </BODY>
- </HTML>
- A3 :
- <%@ page language="java" import="java.util.*" %>
- <%
- String name,date;
- name=request.getParameter("a");
- Date d=new Date();
- date=d.toLocaleString();
- String s[]=date.split(" ");
- out.println(" Current date and time is:"+date);
- if(d.getHours() < 12 && s[4].equals("AM"))
- out.println("<br>Good Morning "+name);
- else
- if(d.getHours()==12 && s[4].equals("PM"))
- out.println("<br>Good Afternoon "+name);
- else
- if(d.getHours()<6 && s[4].equals("PM"))
- out.println("<br>Good Afternoon "+name);
- else
- if(d.getHours()>=6 && s[4].equals("PM"))
- out.println("<br>Good Evening "+name);
- %>
- Q2 :
- class MyThread extends Thread{
- public MyThread(String s){
- super(s);
- }
- public void run(){
- System.out.println(getName()+" thread created.");
- while(true){
- System.out.println(this);
- int s = (int)(Math.random()*5000);
- System.out.println(getName()+" is sleeping for "+s+"msec");
- try{
- Thread.sleep(s);
- }catch(Exception e){}
- }
- }
- }
- class ThreadLifeCycle{
- public static void main(String args[]){
- MyThread t1 = new MyThread("archana"),
- t2 = new MyThread("adhira");
- t1.start();
- t2.start();
- try{
- t1.join();
- t2.join();
- }catch(Exception e){}
- System.out.println(t1.getName()+" thread dead.");
- System.out.println(t2.getName()+" thread dead.");
- }
- }
- Q3 :
- <?php echo"<table border=1>"; foreach($_SERVER as $k=>$v)
- { echo"<tr><td>".$k."</td><td>".$v."</td></tr>"; } echo"</table>"; ?>
- Q4 :
- Slip no 17
- Q1 :
- class slip17
- {
- public static void main(String a[])
- {
- String S;
- int p;
- Thread t = Thread.currentThread();
- S = t.getName();
- System.out.println("\n Current Thread name : "+S);
- p = t.getPriority();
- System.out.println("\n Current thread priority : "+p);
- t.setName("My Thread");
- S = t.getName();
- System.out.println("\nChanged Name : "+S);
- t.setPriority(2);
- p = t.getPriority();
- System.out.println("\nChanged Priority : "+p);
- }
- }
- Q2 :
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import java.sql.*;
- class DDLOperations extends JFrame{
- private JPanel panNorth,panSouth;
- private JLabel lblQuery;
- private JTextArea txtQuery;
- private JButton btnCreate,btnAlter,btnDrop;
- public DDLOperations(){
- lblQuery = new JLabel("Type DDL Query");
- txtQuery = new JTextArea(4,50);
- panNorth = new JPanel();
- panNorth.add(lblQuery);
- panNorth.add(new JScrollPane(txtQuery));
- btnCreate = new JButton("Create Table");
- btnAlter = new JButton("Alter Table");
- btnDrop = new JButton("Drop Table");
- panSouth = new JPanel();
- panSouth.add(btnCreate);
- panSouth.add(btnAlter);
- panSouth.add(btnDrop);
- setTitle("DDL Operations");
- setSize(400,300);
- add(panNorth,"North");
- add(panSouth,"South");
- setVisible(true);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- ButtonHandler bh = new ButtonHandler();
- btnCreate.addActionListener(bh);
- btnAlter.addActionListener(bh);
- btnDrop.addActionListener(bh);
- }
- class ButtonHandler implements ActionListener{
- public void actionPerformed(ActionEvent ae){
- try{
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:lab.dsn");
- String sql = txtQuery.getText();
- Statement s = con.createStatement();
- s.execute(sql);
- txtQuery.setText("");
- }
- catch(Exception e){
- JOptionPane.showMessageDialog(null,e);
- }
- }
- }
- public static void main(String args[]){
- new DDLOperations();
- }
- }
- Q3 :
- Html file :
- <html>
- <body>
- <form action=Que14.php method=get>
- <center>
- Full Name :<input type=text name=nm> <br>
- <font color=red size=2>(Format is:First,Middle,Surname) </font>
- <br>Email ID :<input type=text name=eid>
- <br><input type=submit value=Show>
- </center>
- </form>
- </body> </html>
- Php file :
- <?php
- $nm=$_GET['nm'];
- $eid=$_GET['eid'];
- echo "<br>Capitalization of each word of each name :".ucwords($nm);
- $e=explode('@',$eid);
- If (count($e)==2)
- {
- echo "<br>Email id contains @ symbol ";
- }
- else
- echo "<br>email id doesn’t contains @ symbol or contains more @ symbol";
- ?>
- Q4 :
- Html file :
- <html>
- <head>
- <title>login</title> </head>
- <body>
- <center> <form action="slip_16.php" method="post"> <table>
- <tr><td><label>Email id :</label></td>
- <td><input type=text name=emailid></td></tr>
- <tr><td><label >Password :</label></td>
- <td><input type=password name=password></td></tr>
- <tr><td><input type=submit value="login & continue"></td>
- <td></td></tr>
- </table>
- </form> </center>
- </body> </html>
- Php file :
- <?php
- $con=mysql_connect("localhost","root","") or die("I cannot connect");
- //echo "connected successfuly";
- $d=mysql_select_db("bca_programs",$con);
- $q=mysql_query("select * from login");
- $emailid=$_REQUEST['emailid'];
- //echo $emailid;
- $password=$_REQUEST['password'];
- $n=0;
- while($row=mysql_fetch_array($q))
- {
- if($row[0]==$emailid && $row[1]==$password)
- $n=1;
- }
- if($n==1)
- echo "<center><h3>WELCOME USER</h3><center>";
- else
- echo "<i>Emailid or Password Missmatch</i>";
- ?>
- Slip no 18
- Q1 :
- class PrintDemo
- {
- public void printCount()
- {
- try
- {
- for(int i = 5; i > 0; i--)
- {
- System.out.println("Counter --- " + i );
- }
- }
- catch (Exception e)
- {
- System.out.println("Thread interrupted.");
- }
- }
- }
- class ThreadDemo extends Thread
- {
- private Thread t;
- private String threadName;
- PrintDemo PD;
- ThreadDemo( String name, PrintDemo pd)
- {
- threadName = name;
- PD = pd;
- }
- public void run()
- {
- synchronized(PD)
- {
- PD.printCount();
- }
- System.out.println("Thread " + threadName + " exiting.");
- }
- public void start ()
- {
- System.out.println("Starting " + threadName );
- if (t == null)
- {
- t = new Thread (this, threadName);
- t.start ();
- }
- }
- }
- public class slip18
- {
- public static void main(String a[])
- {
- PrintDemo PD = new PrintDemo();
- ThreadDemo T1 = new ThreadDemo( "Thread - 1 ", PD );
- ThreadDemo T2 = new ThreadDemo( "Thread - 2 ", PD );
- T1.start();
- T2.start();
- // wait for threads to end
- try
- {
- T1.join();
- T2.join();
- }
- catch( Exception e)
- {
- }
- }
- }
- Q2 :
- import java.io.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import java.util.*;
- public class info_check extends HttpServlet
- {
- public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
- {
- try
- {
- res.setContentType("text/html");
- PrintWriter out = res.getWriter();
- out.println("<html>");
- out.println("<body>");
- java.util.Properties p=System.getProperties();
- out.println("Server Name :"+req.getServerName()+"<br>");
- out.println("Operating System Name :"+p.getProperty("Linux")+"<br>");
- out.println("IP Address :"+req.getRemoteAddr()+"<br>");
- out.println("Remote User:"+req.getRemoteUser()+"<br>");
- out.println("Remote Host:"+req.getRemoteHost()+"<br>");
- out.println("Local Name :"+req.getLocalName()+"<br>");
- out.println("Server Port:"+req.getServerPort()+"<br>");
- out.println("Servlet Name :"+this.getServletName()+"<br>");
- out.println("Protocol Name :"+req.getProtocol()+"<br>");
- out.println("</html>");
- out.println("</body>");
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- Q3 :
- Html file :
- <slip_18.html>
- <html> <body>
- <form action="slip_18.php" method="get">
- <center> <h2> Enployee Details :</h2>
- <br> <table>
- <tr> <td><input type=radio name=r value="1"></td>
- <td><b>Create Employee Table:</b></td>
- </tr>
- <tr> <td><input type=radio name=r value="2"></td>
- <td><b> Read/Insert Values :</b></td>
- </tr>
- <tr>
- <td><input type=radio name=r value="3"></td>
- <td><b>Update Values :</b></td>
- </tr>
- <tr>
- <td><input type=radio name=r value="4"></td>
- <td><b>Display :</b>
- </td>
- </tr>
- </table> <br> <input type=submit value=Submit name=submit> </center> </form>
- </body> </html>
- Php file :
- (slip_18.php) :
- <?php
- $r=$_GET['r'];
- $con = mysql_connect("localhost","root","");
- $d = mysql_select_db("bca_programs",$con);
- if($r==1)
- {
- $q=mysql_query("create table emp_slip_18(empno int,ename varchar(10),date_of_join date,salary int,address varchar(20))");
- echo "<center><b><h2> Table Created Successfully.....!!!</h2><b></center>";
- }
- else if($r==2)
- {
- header("location:slip_18_insert.html");
- }
- /*$q2=mysql_query("insert into emp_slip_18 values($a_no,'$a_name','$d_join',$a_sal,'$a_add')");
- echo "<center><b><h2> Values Inserted Successfully.....!!!</h2><b></center>"; */
- else if($r==3)
- {
- header("location:slip_18update.html");
- }
- else if($r==4)
- {
- $q4=mysql_query("select *from emp_slip_18");
- echo "<center>";
- echo "<table border=1 width=30% height=20%>";
- echo "<h2><tr><td><b> Emp No </b></td><td> <b>Employee Name<b> </td><td> <b>Date Of Joining <b></td><td> <b>Salary <b></td><td> <b>Address<b> </td></tr></h2>"; while($row=mysql_fetch_array($q4))
- {
- echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[ 3]."</td><td>".$row[4]."</td></tr>"; }
- echo "</table>";
- echo "</center>";
- }
- ?>
- <slip_18_insert.html> :
- <html> <body>
- <form action="slip_18_insert.php" method="get"> <center> <h2>Enter Enployee Details :</h2> <br> <table>
- <tr> <td>Enter Employee no :</td
- ><td><input type=text name=a_no> </td>
- </tr>
- <tr> <td>Enter Employee name :</td>
- <td><input type=text name=a_name></td> </tr>
- <tr> <td>Enter Date Of Join :</td><td><input type=text name=d_join></td> </tr>
- <tr> <td>Enter Salary :</td>
- <td><input type=text name=a_sal></td>
- </tr>
- <tr>
- <td>Enter Address :</td>
- <td><input type=text name=a_add></td>
- </tr>
- <tr>
- <td><input type=submit value=Show name=submit></td>
- </tr>
- </table> </center> </form>
- </body> </html>
- (slip_18_insert.html) :
- <html> <body>
- <form action="slip_18_insert.php" method="get">
- <center>
- <h2>Enter Enployee Details :</h2>
- <br>
- <table>
- <tr>
- <td>Enter Employee no :</td>
- <td><input type=text name=a_no> </td>
- </tr>
- <tr>
- <td>Enter Employee name :</td>
- <td><input type=text name=a_name></td> </tr>
- <tr> <td>Enter Date Of Join :</td>
- <td><input type=text name=d_join></td> </tr>
- <tr> <td>Enter Salary :</td><td><input type=text name=a_sal></td> </tr>
- <tr> <td>Enter Address :</td><td><input type=text name=a_add></td> </tr>
- <tr> <td><input type=submit value=Show name=submit></td> </tr>
- </table> </center>
- </form>
- </body> </html>
- (slip_18_insert.php) :
- <?php
- $a_no=$_GET['a_no'];
- $a_name=$_GET['a_name'];
- $d_join=$_GET['d_join'];
- $a_sal=$_GET['a_sal'];
- $a_add=$_GET['a_add'];
- $con = mysql_connect("localhost","root","");
- $d = mysql_select_db("bca_programs",$con);
- $q2=mysql_query("insert into emp_slip_18 values($a_no,'$a_name','$d_join',$a_sal,'$a_add')");
- echo "<center><b><h2> Values Inserted Successfully.....!!!</h2><b></center>";
- ?>
- (slip_18_update.html) :
- <?php
- $edit=$_GET['edit'];
- $c=mysql_connect("localhost","root","");
- $d=mysql_select_db("bca_programs",$c);
- $q=mysql_query("select * from emp_slip_18");
- $row=mysql_fetch_array($q);
- ?>
- <html>
- <body>
- <form action="slip_18_update.php" method="get"> <center> <h2>Update Enployee Details :</h2> <br>
- <table>
- <tr> <td> Employee no :</td>
- <td><input type=text name=a_no value="<?php echo $row[0];?>"> </td> </tr>
- <tr> <td> Employee name :</td><td><input type=text name=a_name value="<?php echo $row[1];?>"></td>
- </tr>
- <tr> <td> Date Of Join :</td><td><input type=text name=d_join value="<?php echo $row[2];?>"></td> </tr> <tr> <td> Salary :</td><td><input type=text name=a_sal value="<?php echo $row[3];?>"></td> </tr> <tr> <td> Address :</td><td><input type=text name=a_add value="<?php echo $row[4];?>"></td> </tr>
- <tr> <td><input type=submit value=Show name=submit></td> </tr>
- </table> </center> </form>
- </body> </html>
- (slip_18_update1.php) :
- <?php
- $a_no=$_GET['a_no'];
- $a_name=$_GET['a_name'];
- $d_join=$_GET['d_join'];
- $a_sal=$_GET['a_sal'];
- $a_add=$_GET['a_add'];
- $con = mysql_connect("localhost","root","");
- $d = mysql_select_db("bca_programs",$con);
- $r=mysql_query("update emp_slip_18 setempno=$a_no,ename='$a_name',date_of_join='$d_join',salary='$a_sal',address ='$a_add' where empno=$a_no");
- ?>
- Slip no 19
- Q1 :
- <html>
- <body>
- <form method=get action="slip19_1.jsp">
- Enter Any Number : <input type=text name=num><br><br>
- <input type=submit value="Display">
- </form>
- </body>
- </html>
- Slip19_1.jsp :
- <%@page language="java"%>
- <html>
- <body>
- <font color=red>
- <%! int i,n;
- String s1;
- %>
- <% s1=request.getParameter("num");
- n=s1.length();
- i=0;
- do
- {
- char ch=s1.charAt(i);
- switch(ch)
- {
- case '0': out.println("Zero ");break;
- case '1': out.println("One ");break;
- case '2': out.println("Two ");break;
- case '3': out.println("Three ");break;
- case '4': out.println("Four ");break;
- case '5': out.println("Five ");break;
- case '6': out.println("Six ");break;
- case '7': out.println("Seven ");break;
- case '8': out.println("Eight ");break;
- case '9': out.println("Nine ");break;
- }
- i++;
- }while(i<n);
- %>
- </font>
- </body>
- </html>
- Q2 :
- Applet :
- <html>
- <body>
- <applet code="Smile.class" height=200 width=200>
- </applet>
- </body>
- </html>
- Smile :
- import java.applet.Applet;
- import java.io.*;
- import java.awt.*;
- import java.util.*;
- public class Smile extends Applet implements Runnable
- {
- Thread t;
- int x=0;
- public void run()
- {
- repaint();
- }
- public void init()
- {
- Smile s1=new Smile();
- t=new Thread(s1);
- t.start();
- setSize(500,500);
- setBackground(Color.blue);
- }
- public void paint(Graphics g)
- {
- if(x==0)
- {
- g.drawOval(40,40,130,130);
- g.drawOval(57,75,20,20);
- g.drawOval(110,75,20,20);
- g.drawArc(60,110,80,40,180,180);
- x=1;
- }
- else if(x==1)
- {
- g.drawOval(40,40,130,130);
- g.drawOval(57,75,20,20);
- g.drawOval(110,75,20,20);
- g.drawArc(60,110,80,40,-180,-180);
- x=0;
- }
- try
- {
- Thread.sleep(2000);
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- repaint();
- }
- }
- Q3 :
- php file :
- <html>
- <body> <form method=post action="<?php echo $_SERVER['PHP_SELF'] ?>">
- Enter String : <input type=text name=str1><br>
- <input type=submit name=submit>
- </form>
- <?php
- if(isset($_POST['submit']))
- {
- $str=$_POST['str1'];
- $nstr=strrev($str);
- echo"<br>".$nstr;
- }
- ?>
- </body> </html>
- Q4 :
- Html file :
- <html> <body>
- <form action="slip_19.php" method="get"> <b>Enter the title of project :: </b>
- <input type=text name=ptitle><br>
- <input type=submit value=SUBMIT>
- </form>
- </body>
- <html>
- Php file :
- <?php
- $ptitle = $_GET['ptitle'];
- $con = mysql_connect("localhost","root","");
- $d = mysql_select_db("bca_programs",$con);
- $q = mysql_query("select s_name from student_slip19,project where project_title='$ptitle' && student_slip19.p_group_no=project.p_group_no");
- echo "Student Name :<br>";
- while($row = mysql_fetch_array($q))
- {
- echo $row['s_name'];
- }
- mysql_close();
- ?>
- Slip no 21
- Q1 :
- import java.sql.*;
- class slip21
- {
- public static void main(String args[])
- { Connection con;
- try
- {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:dsn");
- System.out.println("Connection Established...");
- Statement stmt=con.createStatement();
- ResultSet rs=stmt.executeQuery("select * from employee where name like 'S%'");
- System.out.println("eno\t"+"ename\t"+"department\t"+"sal");
- while(rs.next())
- {
- System.out.println("\n"+rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getString(3)+"\t"+rs.getInt(4));
- }
- }
- catch(Exception e)
- {
- }
- }
- }
- Q2 :
- set2bn :
- import java.io.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
- public class setb2n extends HttpServlet
- {
- public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
- {
- PrintWriter out = null;
- try
- {
- out=res.getWriter();
- Cookie c[]=req.getCookies();
- for(int i=0;i<c.length;i++)
- {
- String s1=c[i].getName();
- out.println("selected hobby are :"+s1);
- }
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- Setb21 :
- import java.io.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
- public class Setb21 extends HttpServlet {
- public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
- {
- PrintWriter out = null;
- try
- {
- out=res.getWriter();
- String hb=req.getParameter("ch");
- Cookie c1=new Cookie("hobby",hb);
- out.println("hobby are:"+hb);
- //res.addCookie(c1);
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- Html :
- <html>
- <body>
- <form method="GET" action="http://localhost:8080/choice">
- select your hobbie:<br>
- <input type="radio" name="ch" value="painting">PAINTING<br>
- <input type="radio" name="ch" value="drawing">DRAWING<br>
- <input type="radio" name="ch" value="swiming">SWIMING<br>
- <input type="radio" name="ch" value="singing">SINGING<br>
- <br><input type="submit" value="select">
- <br><input type="reset">
- </form>
- </body>
- </html>
- Q3 :
- Php file :
- <html> <body>
- <FORM ACTION="<?php $_SERVER['PHP_SELF']; ?>" method="POST">
- Enter first no :<input type=text name=no1 ><br>
- Enter second no :<input type=text name=no2><br>
- Select Operation which u have to perform :
- <select name=cal>
- <option value="1">Addition</option>
- <option value="2">Substraction</option>
- <option value="3">Multiplication</option>
- <option value="4">Division</option>
- </select><br>
- <input type=submit name=submit value=Calculate>
- </form>
- </body>
- </html>
- <?php
- if(isset($_POST['submit']))
- {
- $no1=$_POST['no1'];
- $no2=$_POST['no2'];
- $cal=$_POST['cal'];
- if((!empty($no1)) && (!empty($no2)))
- {
- switch($cal)
- {
- case 1:
- $add=$no1+$no2;
- echo "addition=".$add;
- break;
- case 2:
- $sub=$no1-$no2;
- echo "subtraction=".$sub;
- break;
- case 3:
- $mult=$no1*$no2;
- echo "multiplication=".$mult;
- break;
- case 4:
- $div=$no1/$no2;
- echo "division=".$div;
- break;
- }
- }
- else echo "Please enter both 2 nos";
- }
- else
- die("not able to acccess");
- ?>
- Q4 :
- Html file :
- <html>
- <body> <form action="slip_21.php" method="get">
- Enter the Name Of Hospital : <input type=text name=hosp><br>
- <input type=submit value=SUBMIT>
- </form>
- </body>
- <html>
- Php file :
- <?php
- $hosp=$_GET['hosp'];
- $con=mysql_connect("localhost","root","");
- $d=mysql_select_db("bca_programs",$con);
- $q=mysql_query("select doctor.doc_no,doc_name,address,city,area from doctor,hospital,doc_hosp where hosp_name='$hosp' and doc_hosp.doc_no=doctor.doc_no and doc_hosp.hosp_no=hospital.hosp_no");
- echo "<tr><td>Doctor no--</td><td>Doctor Name--</td><td>Address-</td><td>city--</td><td>Area</td></tr>";
- while($row=mysql_fetch_array($q))
- {
- echo "<br><tr><td>".$row[0]." | </td><td>".$row[1]." | </td><td>".$row[2]." | </td><td>".$row[3]." |</td><td>".$row[4]." |</td></tr>";
- }
- mysql_close();
- ?>
- Slip no 22
- Q1 :
- //server.java :
- import java.net.*;
- import java.io.*;
- public class server
- {
- public static void main(String args[])
- {
- try
- {
- ServerSocket ss =new ServerSocket(2222);
- System.out.println("Server is started");
- while(true)
- {
- Socket s=ss.accept();
- System.out.print("Connection request Received");
- InputStream is=s.getInputStream();
- InputStreamReader isr= new InputStreamReader(is);
- BufferedReader br=new BufferedReader(isr);
- OutputStream os=s.getOutputStream();
- PrintWriter pw= new PrintWriter(os,true);
- String no= br.readLine();
- //System.out.print("no:"+ " " + (char)no);
- int no1=Integer.parseInt(no);
- int fact=1,i=0;
- while(no1>i)
- {
- fact=fact*no1;
- no1--;
- //System.out.println("fact="+fact+"no="+no1);
- }
- pw.println(fact);
- s.close();
- }
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- //client.java :
- import java.net.*;
- import java.io.*;
- public class client
- {
- public static void main(String args[])
- {
- try
- {
- Socket s = new Socket("localhost",2222);
- InputStream is=s.getInputStream();
- InputStreamReader isr= new InputStreamReader(is);
- BufferedReader br=new BufferedReader(isr);
- OutputStream os=s.getOutputStream();
- PrintWriter pw= new PrintWriter(os,true);
- String msg="5";
- pw.println(msg);
- msg=br.readLine();
- int gh=Integer.parseInt(msg) ;
- System.out.println("factorial="+gh);
- s.close();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- Q2 :
- import java.sql.*;
- import java.io.*;
- import javax.sql.*;
- class slip6
- {
- public static void main(String args[])
- {
- Connection con;
- Statement state;
- ResultSet rs;
- int ch;
- boolean flag=true;
- String decision;
- int no;
- try
- {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con = DriverManager.getConnection("jdbc:odbc:lab.dsn");
- System.out.println("Statement object created");
- do
- {
- System.out.println("\n");
- System.out.println("Menu:");
- System.out.println("1.create Table");
- System.out.println("2.Insert Record into the Table");
- System.out.println("3.Display all the Records from the Table");
- System.out.println("4.Exit");
- System.out.println("Enter your choice: ");
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- ch=Integer.parseInt(br.readLine());
- switch(ch)
- {
- case 1:
- state=con.createStatement();
- String query="create table student"+"(rno int ,"+" sname varchar(20),"+" per int,"+" address varchar(20))";
- state.executeUpdate(query);
- System.out.println("Table created");
- case 2:
- System.out.println("Enter student Number: ");
- int rno=Integer.parseInt(br.readLine());
- System.out.println("Enter student Name: ");
- String sname=br.readLine();
- System.out.println("Enter per: ");
- int per=Integer.parseInt(br.readLine());
- System.out.println("Enter address: ");
- String address=br.readLine();
- String sql="insert into student values(?,?,?,?)";
- PreparedStatement p=con.prepareStatement(sql);
- p.setInt(1,rno);
- p.setString(2,sname);
- p.setInt(3,per);
- p.setString(4,address);
- p.executeUpdate();
- System.out.println("Record Added");
- break;
- case 3:
- state=con.createStatement();
- sql="select * from student";
- rs=state.executeQuery(sql);
- while(rs.next())
- {
- System.out.println("\n");
- System.out.print("\t" +rs.getInt(1));
- System.out.print("\t" +rs.getString(2));
- System.out.print("\t" +rs.getInt(3));
- System.out.print("\t" +rs.getString(4));
- }
- break;
- case 4:
- System.exit(0);
- default:
- System.out.println("Invalid Choice");
- break;
- }
- }while(ch!=4);
- }catch(Exception e)
- {
- System.out.println(e);
- }
- }
- }
- Q3 :
- Html file :
- <html> <head> <title> Number of times the web page has been viited.</title> </head>
- <body>
- <?php
- session_start();
- if(isset($_SESSION['count']))
- $_SESSION['count']=$_SESSION['count']+1;
- else
- $_SESSION['count']=1;
- echo "<h3>This page is accessed</h3>".$_SESSION['count'];
- ?>
- Q4 :
- html file :
- <html> <body> <form action="slip_22.php" method="get">
- <h3>Enter Actor Name : <input type=text name=nm> </h3>
- <input type=radio name=a value=1>Display Movie Name<br><br>
- <h3>Enter movie no :<input type=text name=m_no> </h3>
- <h3>Enter movie name :<input type=text name=m_nm></h3>
- <h3>Enter release year :<input type=text name=r_yr> </h3>
- <h3>Enter actor no :<input type=text name=a_no> </h3>
- <h3>Enter actor name :<input type=text name=a_nm> </h3>
- <input type=radio name=a value=2>Insert New movie info<br><br>
- <input type=submit value=OK> </form>
- <div id="place">
- </div>
- </body>
- </html>
- php file :
- <?php
- $r = $_GET['a'];
- $con = mysql_connect("localhost","root","");
- $d = mysql_select_db("bca_programs",$con);
- if($r == 1)
- {
- $actor_name = $_GET['nm'];
- $q = mysql_query("select m_name from movie,actor,movie_actor where movie.m_no=movie_actor.m_no and actor.a_no=movie_actor.a_no and a_name='$actor_name'");
- echo "<br>Movie Name </br>";
- while($row=mysql_fetch_array($q))
- {
- echo $row[0]."<br>";
- }
- }
- else if($r == 2)
- {
- $m_no = $_GET['m_no'];
- $m_name = $_GET['m_nm'];
- $r_yr = $_GET['r_yr'];
- $a_no = $_GET['a_no'];
- $a_name = $_GET['a_nm'];
- $q = mysql_query("insert into movie values($m_no,'$m_name',$r_yr)");
- $q1 = mysql_query("insert into actor values($a_no,'$a_name')");
- echo "Value Inserted";
- }
- mysql_close();
- ?>
- Slip no 23
- Q1 :
- <html>
- <head>
- <body>
- <h1>Enter Information</h1>
- <form action="slip23_1.jsp" method="post">
- Roll No : <input type="text" name="rno"><br><br>
- Name : <input type="text" name="name"><br><br>
- Gender : <input type="radio" name="gender" value="Male" checked>Male
- <input type="radio" name="gender" value="Female">Female
- <br><br>
- Comp_Know : <input type="radio" name="know" value="Yes" checked>Yes
- <input type="radio" name="know" value="No">No
- <br><br>
- Class : <select name="Class">
- <option value="11">11Th</option>
- <option value="12">12Th</option>
- <option value="FY">FY</option>
- <option value="SY">SY</option>
- <option value="TY">TY</option>
- </select>
- <br><br>
- <input type="submit" value="Submit">
- </form>
- </body>
- </html>
- Slip23_1.jsp :
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <%
- int rno = Integer.parseInt(request.getParameter("rno"));
- String s_name = request.getParameter("name");
- String s_gender = request.getParameter("gender");
- String s_know = request.getParameter("know");
- String s_class = request.getParameter("Class");
- out.println("\nRoll No :"+rno);
- out.println("\nName :"+s_name);
- out.println("\nGender :"+s_gender);
- out.println("\nComp_Know :"+s_know);
- out.println("\nClass :"+s_class);
- %>
- Q2 :
- import java.sql.*;
- import java.io.*;
- import javax.sql.*;
- class Elements{
- public static void main(String args[]){
- try{
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:lab.dsn");
- Statement s=null;
- PreparedStatement ps=null;
- ResultSet rs=null;
- char ch = args[0].charAt(0);
- String name="",symbol="";
- int weight=0;
- switch(ch)
- {
- case 'R':
- s = con.createStatement();
- rs = s.executeQuery("select * from elements");
- while(rs.next()){
- System.out.println(rs.getInt(1)+"\t"+
- rs.getString(2)+"\t"+
- rs.getString(3));
- }
- break;
- case 'D':
- name = args[1];
- ps = con.prepareStatement("delete from elements where name=?");
- ps.setString(1,name);
- if(ps.executeUpdate()==1)
- System.out.println("Element "+name+" deleted successfully.");
- else
- System.out.println("Element "+name+" not found.");
- break;
- case 'U':
- weight = Integer.parseInt(args[1]);
- name = args[2];
- symbol = args[3];
- ps = con.prepareStatement("update elements set atomic_weight=?,chemical_symbol=? where name=?");
- ps.setInt(1,weight);
- ps.setString(2,symbol);
- ps.setString(3,name);
- if(ps.executeUpdate()==1)
- System.out.println("Element "+name+" updated successfully.");
- else
- System.out.println("Element "+name+" not found.");
- }
- con.close();
- }
- catch(Exception e){
- System.out.println(e);
- }
- }
- }
- Q3 :
- Book.xml :
- <?xml version="1.0"?>
- <BookStore>
- <Books>
- <PHP>
- <title>Programming PHP</title>
- <publication>O’RELLY</publication>
- </PHP>
- <PHP>
- <title>Beginners PHP</title>
- <publication>WROX</publication>
- </PHP>
- </Books>
- </BookStore>
- Book.php :
- <html>
- <body>
- <?php $xml=simplexml_lode_file('book.xml')or die("Cannot Die!!!");
- ?>
- <center><b>...BOOK DETAILS...</B><center>
- <table border='2'> <th>Book title</th>
- <th>Publication</th>
- <?php
- foreach($xml->book as $a)
- {
- echo"<tr><td>".$a['Book title']."</td>"; echo"<tr><td>".$a['Publication']."</td></tr>"; }
- ?>
- </table>
- </body> </html>
- Q4 :
- Html file :
- <html>
- <body>
- <form action="slip_23.php" method="get"> <center>
- <h3>Enter the Bill Number : <input type=text name=bno><br></h3>
- <input type=submit value=SUBMIT></center>
- </form> </body> <html>
- Php file :
- <?php
- $bno = $_GET['bno'];
- $con = mysql_connect("localhost","root","");
- $d = mysql_select_db("bca_programs",$con);
- $q = mysql_query("select * from bill_master where bill_no=$bno");
- echo "<center>";
- while($row = mysql_fetch_array($q))
- {
- echo " <h3><br>Bill No : ".$row[0]."Bill Date : ".$row[2]."</h3>";
- echo "<h3>Customer Name : ".$row[1]."</h3>";
- }
- $i=1;
- $gt=0;
- $q1=mysql_query("select item_name,qty,rate,discount from bill_details,bill_master where bill_details.bill_no=$bno and bill_details.bill_no=bill_master.bill_no");
- echo "<table border=1 width=30% height=10%>";
- echo "<tr><td><b> SrNo. </b></td> <td><b> Particular </b></td> <td><b> Quantity </b></td> <td><b> Rate </b></td> <td><b> Total </b></td></tr>"; while($row1=mysql_fetch_array($q1))
- {
- $t=$row1[1]*$row1[2];
- echo "<br><tr><td>".$i++."</td><td>".$row1[0]."</td><td>".$row1[1]."</td><td>".$r ow1[2]."</td><td>".$t."</td><tr>";
- $gt+=$t;
- }
- echo "</table>";
- echo "<br><b> Gross Ammount is :: ".$gt."</b>";
- echo "<center>";
- mysql_close();
- ?>
- Slip no 24
- Q1 :
- <html>
- <body>
- <form name=f1 action="EmailCheck.jsp">
- <fieldset>
- <legend>Enter Email Id...!!!</legend>
- Enter Email Id:<input type="text" name="t1" >
- </fieldset>
- <div align=center>
- <input type="submit" name="Submit" value="Submit">
- </div>
- </form>
- </body>
- </html>
- Emailcheck.jsp :
- <html>
- <body>
- <%@ page language="java" %>
- <%
- String email=request.getParameter("t1");
- if(email.contains("@") && email.contains("."))
- {
- out.println("Given Email Id is Valid");
- }
- else {
- out.println("Given Email id is not Valid");
- }
- %>
- </body>
- </html>
- Q2 :
- import java.sql.*;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- class College extends JFrame{
- private JLabel lblID,lblName,lblAddr,lblYear;
- private JTextField txtID,txtName,txtAddr,txtYear;
- private JButton btnSave,btnClose;
- private JPanel panCenter,panSouth;
- private Connection con;
- private PreparedStatement ps;
- public College(){
- lblID = new JLabel("College ID:");
- lblName = new JLabel("College Name:");
- lblAddr = new JLabel("Address:");
- lblYear = new JLabel("Year:");
- txtID = new JTextField();
- txtName = new JTextField();
- txtAddr = new JTextField();
- txtYear = new JTextField();
- panCenter = new JPanel();
- panCenter.setLayout(new GridLayout(4,2));
- panCenter.add(lblID);
- panCenter.add(txtID);
- panCenter.add(lblName);
- panCenter.add(txtName);
- panCenter.add(lblAddr);
- panCenter.add(txtAddr);
- panCenter.add(lblYear);
- panCenter.add(txtYear);
- btnSave = new JButton("Save");
- btnClose = new JButton("Close");
- panSouth = new JPanel();
- panSouth.add(btnSave);
- panSouth.add(btnClose);
- setTitle("College Information");
- setSize(400,200);
- setLocation(100,100);
- add(panCenter,"Center");
- add(panSouth,"South");
- setVisible(true);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- try{
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:lab.dsn");
- }
- catch(Exception e){
- JOptionPane.showMessageDialog(null,e);
- dispose();
- }
- btnSave.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent ae){
- try{
- int cid = Integer.parseInt(txtID.getText());
- String cname = txtName.getText();
- String addr = txtAddr.getText();
- int yr = Integer.parseInt(txtYear.getText());
- ps = con.prepareStatement("insert into college values(?,?,?,?)");
- ps.setInt(1,cid);
- ps.setString(2,cname);
- ps.setString(3,addr);
- ps.setInt(4,yr);
- ps.executeUpdate();
- txtID.setText("");
- txtName.setText("");
- txtAddr.setText("");
- txtYear.setText("");
- txtID.requestFocus();
- }
- catch(Exception e){
- JOptionPane.showMessageDialog(null,e);
- }
- }
- });
- btnClose.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent ae){
- dispose();
- }
- });
- }
- Q3 :
- ADDITION.html :
- <html>
- <script language="javascript">
- var req=false;
- if(window.XMLHttpRequest)
- {
- req=new XMLHttpRequest();
- }
- else if(window.ActiveXObject)
- {
- req=new ActiveXObject("Microsoft.XMLHttp");
- }
- function add(url,divID) {
- if(req)
- {
- req.open("POST",url);
- req.onreadystatechange=function()
- {
- if(req.readyState==4 && req.status==200)
- {
- document.getElementById(divID).innerHTML=req.responseText;
- }
- }
- req.send();
- }
- }
- function ad(divID)
- {
- var t1=ducument.f1.t1value;
- var t2=document.f1.t1.value;
- var url="Addx.php?t1="+t1+"&t2="+t2;
- add(url,divID);
- }
- </script>
- <body>
- <form name=f1> No. 1 :<input type=text name=t1><br><br>
- No. 2 :<input type=text name=t2><br><br>
- <input type=button value=add onClick="ad('mydiv')"> </form>
- <div id="mydiv"> </div>
- </body>
- </html>
- Q4 :
- BOOK.XML :
- <?xml version="1.0"?>
- <BookStore>
- <Books>
- <PHP>
- <title>Programming PHP</title>
- <publication>O’RELLY</publication>
- </PHP>
- <PHP>
- <title>Beginners PHP</title>
- <publication>WROX</publication>
- </PHP>
- </Books>
- </BookStore>
- BOOK.PHP :
- <?php
- $xml=simplexml_load_sreing($myXMLData) or die(“Error : Create object”);
- print_r($xml);
- ?>
- Slip no 25
- Q1 :
- <%@page language="java"%>
- <html>
- <body>
- <%!int cnt=0;
- String uname,nname;%>
- <%
- uname=request.getParameter("a");
- nname=request.getParameter("b");
- cnt++;
- if(cnt%2==0)
- out.println("HEllo"+nname+"..visit count"+cnt);
- else
- out.println("HEllo"+uname+"..visit count"+cnt);
- %>
- <a href="slip25-1.jsp">Visit</a>
- </body>
- </html>
- Slip25-1.jsp :
- <HTML>
- <HEAD>
- <TITLE> 4.JSP SET B:1 </TITLE>
- </HEAD>
- <BODY>
- <form action="http://localhost:8080/ty/slip25.jsp" method="POST">
- Enter the user name:
- <input type="text" name="a">
- <br><br>
- Enter the nick name:
- <input type="text" name="b">
- <br><br>
- <input type="Submit" value="Submit"/>
- </form>
- </BODY>
- </HTML>
- Q2 :
- import java.io.*;
- import java.sql.*;
- public class slip6
- {
- public static void main(String args[])
- {
- try
- {
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- Connection con=null;
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con = DriverManager.getConnection("jdbc:odbc:lab");
- Statement sta=con.createStatement();
- sta=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
- ResultSet rs=sta.executeQuery("select * from employee");
- for(;;)
- {
- System.out.println("---------MAIN MENU---------");
- System.out.println("1:Next");
- System.out.println("2:First");
- System.out.println("3:Previous");
- System.out.println("4:Last");
- System.out.println("5:Exit");
- System.out.println("ENTER your choice :");
- int choice=Integer.parseInt(br.readLine());
- switch(choice)
- {
- case 1:
- System.out.println("Display next record");
- rs.next();
- System.out.println(" eNo:"+rs.getInt(1));
- System.out.println("eName:"+rs.getString(2));
- System.out.println("sal:"+rs.getFloat(3));
- break;
- case 2:
- System.out.println("Display first record");
- rs.first();
- System.out.println("eNo:"+rs.getInt(1));
- System.out.println("eName:"+rs.getString(2));
- System.out.println("sal:"+rs.getFloat(3));
- break;
- case 3:
- System.out.println("Display previous record");
- rs.previous();
- System.out.println("eNo:"+rs.getInt(1));
- System.out.println("eName:"+rs.getString(2));
- System.out.println("sal:"+rs.getFloat(3));
- break;
- case 4:
- System.out.println("Display last record");
- rs.last();
- System.out.println("eNo:"+rs.getInt(1));
- System.out.println("eName:"+rs.getString(2));
- System.out.println("sal:"+rs.getFloat(3));
- break;
- case 5:
- System.exit(0);
- break;
- }
- }
- }
- catch(Exception e)
- {
- System.out.println(e);
- }
- }
- }
- Q3 :
- Introspection.php :
- <?php
- class Myclass
- {
- public $a;
- public $b=10;
- public $c='ABC';
- function Myclass()
- {
- //Myclass function
- }
- function myfun1()
- {
- //functin
- }
- function myfun2()
- {
- //functin
- }
- }
- $class=get_declared_classes();
- foreach($class as $cname)
- {
- echo"$cname <br>";
- }
- echo"<br>Class Methods are : <br>";
- $m=get_class_methods('Myclass');
- foreach($m as $mname)
- {
- echo"$mname <br>";
- }
- $cp=get_class_vars('Myclass');
- echo"class variables are :<br>";
- foreach($cp as $cpname => $v)
- {
- echo"$cpname : $v <br>";
- }
- ?>
- Q4 :
- BOOK.XML :
- <?xml version=”1.0” encoding=”utf-8”?>
- <ABCBOOLK>
- <Technical>
- <Book>
- <Book_PubYear>ABC</Book_PubYear>
- <Book_Title>nvdklv </Book_Title>
- <Book_Author>400</Book_Author>
- </Book>
- </Technical>
- <Cooking>
- <Book>
- <Book_PubYear>ABC</Book_PubYear>
- <Book_Title>nvdklv </Book_Title>
- <Book_Author>400</Book_Author>
- </Book>
- </Cooking>
- <Yoga>
- <Book>
- <Book_PubYear>ABC</Book_PubYear>
- <Book_Title>nvdklv </Book_Title>
- <Book_Author>400</Book_Author>
- </Book>
- </Yoga>
- </ABCBOOLK>
- BOOK.php :
- <?php
- $xml=simplexml_load_file("Book.xml") or die("cannnot load");
- $xmlstring=$xml->asXML();
- echo $xmlstring;
- ?>
- Slip no 26
- Q1 :
- import java.io.*;
- import java.util.*;
- class slip26 implements Runnable
- {
- Thread t;
- public slip26()
- {
- t=new Thread(this);
- t.start();
- }
- public void run()
- {
- char ch;
- for (ch='a';ch<='z';ch++)
- {
- System.out.println(ch);
- try
- {
- Thread.sleep(300);
- }
- catch(Exception e)
- {
- }
- }
- }
- public static void main(String args[])
- {
- slip26 s=new slip26();
- }
- }
- Q2 :
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.table.*;
- import java.sql.*;
- import java.util.*;
- import java.text.*;
- class SalesReport extends JFrame{
- private JLabel lblStart,lblEnd;
- private JComboBox cmbStart,cmbEnd;
- private JPanel panNorth;
- private JButton btnShow;
- private JTable tabReport;
- private DefaultTableModel dtm;
- public SalesReport(){
- lblStart = new JLabel("Start Date:");
- lblEnd = new JLabel("End Date:");
- cmbStart = new JComboBox();
- cmbEnd = new JComboBox();
- Calendar calendar = new GregorianCalendar();
- java.util.Date d = new java.util.Date();
- System.out.println(d.getDate());
- calendar.set(Calendar.YEAR, d.getYear()+1900);
- calendar.set(Calendar.MONTH, d.getMonth());
- calendar.set(Calendar.DAY_OF_MONTH, d.getDate());
- for(int i=1000;i>=1;i--){
- String str = calendar.get(Calendar.YEAR)+"-"+
- (calendar.get(Calendar.MONTH)+1)+"-"+
- calendar.get(Calendar.DAY_OF_MONTH);
- cmbStart.addItem(str);
- cmbEnd.addItem(str);
- calendar.add(Calendar.DAY_OF_MONTH, -1);
- }
- btnShow = new JButton("Show");
- panNorth = new JPanel(new GridLayout(1,4));
- panNorth.add(lblStart);
- panNorth.add(cmbStart);
- panNorth.add(lblEnd);
- panNorth.add(cmbEnd);
- panNorth.add(btnShow);
- dtm = new DefaultTableModel();
- dtm.addColumn("PID");
- dtm.addColumn("PName");
- dtm.addColumn("Amount");
- dtm.addColumn("Date");
- tabReport = new JTable(dtm);
- setTitle("Sales Report");
- setSize(400,400);
- add(panNorth,"North");
- add(new JScrollPane(tabReport),"Center");
- setVisible(true);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- btnShow.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent ae){
- try{
- for(int i=0;i<dtm.getRowCount();i++)
- dtm.removeRow(0);
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:lab.dsn");
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
- String sdate = cmbStart.getSelectedItem().toString();
- String edate = cmbEnd.getSelectedItem().toString();
- java.util.Date d = sdf.parse(sdate);
- java.sql.Date newsdate = new java.sql.Date(d.getTime());
- d = sdf.parse(edate);
- java.sql.Date newedate = new java.sql.Date(d.getTime());
- PreparedStatement ps = con.prepareStatement("select * from prod_sales where sale_date between ? and ?");
- ps.setDate(1,newsdate);
- ps.setDate(2,newedate);
- ResultSet rs = ps.executeQuery();
- while(rs.next()){
- Vector v = new Vector();
- v.add(rs.getString(1));
- v.add(rs.getString(2));
- v.add(rs.getString(3));
- v.add(rs.getString(4));
- dtm.addRow(v);
- }
- }
- catch(Exception e){
- JOptionPane.showMessageDialog(null,e);
- }
- }
- });
- }
- public static void main(String args[]){
- new SalesReport();
- }
- }
- Q3 :
- html file :
- <html>
- <body>
- <form action=Que26.php method=GET>
- enter student roll no :<input type=text name=rno><br>
- enter student name : <input type=text name=s_name><br>
- enter class : <input type=text name=cls><br>
- <input type=submit name=submit value=submit >
- </form>
- </body>
- </html>
- Php file :
- <?php
- <?php
- $rno=$_GET['rno'];
- $s_name=$_GET['s_name'];
- $cls=$_GET['cls'];
- $con=mysql_connect("localhost","root","");
- $d=mysql_select_db("bca_programs",$con);
- $q=mysql_query("insert into stud values($rno,'$s_name','$cls')");
- $q1=mysql_query("select * from stud order by sname");
- echo "<table>";
- echo "<tr><td>Roll no.</td><td>Name</td><td>Class</td></tr>";
- while($row=mysql_fetch_array($q1))
- { echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td></tr>";
- }
- echo "</table>";
- mysql_close();
- ?
- Slip no 27
- Q1 :
- import java.io.*;
- import java.sql.*;
- class Deleteemp
- {
- static Connection cn;
- static Statement st;
- static ResultSet rs;
- static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- public static void main(String args[])
- {
- int e,k,ch,sal;
- String en;
- try
- {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- cn=DriverManager.getConnection("jdbc:odbc:Emp","","");
- st=cn.createStatement();
- do
- {
- System.out.println("1. Delete ");
- System.out.println("2. Exit ");
- System.out.println("Enter Ur Choice");
- ch=Integer.parseInt(br.readLine());
- switch(ch)
- {
- case 1:
- System.out.println("Enter the Eno");
- e=Integer.parseInt(br.readLine());
- String sd="delete from emp where eno=" +e;
- k=st.executeUpdate(sd);
- if(k>0)
- {
- System.out.println("Record Is Deleted");
- }
- break;
- case 2:
- System.exit(0);
- }
- }
- while(ch!=2);
- }
- catch(Exception et)
- {
- System.out.println(et);
- }
- }
- }
- Q2 :
- import java.awt.*;
- import java.awt.event.*;
- import java.util.*;
- public class slip27 extends Frame implements
- ActionListener,Runnable
- {
- Button start,stop;
- TextField tf;
- int x=0,y=0;
- String msg="";
- Thread t1=new Thread(this);
- public slip27()
- {
- setLayout(new FlowLayout());
- start=new Button("start");
- stop=new Button("stop");
- add(start);
- add(stop);
- start.addActionListener(this);
- stop.addActionListener(this);
- addWindowListener(new
- WindowAdapter()
- {
- public void
- windowClosing(WindowEvent e)
- {
- System.exit(0);
- }
- });
- setSize(200,200);
- setVisible(true);
- }
- public void actionPerformed(ActionEvent ae)
- {
- Button btn=(Button)ae.getSource();
- if(btn==start)
- {
- t1.start();
- }
- if(btn==stop)
- {
- t1.stop();
- }
- }
- public void run()
- {
- try
- {
- while(true)
- {
- repaint();
- Thread.sleep(350);
- }
- }
- catch(Exception e)
- {
- }
- }
- public void paint(Graphics g)
- {
- int sec,min,hr;
- GregorianCalendar date = new GregorianCalendar();
- sec = date.get(Calendar.SECOND);
- min = date.get(Calendar.MINUTE);
- hr = date.get(Calendar.HOUR);
- msg = hr+":"+min+":"+sec;
- g.drawString(msg,10,y+=10);
- }
- public static void main(String args[])
- {
- new slip27();
- }
- }
- Q3 :
- <html>
- <body>
- <script type="text/javascript">
- function show_confirm()
- {
- var r=confirm("Press a button !");
- if(r==true)
- {
- ver i;
- var game = new Array();
- game[0]="Car ";
- game[1]="GTA";
- game[2]="cricket";
- for(i=0;i<game.length;i++)
- {
- document.write(game[i]+"<br/>");
- }
- }
- else
- {
- alert("Cancel game cannot br displayed !");
- }
- }
- </script>
- </head>
- <body>
- <input type="button" onclick="show_confirm()" value="List of game"/>
- </body>
- </html>
- Q4 :
- <?xml version="1.0" encoding="utf-8"?>
- <CricketTeam>
- <Team country=”India”>
- <player>sachin</player>
- <runs>36000</runs>
- <wicket>88</wicket>
- </Team>
- <Team country=”Australia”>
- <player>watsun</player>
- <runs>10000</runs>
- <wicket>44</wicket>
- </Team>
- <Team country=”Pakisthan”>
- <player>Afridhi</player>
- <runs>6000</runs>
- <wicket>65</wicket>
- </Team>
- </CricketTeam>
- cricket.php
- <?php
- $xml=simplexml_load_file(“cricket.xml”)or die(“cannotnload”);
- $xmlstring=$xml->asXML();
- Echo $xmlstring;
- ?>
- Slip no 28
- Q1 :
- <html>
- <body>
- <form method=post action="armstrong.jsp">
- Enter Number : <input type=text name=t1><br>
- <input type=submit>
- </form>
- </body>
- </html>
- Armstrong.jsp :
- <html>
- <body>
- <%! int n,m,sum=0,rem; %>
- <% n=Integer.parseInt(request.getParameter("t1"));
- m=n;
- while(n>0)
- {
- rem=n%10;
- sum=sum+(rem*rem*rem);
- n=n/10;
- }
- if(sum==m)
- out.print("the no. is armstrong "+sum);
- else
- out.print("the no. is not armstrong "+sum);
- %>
- </body>
- </html>
- Q2 :
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.table.*;
- import java.util.*;
- import java.sql.*;
- class EmpView extends JFrame{
- private JTable tabRecord;
- private JLabel lblEmp;
- private JComboBox cmbEmp;
- private JPanel panNorth;
- private DefaultTableModel dtm;
- private Connection con;
- private PreparedStatement ps;
- private Statement s;
- private ResultSet rs;
- public EmpView(){
- lblEmp = new JLabel("Employee:");
- cmbEmp = new JComboBox();
- panNorth = new JPanel();
- panNorth.add(lblEmp);
- panNorth.add(cmbEmp);
- dtm = new DefaultTableModel();
- dtm.addColumn("EmpNo");
- dtm.addColumn("Name");
- dtm.addColumn("Salary");
- //dtm.addColumn("Designation");
- tabRecord = new JTable(dtm);
- setTitle("View Employee");
- setSize(500,150);
- add(panNorth,"North");
- add(new JScrollPane(tabRecord),"Center");
- setVisible(true);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- try{
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con=DriverManager.getConnection("jdbc:odbc:lab.dsn");
- s = con.createStatement();
- rs = s.executeQuery("select * from emp");
- cmbEmp.addItem("---");
- while(rs.next()){
- cmbEmp.addItem(rs.getString(2));
- }
- }
- catch(Exception e){
- JOptionPane.showMessageDialog(null,e);
- }
- cmbEmp.addItemListener(new ItemListener(){
- public void itemStateChanged(ItemEvent ie){
- try{
- String name = cmbEmp.getSelectedItem().toString();
- ps = con.prepareStatement("select * from emp where name=?");
- ps.setString(1,);
- rs = ps.executeQuery();
- if(rs.next()){
- Vector rec = new Vector();
- rec.add(rs.getString(1));
- rec.add(rs.getString(2));
- rec.add(rs.getString(3));
- // rec.add(rs.getString(4));
- if(dtm.getRowCount()>0)
- dtm.removeRow(0);
- dtm.addRow(rec);
- }
- }
- catch(Exception e){
- JOptionPane.showMessageDialog(null,e);
- }
- }
- });
- }
- public static void main(String args[]){
- new EmpView();
- }
- }
- Q3 :
- Html file :
- <html> <body>
- <form action="slip_28_Q3-1.php" method="get">
- <center> <b>Select font style :</b>
- <input type=text name=s1> <br>
- <b>Enter font size : </b><input type=text name=s><br>
- <b>Enter font color : </b><input type=text name=c><br>
- <b>Enter background color :</b>
- <input type=text name=b><br>
- <input type=submit value="Next">
- </center>
- </form>
- </body>
- </html>
- Php file :
- slip_28_1.php
- <?php
- echo "style is ".$_GET['s1']."<br>color is ".$_GET['c']."<br>Background color is ".$_GET['b']."<br>size is ".$_GET['s'];
- setcookie("set1",$_GET['s1'],time()+3600); setcookie("set2",$_GET['c'],time()+3600); setcookie("set3",$_GET['b'],time()+3600); setcookie("set4",$_GET['s'],time()+3600);
- ?>
- <html>
- <body>
- <form action="slip28_2.php">
- <input type=submit value=OK>
- </form>
- </body>
- </html>
- php file : slip28_2.php
- <?php
- $style=$_COOKIE['set1'];
- $color=$_COOKIE['set2'];
- $size=$_COOKIE['set4'];
- $b_color=$_COOKIE['set3'];
- $msg="NR Classes";
- echo "<body bgcolor=$b_color>";
- echo "<font color=$color size=$size>$msg";
- echo "</font></body>";
- ?>
- Slip no 29
- Q1 :
- <html>
- <body>
- <form method=post action="Vote.jsp">
- Enter Your Age : <input type=text name=t1><br>
- <br>
- <input type=submit>
- </form>
- </body>
- </html>
- Vote.jsp :
- <html>
- <body>
- <%! int n; %>
- <% n=Integer.parseInt(request.getParameter("t1"));
- if(n>=18)
- out.print("You are eligible for voting....!");
- else
- out.print("You are not eligible for voting....!");
- %>
- </body>
- </html>
- Q2 :
- import java.sql.*;
- import java.io.*;
- class slip29
- {
- public static void main(String args[])
- {
- Connection con;
- Statement state;
- ResultSet rs;
- int ch,k;
- boolean flag=true;
- String decision;
- int rno;
- try
- {
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- con = DriverManager.getConnection("jdbc:odbc:lab.dsn");
- System.out.println("Statement object created");
- do
- {
- System.out.println("\n");
- System.out.println("Menu:");
- System.out.println("1.Insert Record into the Table");
- System.out.println("2.Update The Existing Record.");
- System.out.println("3.Display all the Records from the Table");
- System.out.println("4.Delete Record into the Table");
- System.out.println("5.Search The Existing Record.");
- System.out.println("6.Exit");
- System.out.println("Enter your choice: ");
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- ch=Integer.parseInt(br.readLine());
- switch(ch)
- {
- case 1:
- System.out.println("Enter Student Number: ");
- rno=Integer.parseInt(br.readLine());
- System.out.println("Enter Student Name: ");
- String name=br.readLine();
- System.out.println("Enter Percentage: ");
- int per=Integer.parseInt(br.readLine());
- String sql="insert into Student values(?,?,?)";
- PreparedStatement p=con.prepareStatement(sql);
- p.setInt(1,rno);
- p.setString(2,name);
- p.setInt(3,per);
- p.executeUpdate();
- System.out.println("Record Added");
- break;
- case 2:
- state=con.createStatement();
- System.out.println("Enter the rno");
- rno=Integer.parseInt(br.readLine());
- System.out.println("Enter the per");
- per=Integer.parseInt(br.readLine());
- String ss="update Student set Student.per="+per+" where(((Student.[rno])="+rno+"))";
- k=state.executeUpdate(ss);
- System.out.println(ss);
- if(k>0)
- {
- System.out.println("Record Is Updated");
- }
- break;
- case 3:
- state=con.createStatement();
- sql="select * from Student";
- rs=state.executeQuery(sql);
- while(rs.next())
- {
- System.out.println("\n");
- System.out.print("\t" +rs.getInt(1));
- System.out.print("\t" +rs.getString(2));
- System.out.print("\t" +rs.getInt(3));
- }
- break;
- case 4:
- state =con.createStatement();
- while(flag)
- {
- System.out.println("Enter Student Number for the record you wish to Delete: ");
- rno=Integer.parseInt(br.readLine());
- sql="delete from Student where rno="+rno;
- System.out.println(sql);
- int rows=state.executeUpdate(sql);
- System.out.println(rows+"rows sucessfully Deleted");
- System.out.println("Do u want to Delete more data:y/n:");
- decision=br.readLine().toLowerCase();
- if(decision.charAt(0)=='n')
- flag=false;
- }
- break;
- case 5:
- state=con.createStatement();
- System.out.println("enter roll no u want to search");
- rno=Integer.parseInt(br.readLine());
- sql="select * from Student where rno="+rno;
- rs=state.executeQuery(sql);
- System.out.println("success");
- while(rs.next())
- {
- System.out.println("RollNo="+rs.getInt(1)+""+"name="+rs.getString(2)+" "+"per="+rs.getInt(3));
- }
- break;
- case 6:
- System.exit(0);
- default:
- System.out.println("Invalid Choice");
- break;
- }
- }while(ch!=6);
- }catch(Exception e)
- {
- System.out.println(e);
- }
- }
- }
- Q3 :
- <?xml version=”1.0” encoding=”utf-8”?>
- <Course>
- <Computer Science>
- <Student name>Sachin pawar</Student name>
- <Class name>SYBCS</Class name>
- <percentage>56</percentage> </Computer Science>
- </Course>
- <Course>
- <Computer Science>
- <Student name>Sachin pawar</Student name>
- <Class name>SYBCS</Class name>
- <percentage>56</percentage>
- </Computer Science>
- </Course>
- <Course>
- <Computer Science>
- <Student name>Sachin pawar</Student name>
- <Class name>SYBCS</Class name>
- <percentage>56</percentage>
- </Computer Science>
- </Course>
- <Course>
- <Computer Science>
- <Student name>Sachin pawar</Student name>
- <Class name>SYBCS</Class name>
- <percentage>56</percentage>
- </Computer Science>
- </Course>
- Q4 :
- Userpass.html
- <html>
- <body>
- <form method=get action="userpass.php">
- Enter UserName : <input type=text name="t1"><br><br>
- Enter Password : <input type=text name="t2"><br><br>
- <input type=submit value="Log In">
- </form>
- </body>
- </html>
- Userpass.php :
- <?php
- session_start();
- session_register("chance");
- if($_SERVER['REQUEST_METHOD']=='GET')
- {
- ?>
- <form method=post action="<?php echo $_SERVER['PHP_SELF']?>">
- <P>Name : <input type=text name=uname value="<?php if(isset($_POST['uname'])) echo $_POST['uname'];?>">
- </p>
- <P>Passoword : <input type=text name=pass value="<?php if(isset($_POST['pass'])) echo $_POST['pass'];?>"></p>
- <input type=submit name=submit value=submit> </form>
- <?php
- }
- else if($_SERVER['REQUEST_METHOD']=='POST')
- {
- $name=$_POST['uname'];
- $pass=$_POST['pass'];
- if(($name=="ABC") && ($pass=="abc"))
- echo"Hello <a href='next.php'>next form</a>";
- else echo"wrong username password ".session_register("chance")."!!!"; $chance++;
- if($chance==3)
- echo"sorry!!! your chance are finished!!!!!";
- }
- else
- {
- die("not able to process script");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement