Advertisement
Guest User

SLIPS

a guest
Mar 14th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 139.61 KB | None | 0 0
  1. Slip no 1
  2. Q1 : Server1 :
  3. import java.io.*;
  4. import java.net.*;
  5. class server1
  6. {
  7. public static void main(String a[]) throws Exception
  8. {
  9. ServerSocket ss = new ServerSocket(1000);
  10. System.out.println("Server is waiting for client : ");
  11. Socket s =ss.accept();
  12. System.out.println("Client is connected");
  13. }
  14. }
  15. Client1 :
  16. import java.io.*;
  17. import java.net.*;
  18. class client1
  19. {
  20. public static void main(String a[]) throws Exception
  21. {
  22. Socket ss = new Socket("localhost",1000);
  23. System.out.println("IP Address = "+ss.getInetAddress());
  24. System.out.println("Client port = "+ss.getPort());
  25. }
  26. }
  27. Q2: Slip1.jsp :
  28. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  29. <!DOCTYPE html>
  30. <HTML>
  31. <HEAD>
  32. <TITLE>Login using jsp</TITLE>
  33. </HEAD>
  34. <BODY>
  35. <H1>LOGIN FORM</H1>
  36. <%
  37. String myname = (String)session.getAttribute("username");
  38. if(myname!=null)
  39. {
  40. out.println("Welcome "+myname+" , <a href=\"Slip1_logout.jsp\" >Logout</a>");
  41. }
  42. else
  43. {
  44. %>
  45. <form action="Slip1_checkLogin.jsp">
  46. <table>
  47. <tr>
  48. <td> Username : </td><td><input name="username" size=15 type="text"
  49. /></td>
  50. </tr>
  51. <tr>
  52. <td> Password : </td><td><input name="password" size=15
  53. type="password" /></td>
  54. </tr>
  55. </table>
  56. <input type="submit" value="login" />
  57. </form>
  58. <%
  59. }
  60. %>
  61. </BODY>
  62. </HTML>
  63. Slip1_checklogin.jsp :
  64.  
  65. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  66. <!DOCTYPE html>
  67. <%
  68. String username = request.getParameter("username");
  69. String password = request.getParameter("password");
  70. out.println("Checking login<br>");
  71. if (username == null || password == null) {
  72. out.print("Invalid paramters ");
  73. }
  74. // Here you put the check on the username and password
  75. if (username.toLowerCase().trim().equals("admin")&&
  76. password.toLowerCase().trim().equals("admin")) {
  77. out.println("Welcome " + username + " <a href=\"Slip1.jsp\">Back to main</a>");
  78. session.setAttribute("username", username);
  79. }
  80. else
  81. {
  82. out.println("Invalid username and password");
  83. }
  84. %>
  85. Slip1_logout.jsp :
  86. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  87. <!DOCTYPE html>
  88. <%
  89. String username=(String)session.getAttribute("username");
  90. if(username!=null)
  91. {
  92. out.println(username+" loged out, <a href=\"Slip1.jsp\">Back</a>");
  93. session.removeAttribute("username");
  94. }
  95. else
  96. {
  97. out.println("You are already not login <a href=\"Slip1.jsp\">Back</a>");
  98. }
  99. %>
  100.  
  101. Q3 :
  102. <HTML>
  103. <BODY>
  104. <FORM method=POST action="<?php echo $_SERVER['PHP_SELF'] ?>">
  105. Enter First Value : <INPUT type=text name=a> <BR>
  106. Enter Second Value: <INPUT type=text name=b> <BR>
  107. <b>Select Arithmetic Operation</b> <BR>
  108. <INPUT type=radio name="choice" value="1"> Addition <BR>
  109. <INPUT type=radio name="choice" value="2"> Subtraction <BR>
  110. <INPUT type=radio name="choice" value="3"> Multiplication <BR>
  111. <INPUT type=radio name="choice" value="4">Division <BR>
  112. <INPUT type=submit name=submit value="Calculate"><BR>
  113. </FORM>
  114. <?php
  115. $c="";
  116. if(isset($_POST['submit']))
  117. { $a=$_POST['a'];
  118. $b=$_POST['b'];
  119. $ch=$_POST['choice'];
  120. if($ch=='1')
  121. {
  122. $c=$a+$b;
  123. echo"Addition = $c";
  124. }
  125. if($ch=='2')
  126. {
  127. $c=$a-$b;
  128. echo"Subtraction = $c";
  129. }
  130. if($ch=='3')
  131. {
  132. $c=$a*$b;
  133. echo"Multiplication = $c";
  134. }
  135. if($ch=='4')
  136. {
  137. $c=$a/$b;
  138. echo"Division = $c";
  139. }
  140. }
  141. ?>
  142. </BODY>
  143. </HTML>
  144. Q4 :
  145. <html>
  146. <body>
  147. <form method=get action="emp.php">
  148. Enter Employee Code : <input type=text name=ecode> <br>
  149. Enter Employee Name : <input type=text name=ename><br>
  150. Enter Designation : <input type=text name=des><br>
  151. <input type=submit value=Save>
  152. </form>
  153. </body>
  154. </html>
  155. Display.php :
  156. <?php
  157. $ecode=$_GET['ecode'];
  158. $ename=$_GET['ename'];
  159. $des=$_GET['des'];
  160. if(isset($_COOKIE['ecode'])&&isset($_COOKIE['ename'])&&isset($_COOKIE['d es']))
  161. {
  162. echo"<br><b> Employee Details </b><br>";
  163. echo"Employee Code : ".$_COOKIE['ename']." <br>";
  164. echo"Employee Name:".$_COOKIE['ename']."<br>";
  165. echo"Designation. : ".$_COOKIE['des']."<br>";
  166. echo"<br><b>EMPLOYESS Details</b><br>";
  167. echo"Account No. : $ano<br>";
  168. echo"Joining Date : $jdate<br>";
  169. }
  170. ?>
  171. Emp.php :
  172. <?php
  173. $ecode=$_GET['ecode'];
  174. $ename=$_GET['ename'];
  175. $designation=$_GET['des'];
  176. setcookie("ecode",$ecode);
  177. setcookie("ename",$ename);
  178. setcookie("des",$des);
  179. echo"Hello $ename enter your details <br><br>";
  180. echo"<form method=get action=display.php>
  181. echo"Account No. : $ano<br>";
  182. echo"Joining Date : $jdate<br>";
  183. echo"Hello $ename enter your salary <br><br>";
  184. echo"<form method=get action=display.php>
  185. echo"Basic pay. : $bpay<br>";
  186. echo"Earnings : $earnings<br>";
  187. echo"Deduction : $deduction<br>";
  188. <input type=submit value=Display>
  189. </form>";
  190. ?>
  191. Slip no 2
  192. Q1 :
  193. import java.util.*;
  194. import java.io.*;
  195. class slip2 extends Thread
  196. {
  197. String s1;
  198. slip2(String s)
  199. {
  200. s1=s;
  201. start();
  202. }
  203. public void run()
  204. {
  205. System.out.println("Vowels are ");
  206. for(int i=0;i<s1.length();i++)
  207. {
  208. char ch=s1.charAt(i);
  209. if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
  210. System.out.print(" "+ch);
  211. }
  212. }
  213. public static void main(String a[]) throws Exception
  214. {
  215. DataInputStream di = new DataInputStream(System.in);
  216. System.out.println("Enter a string");
  217. String str=di.readLine();
  218. slip2 s=new slip2(str);
  219. }
  220. }
  221. Q2 :
  222. import java.io.*;
  223. import javax.servlet.*;
  224. import javax.servlet.http.*;
  225. public class VisitServlet extends HttpServlet
  226. {
  227. static int i=1;
  228. public void doGet(HttpServletRequest request, HttpServletResponse response)
  229. throws IOException, ServletException
  230. {
  231. response.setContentType("text/html");
  232. PrintWriter out = response.getWriter();
  233. String k=String.valueOf(i);
  234. Cookie c = new Cookie("visit",k);
  235. response.addCookie(c);
  236. int j=Integer.parseInt(c.getValue());
  237. if(j==1)
  238. {
  239. out.println("Welcome");
  240. }
  241. else
  242. {
  243. out.println("You visited "+i+" times");
  244. }
  245. i++;
  246. }
  247. }
  248. <?xml version="1.0" encoding="ISO-8859-1"?>
  249. <web-app>
  250. <servlet>
  251. <servlet-name>VisitServlet</servlet-name>
  252. <servlet-class>VisitServlet</servlet-class>
  253. </servlet>
  254. <servlet-mapping>
  255. <servlet-name>VisitServlet</servlet-name>
  256. <url-pattern>/servlet/VisitServlet</url-pattern>
  257. </servlet-mapping>
  258. </web-app>
  259. Q3 :
  260. <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>
  261.  
  262. 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>";
  263.  
  264. $fac=substr($a,0,2); if($fac=='BA') echo"Faculty = BA"; if($fac=='BC') echo"Faculty = BCA"; if($fac=='BS') echo"Faculty = B.Sc."; }
  265.  
  266.  
  267. else { echo"Invalid Roll No."; } ?>
  268. Q4 :
  269.  
  270. <?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>"; }
  271.  
  272. } $c=new Cylinder(5,5); $c->area(); $c->volume(); ?>
  273. Slip no 3
  274. Q1 :
  275. import java.sql.*;
  276. public class slip3
  277.  
  278. {
  279. public static void main(String args[])
  280. {
  281. Connection con;
  282. try{
  283. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  284. con=DriverManager.getConnection("jdbc:odbc:dsn");
  285.  
  286.  
  287.  
  288. Statement stmt=con.createStatement();
  289. ResultSet rs=stmt.executeQuery("select * From employee Where dept='computer science'");
  290. System.out.println("eno\t"+"ename\t"+"department\t"+"sal");
  291. while(rs.next())
  292. {
  293. System.out.println("\n"+rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getString(3)+""+rs.getInt(4));
  294. }
  295. con.close();
  296.  
  297.  
  298. }
  299.  
  300. catch(Exception e)
  301. {
  302.  
  303. }
  304. }
  305. }
  306. Q2 :
  307. import java.awt.*;
  308. import java.applet.*;
  309. /*<applet code="slip3.java" height=450 width=350>
  310. </applet>*/
  311. public class slip3 extends Applet implements Runnable
  312. {
  313. Thread t;
  314. int r,g1,y,i;
  315. public void init()
  316. {
  317. t=new Thread(this);
  318. t.start();
  319. r=0;g1=0;i=0;y=0;
  320.  
  321.  
  322. }
  323.  
  324. public void run()
  325. {
  326. try{
  327.  
  328. for(i=24;i>=1;i--)
  329. {
  330.  
  331. if (i>16&&i<=24)
  332. {
  333. t.sleep(200);
  334. r=1;
  335. repaint();
  336. }
  337.  
  338. if (i>8&&i<=16)
  339. {
  340. t.sleep(200);
  341. y=1;
  342. repaint();
  343. }
  344.  
  345. if (i>1&&i<=8)
  346. {
  347. t.sleep(200);
  348. g1=1;
  349. repaint();
  350. }
  351.  
  352. }
  353. if (i==0)
  354. {
  355. run();
  356. }
  357. }catch(Exception e){
  358. }
  359.  
  360.  
  361. }
  362.  
  363. public void paint(Graphics g)
  364. {
  365. g.drawRect(100,100,100,300);
  366. if (r==1)
  367. { g.setColor(Color.red);
  368. g.fillOval(100,100,100,100);
  369. g.setColor(Color.black);
  370. g.drawOval(100,200,100,100);
  371. g.drawOval(100,300,100,100);
  372. r=0;
  373. }
  374.  
  375. if (y==1)
  376. {
  377. g.setColor(Color.black);
  378. g.drawOval(100,100,100,100);
  379. g.drawOval(100,300,100,100);
  380. g.setColor(Color.yellow);
  381. g.fillOval(100,200,100,100);
  382.  
  383. y=0;
  384. }
  385.  
  386. if (g1==1)
  387. {
  388. g.setColor(Color.black);
  389. g.drawOval(100,100,100,100);
  390. g.drawOval(100,200,100,100);
  391. g.setColor(Color.green);
  392. g.fillOval(100,300,100,100);
  393. g1=0;
  394. }
  395.  
  396.  
  397. }
  398. }
  399. Q3 :
  400. <?php
  401. class Myclass
  402. {
  403. public $a;
  404. public $b=10;
  405. public $c='ABC';
  406. function Myclass()
  407. {
  408. //Myclass function
  409. }
  410. function myfun1()
  411. {
  412. //functin
  413. }
  414. function myfun2()
  415. {
  416. //functin
  417. }
  418. }
  419. $class=get_declared_classes();
  420. foreach($class as $cname)
  421. {
  422. echo"$cname <br>";
  423. }
  424. echo"<br>Class Methods are : <br>";
  425. $m=get_class_methods('Myclass');
  426. foreach($m as $mname)
  427. {
  428. echo"$mname <br>";
  429. }
  430. $cp=get_class_vars('Myclass');
  431. echo"class variables are :<br>";
  432. foreach($cp as $cpname => $v)
  433. {
  434. echo"$cpname : $v <br>";
  435. } ?>
  436.  
  437. Q4 :
  438.  
  439. <?php
  440. interface Area
  441. {
  442. function area();
  443. }
  444. class Rectangle implements Area
  445. {
  446. public $w;
  447. public $l;
  448. function __construct($w,$l)
  449. {
  450. $this->w=$w;
  451. $this->l=$l;
  452. }
  453. function area()
  454. {
  455. return($this->w*$this->l);
  456. }
  457. }
  458. class Square extends Rectangle implements Area
  459. {
  460. public $l;
  461. function __construct($l)
  462. {
  463. parent::__construct(12,3);
  464. echo "<br>Area of Rectangle : ".parent::area()."<br>";
  465. $this->l=$l;
  466. }
  467. function area()
  468. {
  469. return($this->l*$this->l);
  470. }
  471. }
  472. class Circle implements Area
  473. {
  474. public $PI=3.14;
  475. public $r;
  476. function __construct($r)
  477. {
  478. $this->r=$r;
  479. }
  480. function area()
  481. {
  482. return($this->PI*$this->r*$this->r);
  483. }
  484. }
  485. $sq=new Square(4);
  486. echo "Area of Square : ".$sq->area();
  487. $cr=new Circle(5);
  488. echo "<br>Area of Circle : ".$cr->area();
  489. ?>
  490.  
  491. Slip no 4
  492. Q1 :
  493. import java.io.*;
  494.  
  495. public class slip4 implements Runnable{
  496.  
  497. int i,no;
  498.  
  499. slip4(int n)
  500. {
  501. no = n;
  502. }
  503. public void run()
  504. {
  505. try
  506. {
  507. for(i = 1; i<=no; i++)
  508. {
  509. System.out.println("\nHello Java");
  510.  
  511.  
  512. Thread.sleep(150);
  513. }
  514. }
  515. catch(Exception e)
  516. {
  517.  
  518. }
  519. }
  520.  
  521.  
  522. public static void main(String args[])
  523. {
  524. try
  525. {
  526. int n;
  527.  
  528. System.out.println("\nEnter Number : ");
  529. BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  530. String s = br.readLine();
  531. n = Integer.parseInt(s);
  532. Thread t = new Thread(new slip4(n));
  533. t.start();
  534. }
  535. catch(Exception e)
  536. {
  537.  
  538. }
  539. }
  540. }
  541. Q2 :
  542. <form method='post' action='page1.jsp'>
  543. <h3>Page 1</h3>
  544. <h4>Select Your Product:</h4>
  545. <input type='checkbox' name='prod' value=10>Pencil<br>
  546. <input type='checkbox' name='prod' value=30>Pen<br>
  547. <input type='checkbox' name='prod' value=5>Eraser<br>
  548. <input type='checkbox' name='prod' value=8>Scale<br>
  549. <input type='checkbox' name='prod' value=45>Note Book<br>
  550. <input type='submit'><input type='reset'>
  551. </form>
  552. Page1.jsp :
  553. <%
  554. String s[] = request.getParameterValues("prod");
  555. int tot=0;
  556. for(int i=0;i<s.length;i++){
  557. tot+=Integer.parseInt(s[i]);
  558. }
  559. session.setAttribute("tot1", tot);
  560. response.sendRedirect("Page2.html");
  561. %>
  562. <form method='post' action='page2.jsp'>
  563. <h3>Page 2</h3>
  564. <h4>Select Your Product:</h4>
  565. <input type='checkbox' name='prod' value=1300>Jeans<br>
  566. <input type='checkbox' name='prod' value=500>Shirt<br>
  567. <input type='checkbox' name='prod' value=2500>Saree<br>
  568. <input type='checkbox' name='prod' value=750>Trouser<br>
  569. <input type='checkbox' name='prod' value=400>T-Shirt<br>
  570. <input type='submit'><input type='reset'>
  571. </form>
  572. Page2.jsp :
  573. <%
  574. String s[] = request.getParameterValues("prod");
  575. int tot=0;
  576. for(int i=0;i<s.length;i++){
  577. tot+=Integer.parseInt(s[i]);
  578. }
  579. int tot1 = Integer.parseInt(session.getAttribute("tot1").toString());
  580. %>
  581. <table border=1>
  582. <tr><td><b>Page 1:</b></td><td>Rs.<%=tot1%>/-</td></tr>
  583. <tr><td><b>Page 2:</b></td><td>Rs.<%=tot%>/-</td></tr>
  584. <tr><td><b>Grand Total:</b></td><td>Rs.<%=tot1+tot%>/-</td></tr>
  585. </table>
  586. Q3 :
  587. Calulate.html :
  588. <HTML>
  589. <BODY>
  590. <FORM method=get action="Calulate.php">
  591. Enter first value: <INPUT type=text name="a"><br>
  592. Enter second value:<INPUT type=text name="b"><br>
  593. <INPUT type=submit>
  594. </FORM>
  595. </BODY>
  596. </HTML>
  597. Calulate.php :
  598. <?php
  599. class Calculate
  600. {
  601. public $a;
  602. public $b;
  603. function __construct($a,$b)
  604. {
  605. $this->a=$a;
  606. $this->b=$b;
  607. }
  608. public function add()
  609. {
  610. $c=$this->a+$this->b;
  611. echo"Addition = $c<br>";
  612. }
  613. public function subtract()
  614. {
  615. $c=$this->a-$this->b;
  616. echo"Subtract = $c<br>";
  617. }
  618. public function multiply()
  619. {
  620.  
  621.  
  622. $c=$this->a*$this->b;
  623. echo"Multiplication = $c<br>";
  624. }
  625. public function div()
  626. {
  627. $c=$this->a/$this->b;
  628. echo"Division = $c";
  629. }
  630. }
  631. $x=$_GET['a'];
  632. $y=$_GET['b'];
  633. $calc=new Calculate($x,$y);
  634. $calc->add();
  635. $calc->subtract();
  636. $calc->multiply();
  637. $calc->div();
  638. ?>
  639.  
  640.  
  641.  
  642.  
  643. Q4 :
  644.  
  645. LoginSession.html :
  646. <html>
  647. <body>
  648. <form method=get action=details.php>
  649. user name : <input type=text name=uname><br><br>
  650. password : <input type=text name=pass><br><br>
  651. <input type=submit value=Login>
  652. </form>
  653. </body>
  654. </html>
  655.  
  656. Details.php :
  657.  
  658. <?php
  659. session_start();
  660. if(set_time_limit(20))
  661. echo"time expired";
  662. if(($_REQUEST['uname']=='ABC') && ($_REQUEST['pass']=='abc'))
  663. {
  664. echo"<form method=post action='display.php'>";
  665. echo"Name : <input type=text name=name><br>";
  666. echo"city : <input type=text name=city><br>";
  667. echo"PhoneNo.:<input type=text name=pno><br>";
  668. echo"<input type=submit value='Display'></form>";
  669. }
  670. else
  671. echo"Wrong Information...<a href=LoginSession.html>LoginSession.html</a>";
  672. ?>
  673.  
  674. Slip no 5
  675. Q1 :
  676. import java.sql.*;
  677. class slip5
  678. {
  679. public static void main(String args[])
  680. { Connection con;
  681. try
  682. {
  683. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  684. con=DriverManager.getConnection("jdbc:odbc:dsn");
  685.  
  686. System.out.println("Connection Established...");
  687.  
  688. Statement stmt=con.createStatement();
  689.  
  690. //create a table teacher
  691. String query="create table Teacher1"+"(TNo int ,"+" TName varchar(20),"+" sal int,"+" desg varchar(20))";
  692. stmt.executeUpdate(query);
  693. System.out.println("given table created in database");
  694.  
  695. //insert record into teacher table
  696. stmt.executeUpdate("insert into Teacher1 "+"values(1,'NRC',50000,'MCS')");
  697. stmt.executeUpdate("insert into Teacher1 "+"values(2,'ABC',10000,'MCA')");
  698. stmt.executeUpdate("insert into Teacher1 "+"values(3,'XYZ',40000,'MCA')");
  699. stmt.executeUpdate("insert into Teacher1 "+"values(4,'PQR',20000,'MCS')");
  700. System.out.println("Succesfully inserted in table....");
  701.  
  702. //display details
  703. ResultSet rs=stmt.executeQuery("select * From Teacher1");
  704. System.out.println("TNo\t"+"TName\t"+"sal\t"+"desg");
  705. while(rs.next())
  706. {
  707. System.out.println("\n"+rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getInt(3)+"\t"+rs.getString(4));
  708. }
  709.  
  710. }
  711. catch(Exception e)
  712. {
  713.  
  714. }
  715. }
  716. }
  717. Q2 :
  718. import java.awt.*;
  719. import java.applet.*;
  720. /*
  721. <APPLET
  722. code = "Flag.java"
  723. width = "500"
  724. height = "300"
  725. >
  726. </APPLET>
  727. */
  728. public class Flag extends Applet implements Runnable
  729. {
  730. Thread t;
  731. int x1,x2,x3,y3,x4,y4,x5,ln;
  732.  
  733. public void init()
  734. {
  735. t=new Thread(this);
  736. t.start();
  737. ln=1;
  738. }
  739. public void run()
  740. {
  741. try
  742. { if(ln==1)
  743. {
  744. for(x1=200;x1>100;)
  745. {
  746. t.sleep(200);
  747. repaint();
  748. }
  749. }
  750. ln=2;
  751. if(ln==2)
  752. {
  753. for(x2=100;x2<150;)
  754. {
  755. t.sleep(200);
  756. repaint();
  757. }
  758. }
  759. ln=3;
  760. if(ln==3)
  761. {
  762. for(x3=150,y3=100;x3>125&&y3<125;)
  763. {
  764. t.sleep(200);
  765. repaint();
  766. }
  767. }
  768. ln=4;
  769. if(ln==4)
  770. {
  771. for(x4=125,y4=125;x4<150&&y4<150;)
  772. {
  773. t.sleep(200);
  774. repaint();
  775. }
  776. }
  777. ln=5;
  778. if(ln==5)
  779. {
  780. for(x5=150;x5>100;)
  781. {
  782. t.sleep(200);
  783. repaint();
  784. }
  785. }
  786. ln=1;
  787. }catch(Exception e)
  788. {
  789. System.out.println(e);
  790. }
  791. run();
  792. }
  793. public void paint(Graphics g)
  794. {
  795. if(ln==1&&x1>100)
  796. {
  797. g.drawLine(100,200,100,x1-=5);
  798. }
  799.  
  800. if(ln==2&&x2<150)
  801. {
  802. g.drawLine(100,200,100,100);
  803. g.drawLine(100,100,x2+=5,100);
  804. }
  805. if(ln==3&&x3>125&&y3<125)
  806. {
  807. g.drawLine(100,200,100,100);
  808. g.drawLine(100,100,150,100);
  809. g.drawLine(150,100,x3-=5,y3+=5);
  810. }
  811. if(ln==4&&x4<150&&y4<150)
  812. {
  813. g.drawLine(100,200,100,100);
  814. g.drawLine(100,100,150,100);
  815. g.drawLine(150,100,125,125);
  816. g.drawLine(125,125,x4+=5,y4+=5);
  817. }
  818. if(ln==5&&x5>100)
  819. {
  820. g.drawLine(100,200,100,100);
  821. g.drawLine(100,100,150,100);
  822. g.drawLine(150,100,125,125);
  823. g.drawLine(125,125,150,150);
  824. g.drawLine(150,150,x5-=5,150);
  825. }
  826.  
  827. }
  828. }
  829. Q3 :
  830. Search.php :
  831. <?php
  832. function searchcustomerName(Array $array,$value)
  833. {
  834. $firstresult ="";
  835. foreach ($array as $subarray)
  836. {
  837. if(isset($subarray[1])&& stristr($subarray[1],$value)&&$ value!="")
  838. {
  839. $firstresult .= $subarray[0]." ".$subarray[1]."".$subarray[2]."<br/>";
  840. }
  841. }
  842. return $firstresult;
  843. }
  844. $file= fopen("Customer.dat", "r");
  845.  
  846. $filestring =" ";
  847. while(!feof($file))
  848. {
  849. $tempstring = fgets($file);
  850. $filestring.=$tempstring."<br />";
  851. $line_of_text.=$tempstring;
  852. }
  853. $customer = explode("\n",$line_of_text);
  854. fclose($file);
  855. foreach ($customer as $key =>$value)
  856. {
  857. $customer[$key] =explode(",",$value);
  858. }
  859. $term=strip_tags(substr(_POST['search_term'],0,100));
  860. $string = ' ' ;
  861. if($term !=" "&& $term != " ")
  862. {
  863. $string.=searchcustomerName($customer,$term);
  864. }
  865. if ($string ! =" ")
  866. echo $string;
  867. else
  868. echo'<div class="alter_yellow">No results found</div>';
  869. ?>
  870.  
  871. index.php :
  872.  
  873. <?php
  874. if(isset($_POST['field'])) $selectedoption =$_POST['field'];
  875. else $selectedoption = "customername";
  876. ?>
  877. <head>
  878. <script type="text/javascript"src="jquery.js"> </script>
  879. <script type='text/javascript'> $(document).ready(function()
  880. { $("#search_result").slideUP();
  881. $("#search_button").click(function(e)
  882.  
  883. {
  884. e.preventDefault();
  885. ajax_search();
  886. });
  887. });
  888. function ajax_search()
  889. {
  890. $"#search_results.show();
  891. var search_val=$("#search_term").val();
  892. var.post("./search.php",{search_term : search_val, field : search_type},function(data)
  893. {
  894. if(data.length>0)
  895. {
  896. $("#search_results").html(data);
  897. }
  898. })
  899. }
  900. </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"/>
  901. </head>
  902. <body> <div id="wrapper"> <form name="search"id=searchform" method="post"> <div> Search for:<input type="text"name"search_term" id="search_term"/>in
  903. <Select NAME="field"id="searchtype">
  904. <Option <?php if ($selectedoption=='customername')echo'selected'?>VALUE="customername" >customer Name</option> </Select>
  905. <input type="hidden"name="searching" value="yes" />
  906. <input type="submit"id=search_button"name="search" value="search" /> </div> </form> <br /> <hr /> <div id="search_result"></div> <br />
  907.  
  908. </div> </body> </html>
  909. Q4 :
  910. <?php
  911.  
  912. class Employee
  913. {
  914. private $eid,$ename,$edept,$sal;
  915. function __construct($a,$b,$c,$d)
  916. {
  917. $this->eid=$a;
  918. $this->ename=$b;
  919. $this->edept=$c;
  920. $this->sal=$d;
  921. }
  922. public function getdata()
  923. {
  924. return $this->sal;
  925. }
  926. public function display()
  927. {
  928. echo $this->eid."</br>";
  929. echo $this->ename."</br>";
  930. echo $this->edept."</br>";
  931. //echo $this->ename."</br>";
  932. }
  933. }
  934. class Manager extends Employee
  935. {
  936. private $bonus;
  937. public static $total1=0;
  938. function __construct($a,$b,$c,$d,$e)
  939. {
  940. parent::__construct($a,$b,$c,$d);
  941. $this->bonus=$e;
  942. }
  943. public function max($ob)
  944. {
  945. $sal=$this->getdata();
  946. $total=$sal+$this->bonus;
  947. if($total>self::$total1)
  948. {
  949. self::$total1=$total;
  950. return $this;
  951. }
  952. else { return $ob;
  953. }
  954. }
  955. public function display()
  956. {
  957. parent::display();
  958. echo self::$total1;
  959. }
  960.  
  961. }
  962. $ob=new Manager(0,"ABC","",0,0);
  963. $ob1=new Manager(1,"ramdas","computer",28000,2000);
  964. $ob=$ob1->max($ob);
  965. $ob2=new Manager(2,"ramdas1","computer",30000,2500);
  966. $ob=$ob2->max($ob);
  967. $ob3=new Manager(3,"ramdas2","computer",32000,3000);
  968. $ob=$ob3->max($ob);
  969. $ob4=new Manager(4,"ramdas","computer",28000,4000);
  970. $ob=$ob4->max($ob);
  971. $ob5=new Manager(5,"ramdas","computer",28000,5000);
  972. $ob=$ob5->max($ob);
  973. $ob->display();
  974.  
  975. ?>
  976. Slip no 6
  977. Q1 :
  978. import java.sql.*;
  979. import java.io.*;
  980. class slip6
  981. {
  982. public static void main(String a[])
  983. {
  984. PreparedStatement ps;
  985. Connection con;
  986. try{
  987. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  988. con=DriverManager.getConnection("jdbc:odbc:dsn");
  989. con.setAutoCommit(false);
  990. System.out.println("Connection Esatablished......");
  991. Statement stmt=con.createStatement();
  992.  
  993.  
  994. BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  995. String query="insert into Customer values(?,?,?,?)";
  996. ps=con.prepareStatement(query);
  997.  
  998. System.out.println("Customer Details....");
  999. System.out.println("Enter CID");
  1000. int cid=Integer.parseInt(br.readLine());
  1001. ps.setInt(1,cid);
  1002. System.out.println("Enter name");
  1003. String name=br.readLine();
  1004. ps.setString(2,name);
  1005. System.out.println("Enter Address");
  1006. String add=br.readLine();
  1007. ps.setString(3,add);
  1008. System.out.println("Enter Ph_No");
  1009. int phno=Integer.parseInt(br.readLine());
  1010. ps.setInt(4,phno);
  1011.  
  1012. ps.executeUpdate();
  1013. con.setAutoCommit(true);
  1014. con.close();
  1015.  
  1016.  
  1017. }
  1018. catch(Exception e)
  1019. {
  1020.  
  1021. }
  1022. }
  1023. }
  1024. Q2 :
  1025. Server :
  1026. import java.io.*;
  1027. import java.net.*;
  1028.  
  1029. class Server{
  1030. public static void main(String args[])
  1031. throws Exception{
  1032. ServerSocket ss = new ServerSocket(7080);
  1033. while(true)
  1034. {
  1035. Socket s = ss.accept();
  1036. DataOutputStream toClient = new DataOutputStream(
  1037. s.getOutputStream());
  1038. DataInputStream fromClient = new DataInputStream(
  1039. s.getInputStream());
  1040. String fileName = fromClient.readLine();
  1041. File f = new File(fileName);
  1042. if(f.exists()){
  1043. String str=null;
  1044. DataInputStream dis = new DataInputStream(
  1045. new FileInputStream(f));
  1046. while((str=dis.readLine())!=null)
  1047. {
  1048. toClient.writeBytes(str+"\n");
  1049. }
  1050. }
  1051. else{
  1052. toClient.writeBytes("File "+fileName+" not found.\n");
  1053. }
  1054. toClient.writeBytes("END\n");
  1055. }
  1056. }
  1057. }
  1058. Client :
  1059. import java.io.*;
  1060. import java.net.*;
  1061.  
  1062. class Client{
  1063. public static void main(String args[])
  1064. throws Exception{
  1065. Socket s = new Socket("localhost",7080);
  1066. BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  1067.  
  1068. System.out.print("Enter file name:");
  1069. String fileName = br.readLine();
  1070. DataInputStream fromServer = new DataInputStream(s.getInputStream());
  1071. DataOutputStream toServer = new DataOutputStream(s.getOutputStream());
  1072. toServer.writeBytes(fileName+"\n");
  1073. String str="";
  1074. while(true)
  1075. {
  1076. str = fromServer.readLine();
  1077. if(str.equals("END")) break;
  1078. System.out.println(str);
  1079. }
  1080. }
  1081. }
  1082. Q3 :
  1083. <html>
  1084. <head>
  1085. <title>Sticky Form</title>
  1086. </head>
  1087. <body>
  1088. <form action="<?php echo $_SERVER['PHP_SELF']?>" method=post>
  1089. <input type=text name=txtuname value="<?php if(isset($_POST['txtuname']))echo $_POST['txtuname'];?>" >
  1090. </br>
  1091. <input type=password name=txtupass value="<?php if(isset($_POST['txtupass']))echo $_POST['txtupass'];?>" >
  1092. </br>
  1093. <input type=submit value="Login" name=submit>
  1094. <?php
  1095. if(isset($_POST['submit']))
  1096. $nm=$_POST['txtuname'];
  1097. $ps=$_POST['txtupass'];
  1098. $con=mysql_connect("localhost","root","rsb");
  1099. mysql_elect_db("slip6db",$con);
  1100. $result=mysql_query("select * from login where uname='$nm' and upass='$ps'");
  1101. $flag=0;
  1102. while($row=mysql_fetch_array($result))
  1103. {
  1104. $flag++;
  1105. }
  1106. if($flag==1)
  1107. echo "Login validated";
  1108. else echo "username or password invalid";
  1109. ?>
  1110. </body>
  1111. Q4 :
  1112. <?php
  1113. class vehicle
  1114. {
  1115. public $company,$price;
  1116. public function __construct($a,$b)
  1117. {
  1118. $this->company=$a;
  1119. $this->price=$b;
  1120. }
  1121. }
  1122. class Lightmotorvehicle extends vehicle
  1123. {
  1124. public $milege;
  1125. public function __construct($a,$b,$c)
  1126. {
  1127. $this->company=$a;
  1128. $this->price=$b;
  1129. $this->milege=$c;
  1130. }
  1131. public function display()
  1132. {
  1133. echo "<table border=1 width=300><tr><td>".$this>company."</td><td>".$this->price."</td><td>".$this->milege."</td></tr>";
  1134. }
  1135. }
  1136. class Heavymotorvehicle extends vehicle
  1137. {
  1138. public $capacity;
  1139. public function __construct($a,$b,$c)
  1140. {
  1141. $this->company=$a;
  1142. $this->price=$b;
  1143. $this->capacity=$c;
  1144. }
  1145. public function display()
  1146. {
  1147. echo "<table border=1 width=300>";
  1148. echo "<tr><td>".$this->company."</td><td>".$this->price."</td><td>".$this>capacity;
  1149. echo "</td></tr></table>";
  1150. }
  1151. }
  1152. $ob1=new Lightmotorvehicle("Maruti",200000,25);
  1153. $ob1->display();
  1154. $ob2=new Lightmotorvehicle("Toyota",500000,20);
  1155. $ob2->display();
  1156. $ob3=new Lightmotorvehicle("skoda",400000,15);
  1157. $ob3->display();
  1158. $ob4=new Heavymotorvehicle("Tata Truck",1220000,25);
  1159. $ob4->display();
  1160. $ob5=new Heavymotorvehicle("Bajaj",200000,25);
  1161. $ob5->display();
  1162.  
  1163. $ob6=new Heavymotorvehicle("mahindra",900000,25); $ob6->display();
  1164. ?>
  1165.  
  1166. Slip no 10
  1167. Q1 :
  1168. import java.sql.*;
  1169.  
  1170. class slip10
  1171. {
  1172. public static void main(String args[])
  1173. {
  1174. Connection con;
  1175. Statement stmt;
  1176. try
  1177. {
  1178. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  1179. con=DriverManager.getConnection("jdbc:odbc:dsn");
  1180.  
  1181. System.out.println("Connection Established......");
  1182. stmt=con.createStatement();
  1183. ResultSet rs=stmt.executeQuery("select * from employee");
  1184.  
  1185. int cnt=0;
  1186. while(rs.next())
  1187. {
  1188. cnt++;
  1189. }
  1190. System.out.println("Number of records in Table are:"+cnt);
  1191. }
  1192.  
  1193. catch(Exception e)
  1194. {
  1195.  
  1196.  
  1197. }
  1198. }
  1199. }
  1200. Q2 :
  1201. Slip 10_2.java
  1202. import java.awt.*;
  1203. class Slip10_2 extends java.applet.Applet implements Runnable
  1204. {
  1205. Thread t;
  1206. int f,y,f1,f2,f3;
  1207. public void init()
  1208. {
  1209. t=new Thread(this);
  1210. t.start();
  1211. f=0;
  1212. y=0;
  1213. f1=0;
  1214. }
  1215. public void run()
  1216. {
  1217. try {
  1218.  
  1219. if (f==0)
  1220. {
  1221. t.sleep(10);
  1222. y=y+5;
  1223. repaint();
  1224. if(f1==6)
  1225. f1=0;
  1226. }
  1227. if(f==1)
  1228. {
  1229. t.sleep(10);
  1230. y=y-5;
  1231. repaint();
  1232. if(f1==6)
  1233. f1=0;
  1234. }
  1235. }
  1236. catch(Exception e)
  1237. {
  1238. System.out.println(e);
  1239. }
  1240. run();
  1241. }
  1242. public void paint(Graphics g)
  1243. {
  1244. if(f==0)
  1245. {
  1246. if(f1==1)
  1247. g.setColor(Color.green);
  1248. if(f1==2) g.setColor(Color.blue);
  1249. if(f1==3) g.setColor(Color.red);
  1250. if(f1==4) g.setColor(Color.yellow);
  1251. if(f1==5) g.setColor(Color.orange);
  1252. g.fillOval(150,y+10,20,20);
  1253. if(y==400)
  1254. {
  1255. f1++;
  1256. f=1;
  1257. }
  1258. }
  1259. if(f==1)
  1260. {
  1261. if(f1==1)
  1262. g.setColor(Color.green);
  1263. if(f1==2) g.setColor(Color.blue);
  1264. if(f1==3) g.setColor(Color.red);
  1265. if(f1==4) g.setColor(Color.yellow);
  1266. if(f1==5) g.setColor(Color.orange);
  1267. g.fillOval(150,y-10,20,20);
  1268. if(y==0)
  1269. {
  1270. f1++; f=0;
  1271. }
  1272. }
  1273. }
  1274. Q3 :
  1275. Html File :
  1276. <html>
  1277. <head>
  1278. <script>
  1279.  
  1280. function getans()
  1281. {
  1282. st1=document.getElementById('txtname').value;
  1283. st2=document.getElementById('txtpass').value;
  1284. ob=new XMLHttpRequest();
  1285. if(ob)
  1286. alert("object created");
  1287. ob.onreadystatechange=function()
  1288. {
  1289. if(ob.readyState==4 && ob.status==200)
  1290. {
  1291. if(ob.responseText==3)
  1292. {
  1293. alert("sorry you lost the chances to login");
  1294. location="error.html";
  1295. }
  1296. else if(ob.responseText=="correct")
  1297. {
  1298. alert("you entered correct details");
  1299. }
  1300. else
  1301. alert(ob.responseText);
  1302. }
  1303. }
  1304. ob.open("GET","slip10.php?n="+st1+"&p="+st2); ob.send();
  1305.  
  1306. }
  1307.  
  1308. </script>
  1309.  
  1310. </head>
  1311. <body>
  1312. <input type=text id=txtname placeholder="username"></br>
  1313. <input type=password id=txtpass placeholder="password"></br>
  1314. <input type="button" onclick="getans()" value="Login">
  1315.  
  1316.  
  1317. </body>
  1318.  
  1319. </html>
  1320.  
  1321. php file :
  1322.  
  1323. <?php
  1324. $nm=$_GET['n'];
  1325. $ps=$_GET['p'];
  1326. if($nm==$ps)
  1327. {
  1328. echo "correct";
  1329. }
  1330. else if(isset($_COOKIE['cnt']))
  1331. {
  1332. $x=$_COOKIE['cnt'];
  1333. $x=$x+1;
  1334. setcookie('cnt',$x);
  1335. echo $_COOKIE['cnt'];
  1336. if($_COOKIE['cnt']>=3)
  1337. setcookie('cnt',1);
  1338.  
  1339. }
  1340. else
  1341. {
  1342. setcookie('cnt',1);
  1343. echo "1";
  1344. }
  1345. ?>
  1346. Q4 :
  1347. Html file :
  1348.  
  1349. <html>
  1350. <body>
  1351.  
  1352. <form action="slip_10-1.php" method="post"> <center> <h2>Enter Students information :</h2>
  1353.  
  1354. <table>
  1355. <tr>
  1356. <td>Name : </td>
  1357. <td><input type="text" name="name"></td>
  1358. </tr>
  1359. <tr>
  1360. <td>Address : </td>
  1361. <td><input type="text" name="addr"></td>
  1362. </tr>
  1363. <tr>
  1364. <td>Class : </td>
  1365. <td><input type="text" name="class"></td>
  1366. </tr>
  1367. <tr>
  1368. <td></td>
  1369. <td><input type="submit" value=Next></td>
  1370. </tr>
  1371. </table> </center>
  1372.  
  1373. </form>
  1374. </body>
  1375. </html>
  1376.  
  1377. Php file : Slip_10-1.php : <html> <body>
  1378.  
  1379. <form action="slip_10-2.php" method="post"> <center> <h2>Enter Marks for Student:</h2>
  1380.  
  1381. <table>
  1382. <tr>
  1383. <td>Java : </td>
  1384. <td><input type="text" name="m1"></td>
  1385. </tr>
  1386. <tr><td>PHP : </td>
  1387. <td><input type="text" name="m2"></td>
  1388. </tr>
  1389. <tr><td>ST : </td>
  1390. <td><input type="text" name="m3"></td>
  1391. </tr>
  1392. <tr><td>IT : </td>
  1393. <td><input type="text" name="m4"></td>
  1394. </tr>
  1395. <tr>
  1396. <td>Practical : </td>
  1397. <td>
  1398. <input type="text" name="m5"></td>
  1399. </tr>
  1400. <tr><td>Project : </td>
  1401. <td><input type="text" name="m6"></td>
  1402. </tr>
  1403. <tr><td></td>
  1404. <td><input type="submit" value=Next></td>
  1405. </tr>
  1406. </table> </center>
  1407.  
  1408. </form> </body>
  1409. </html>
  1410.  
  1411.  
  1412. <?php
  1413. setcookie("stud1",$_POST['name'],time()+3600);
  1414. setcookie("stud2",$_POST['addr'],time()+3600);
  1415. setcookie("stud3",$_POST['class'],time()+3600);
  1416. ?>
  1417.  
  1418. Slip_10-2.php :
  1419.  
  1420. <?php
  1421. echo "<h3>Marksheet</h3> ";
  1422.  
  1423. echo "Name : ".$_COOKIE['stud1']."<br>";
  1424. echo "Address : ".$_COOKIE['stud2']."\n";
  1425. echo "Class : ".$_COOKIE['stud3']."\n";
  1426.  
  1427. echo "Java : ".$_POST['m1']."\n";
  1428. echo "PHP : ".$_POST['m2']."\n";
  1429. echo "ST : ".$_POST['m3']."\n";
  1430. echo "IT : ".$_POST['m3']."\n";
  1431. echo "Practical : ".$_POST['m3']."\n";
  1432. echo "Project : ".$_POST['m3']."\n";
  1433.  
  1434. ?>
  1435.  
  1436. Slip no 12
  1437. Q1 :
  1438. import java.awt.event.*;
  1439. import javax.swing.*;
  1440.  
  1441.  
  1442.  
  1443. class slip12 extends JFrame implements ActionListener,Runnable
  1444. {
  1445.  
  1446.  
  1447. JTextField t;
  1448. JButton b;
  1449. Thread t1;
  1450.  
  1451. slip12()
  1452. {
  1453. setLayout(null);
  1454.  
  1455. setSize(300,300);
  1456. setVisible(true);
  1457.  
  1458. t = new JTextField(60);
  1459. b = new JButton("Start");
  1460.  
  1461. t1 = new Thread(this);
  1462.  
  1463. b.addActionListener(this);
  1464. t.setBounds(70,70,80,40);
  1465. add(t);
  1466. b.setBounds(70,150,100,30);
  1467. add(b);
  1468.  
  1469.  
  1470. }
  1471.  
  1472.  
  1473. public void actionPerformed(ActionEvent e)
  1474. {
  1475. t1.start();
  1476. }
  1477.  
  1478. public void run()
  1479. {
  1480. for(int i =1; i<=100;i++)
  1481. {
  1482. t.setText(""+i);
  1483. try
  1484. {
  1485. Thread.sleep(150);
  1486. }
  1487. catch(Exception e)
  1488. {
  1489.  
  1490. }
  1491. }
  1492. }
  1493. public static void main(String args[])
  1494. {
  1495. new slip12();
  1496. }
  1497. }
  1498. Q2 :
  1499. Account :
  1500. <form method='post' action='add_account.jsp'>
  1501. <table>
  1502. <tr>
  1503. <td><b>Account No:</b></td>
  1504. <td><input type='text' name='ano'></td>
  1505. </tr>
  1506. <tr>
  1507. <td><b>Account Type:</b></td>
  1508. <td>
  1509. <select name='type'>
  1510. <option value=''>Select Type</option>
  1511. <option value='Saving'>Saving</option>
  1512. <option value='Current'>Current</option>
  1513. </select>
  1514. </td>
  1515. </tr>
  1516. <tr><td><b>Balance:</b></td><td><input type='text' name='bal'></td></tr>
  1517. <tr><td><input type='submit'></td><td><input type='reset'></td></tr>
  1518. </table>
  1519. </form>
  1520. <a href='view_accounts.jsp'>View Accounts</a>
  1521. Add_accounts.jsp :
  1522. <%@page import="java.sql.*" errorPage="err.jsp"%>
  1523. <%
  1524. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  1525. Connection con = DriverManager.getConnection("jdbc:odbc:lab.dsn");
  1526.  
  1527. int ano = Integer.parseInt(request.getParameter("ano"));
  1528. String type = request.getParameter("type");
  1529. float bal = Float.parseFloat(request.getParameter("bal"));
  1530. PreparedStatement ps = con.prepareStatement("insert into account values(?,?,?)");
  1531. ps.setInt(1,ano);
  1532. ps.setString(2,type);
  1533. ps.setFloat(3,bal);
  1534. ps.executeUpdate();
  1535. %>
  1536. Account created successfully.<br>
  1537. <a href='account.html'>Add Account</a> <a href='view_accounts.jsp'>View Accounts</a>
  1538. Err .jsp :
  1539. <%@page isErrorPage="true"%>
  1540. Error:<%=exception%><br>
  1541. <a href='account.html'>Home</a>
  1542. View_accounts.jsp :
  1543. <%@page import="java.sql.*"%>
  1544.  
  1545. <%
  1546. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  1547. Connection con = DriverManager.getConnection("jdbc:odbc:lab.dsn");
  1548. Statement s = con.createStatement();
  1549. ResultSet rs = s.executeQuery("select * from account");
  1550. %>
  1551. <table border=1>
  1552. <tr><th>Account No</th><th>Type</th><th>Balance</th></tr>
  1553. <%
  1554. while(rs.next()){
  1555. %>
  1556. <tr><td><%=rs.getInt(1)%></td><td><%=rs.getString(2)%></td><td><%=rs.getFloat(3)%></td>
  1557. </tr>
  1558. <%
  1559. }
  1560. %>
  1561. </table><br>
  1562. <a href='account.html'>Home</a>
  1563. Q3 :
  1564. <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>
  1565.  
  1566. <?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>
  1567. Q4 :
  1568. <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>
  1569.  
  1570. 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>"; } ?>
  1571. Slip no 13
  1572. Q1 :
  1573. import java.sql.*;
  1574. class slip13
  1575. {
  1576. public static void main(String a[])
  1577. {
  1578. Connection con;
  1579. Statement stmt;
  1580. try
  1581. {
  1582. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  1583. con=DriverManager.getConnection("jdbc:odbc:dsn");
  1584.  
  1585. System.out.println("Connection Established....");
  1586. stmt=con.createStatement();
  1587.  
  1588. String sql="create table mobile"+"(Model_No int,"+"Company_Name varchar(20),"+"price float(6,2),"+"color varchar(20))";
  1589. stmt.executeUpdate(sql);
  1590. System.out.println("Table Created sucessfully...");
  1591.  
  1592. con.close();
  1593.  
  1594. }
  1595. catch(Exception e)
  1596. {
  1597.  
  1598. }
  1599. }
  1600. }
  1601. Q2 :
  1602. GossipClient :
  1603. import java.io.*;
  1604. import java.net.*;
  1605. public class GossipClient
  1606. {
  1607. public static void main(String[] args) throws Exception
  1608. {
  1609. Socket sock = new Socket("127.0.0.1", 3000);
  1610. // reading from keyboard (keyRead object)
  1611. BufferedReader keyRead = new BufferedReader(new InputStreamReader(System.in));
  1612. // sending to client (pwrite object)
  1613. OutputStream ostream = sock.getOutputStream();
  1614. PrintWriter pwrite = new PrintWriter(ostream, true);
  1615.  
  1616. // receiving from server ( receiveRead object)
  1617. InputStream istream = sock.getInputStream();
  1618. BufferedReader receiveRead = new BufferedReader(new InputStreamReader(istream));
  1619.  
  1620. System.out.println("Start the chitchat, type and press Enter key");
  1621.  
  1622. String receiveMessage, sendMessage;
  1623. while(true)
  1624. {
  1625. sendMessage = keyRead.readLine(); // keyboard reading
  1626. pwrite.println(sendMessage); // sending to server
  1627. pwrite.flush(); // flush the data
  1628. if((receiveMessage = receiveRead.readLine()) != null) //receive from server
  1629. {
  1630. System.out.println(receiveMessage); // displaying at DOS prompt
  1631. }
  1632. }
  1633. }
  1634. }
  1635. GossipServer :
  1636. import java.io.*;
  1637. import java.net.*;
  1638. public class GossipServer
  1639. {
  1640. public static void main(String[] args) throws Exception
  1641. {
  1642. ServerSocket sersock = new ServerSocket(3000);
  1643. System.out.println("Server ready for chatting");
  1644. Socket sock = sersock.accept( );
  1645. // reading from keyboard (keyRead object)
  1646. BufferedReader keyRead = new BufferedReader(new InputStreamReader(System.in));
  1647. // sending to client (pwrite object)
  1648. OutputStream ostream = sock.getOutputStream();
  1649. PrintWriter pwrite = new PrintWriter(ostream, true);
  1650.  
  1651. // receiving from server ( receiveRead object)
  1652. InputStream istream = sock.getInputStream();
  1653. BufferedReader receiveRead = new BufferedReader(new InputStreamReader(istream));
  1654.  
  1655. String receiveMessage, sendMessage;
  1656. while(true)
  1657. {
  1658. if((receiveMessage = receiveRead.readLine()) != null)
  1659. {
  1660. System.out.println(receiveMessage);
  1661. }
  1662. sendMessage = keyRead.readLine();
  1663. pwrite.println(sendMessage);
  1664. pwrite.flush();
  1665. }
  1666. }
  1667. }
  1668. Q3 :
  1669. 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) {
  1670.  
  1671. 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>
  1672.  
  1673. </body>
  1674.  
  1675. </html>
  1676.  
  1677. PHP File :
  1678.  
  1679. <?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>"; ?>
  1680. Q4 :
  1681. Html file :
  1682.  
  1683. <html> <body>
  1684.  
  1685. <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>
  1686.  
  1687. Php file :
  1688.  
  1689. <?php $c_name = $_GET['cname'];
  1690.  
  1691. $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");
  1692.  
  1693. 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>";
  1694.  
  1695. } echo "</table>";
  1696.  
  1697. mysql_close();
  1698.  
  1699. ?>
  1700. Slip no 15
  1701. Q1 :
  1702. import java.sql.*;
  1703. import java.io.*;
  1704. class slip15
  1705. {
  1706. public static void main(String args[])
  1707. {
  1708. Connection con;
  1709. Statement stmt;
  1710. PreparedStatement ps;
  1711. String name;
  1712. try
  1713. {
  1714. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  1715. con=DriverManager.getConnection("jdbc:odbc:dsn");
  1716.  
  1717. System.out.println("Connection Established...");
  1718.  
  1719. stmt=con.createStatement();
  1720.  
  1721. String query="Update Customer set address=? where name=?";
  1722. ps=con.prepareStatement(query);
  1723.  
  1724. BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  1725. System.out.println("Enter Customer name for Update:");
  1726. name=br.readLine();
  1727.  
  1728. System.out.println("Enter new Address:");
  1729. String addr=br.readLine();
  1730. ps.setString(1,addr);
  1731. ps.setString(2,name);
  1732. ps.executeUpdate();
  1733.  
  1734.  
  1735. System.out.println("Succesfully updated in table....");
  1736.  
  1737. ps=con.prepareStatement("select * from Customer where name=?");
  1738. ps.setString(1,name);
  1739. ResultSet rs=ps.executeQuery();
  1740. System.out.println("cid\t"+"Name\t"+"address\t"+"ph_no");
  1741. while(rs.next())
  1742. {
  1743. System.out.println("\n"+rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getString(3)+"\t"+rs.getString(4));
  1744. }
  1745. }
  1746. con.close();
  1747.  
  1748. }
  1749. catch(Exception e)
  1750. {
  1751. System.out.println(e);
  1752. }
  1753. }
  1754. Q2 :
  1755. import java.io.*;
  1756. import javax.servlet.*;
  1757. import javax.servlet.http.*;
  1758. public class Student extends HttpServlet
  1759. {
  1760. public void doPost(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException
  1761. {
  1762. int sno,s1,s2,s3,total;
  1763. String snm,sclass;
  1764. float per;
  1765. res.setContentType("text/html");
  1766. PrintWriter out=res.getWriter();
  1767. sno=Integer.parseInt(req.getParameter("txtsno"));
  1768. snm=req.getParameter("txtnm");
  1769. sclass=req.getParameter("txtclass");
  1770. s1=Integer.parseInt(req.getParameter("txtsub1"));
  1771. s2=Integer.parseInt(req.getParameter("txtsub2"));
  1772. s3=Integer.parseInt(req.getParameter("txtsub3"));
  1773. total=s1+s2+s3;
  1774. per=(total/3);
  1775. out.println("<html><body>");
  1776. out.print("<h2>Result of student</h2><br>");
  1777. out.println("<b><i>Roll No :</b></i>"+sno+"<br>");
  1778. out.println("<b><i>Name :</b></i>"+snm+"<br>");
  1779. out.println("<b><i>Class :</b></i>"+sclass+"<br>");
  1780. out.println("<b><i>Subject1:</b></i>"+s1+"<br>");
  1781. out.println("<b><i>Subject2:</b></i>"+s2+"<br>");
  1782. out.println("<b><i>Subject3:</b></i>"+s3+"<br>");
  1783. out.println("<b><i>Total :</b></i>"+total+"<br>");
  1784. out.println("<b><i>Percentage :</b></i>"+per+"<br>");
  1785. if(per<50)
  1786. out.println("<h1><i>Pass Class</i></h1>");
  1787. else if(per<55 && per>50)
  1788. out.println("<h1><i>Second class</i></h1>");
  1789. else if(per<60 && per>=55)
  1790. out.println("<h1><i>Higher class</i></h1>");
  1791. out.close();
  1792. }
  1793. }
  1794. Html :
  1795.  
  1796. <html>
  1797. <body>
  1798. <form name="f1" method="Post" action="http://localhost:8080/Stud">
  1799.  
  1800. Enter Roll No :&nbsp <input type="text" name="txtsno"><br><br>
  1801. Enter Name :&nbsp &nbsp <input type="text" name="txtnm"><br><br>
  1802. Enter class :&nbsp &nbsp &nbsp <input type="text" name="txtclass"><br><br>
  1803. Subject 1 :&nbsp &nbsp &nbsp <input type="text" name="txtsub1"><br><br>
  1804. Subject 2 :&nbsp &nbsp &nbsp <input type="text" name="txtsub2"><br><br>
  1805. Subject 3 :&nbsp &nbsp &nbsp <input type="text" name="txtsub3"><br><br>
  1806.  
  1807. <input type="submit" value="Result">
  1808. </div>
  1809. </form>
  1810. </body>
  1811. </html>
  1812. Q3 :
  1813. HTML File <html>
  1814. <form action=slip15.php method=post enctype=multipart/form-data>
  1815. <input type=file name=file></br>
  1816. <input type=submit value="Upload">
  1817. </form>
  1818. </html>
  1819.  
  1820. PHP File :
  1821. <?php
  1822.  
  1823. echo "File name : ".$_FILES['file']['name']."</br>";
  1824. $f=$_FILES['file']['size'];
  1825. echo "Size :".$f."</br>";
  1826. echo "File Name on Sever: ".$_FILES['file']['tmp_name']."</br>";
  1827. echo "File Error: ".$_FILES['file']['error']."</br>";
  1828.  
  1829. print_r($_FILES);
  1830.  
  1831. ?>
  1832. Q4 :
  1833. Html file :
  1834.  
  1835. <html>
  1836. <head>
  1837. <script type="text/javascript" >
  1838. function m1(str)
  1839. {
  1840. var ob=false;
  1841. ob=new XMLHttpRequest();
  1842. ob.open("GET","slip_15.php?q="+str);
  1843. ob.send();
  1844. ob.onreadystatechange=function()
  1845. {
  1846. if(ob.readyState==4 && ob.status==200)
  1847. {
  1848. document.getElementById("a").innerHTML=ob.res ponseText;
  1849. }
  1850. }
  1851. }
  1852.  
  1853. </script>
  1854. </head>
  1855.  
  1856. <body> <form>
  1857.  
  1858. Search<input type=text name=search size="20" onkeyup="m1(form.search.value)">
  1859.  
  1860. <input type=button value="submit" onclick="m1(form.search.value)">
  1861.  
  1862. </form> suggestions :<span id="a"></span><br>
  1863.  
  1864. </body> </html>
  1865.  
  1866. Php file :
  1867.  
  1868. <?php
  1869. $a=array("pune","satara","nashik","sangli","mumbai","murud","akola","dound ","dhule","ratnagiri","rajpur");
  1870.  
  1871. $q=$_GET['q'];
  1872.  
  1873. if(strlen($q)>0)
  1874. {
  1875. $match="";
  1876. for($i=0;$i<count($a);$i++)
  1877. {
  1878. if(strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))
  1879. {
  1880. if($match=="")
  1881. $match=$a[$i];
  1882. else $match=$match.",".$a[$i];
  1883. }
  1884. }
  1885. if($match=="")
  1886. echo "No Suggestios";
  1887. else echo $match;
  1888. }
  1889. ?>
  1890.  
  1891. Slip no 16
  1892. Q1 :
  1893. <HTML>
  1894. <HEAD>
  1895. <TITLE> 4.JSP SET B:1 </TITLE>
  1896. </HEAD>
  1897. <BODY>
  1898. <form action="http://localhost:8080/ty/a3.jsp" method="POST">
  1899. Enter the user name:
  1900. <input type="text" name="a">
  1901. <br><br>
  1902. <input type="Submit" value="Submit"/>
  1903. </form>
  1904. </BODY>
  1905. </HTML>
  1906. A3 :
  1907. <%@ page language="java" import="java.util.*" %>
  1908. <%
  1909. String name,date;
  1910. name=request.getParameter("a");
  1911. Date d=new Date();
  1912. date=d.toLocaleString();
  1913. String s[]=date.split(" ");
  1914. out.println(" Current date and time is:"+date);
  1915. if(d.getHours() < 12 && s[4].equals("AM"))
  1916. out.println("<br>Good Morning "+name);
  1917. else
  1918. if(d.getHours()==12 && s[4].equals("PM"))
  1919. out.println("<br>Good Afternoon "+name);
  1920. else
  1921. if(d.getHours()<6 && s[4].equals("PM"))
  1922. out.println("<br>Good Afternoon "+name);
  1923. else
  1924. if(d.getHours()>=6 && s[4].equals("PM"))
  1925. out.println("<br>Good Evening "+name);
  1926. %>
  1927. Q2 :
  1928. class MyThread extends Thread{
  1929.  
  1930. public MyThread(String s){
  1931. super(s);
  1932. }
  1933.  
  1934. public void run(){
  1935. System.out.println(getName()+" thread created.");
  1936. while(true){
  1937. System.out.println(this);
  1938. int s = (int)(Math.random()*5000);
  1939. System.out.println(getName()+" is sleeping for "+s+"msec");
  1940. try{
  1941. Thread.sleep(s);
  1942. }catch(Exception e){}
  1943. }
  1944. }
  1945. }
  1946.  
  1947. class ThreadLifeCycle{
  1948. public static void main(String args[]){
  1949. MyThread t1 = new MyThread("archana"),
  1950. t2 = new MyThread("adhira");
  1951. t1.start();
  1952. t2.start();
  1953.  
  1954. try{
  1955. t1.join();
  1956. t2.join();
  1957. }catch(Exception e){}
  1958.  
  1959. System.out.println(t1.getName()+" thread dead.");
  1960. System.out.println(t2.getName()+" thread dead.");
  1961. }
  1962. }
  1963. Q3 :
  1964. <?php echo"<table border=1>"; foreach($_SERVER as $k=>$v)
  1965.  
  1966. { echo"<tr><td>".$k."</td><td>".$v."</td></tr>"; } echo"</table>"; ?>
  1967. Q4 :
  1968.  
  1969.  
  1970. Slip no 17
  1971. Q1 :
  1972. class slip17
  1973. {
  1974. public static void main(String a[])
  1975. {
  1976. String S;
  1977. int p;
  1978.  
  1979. Thread t = Thread.currentThread();
  1980.  
  1981. S = t.getName();
  1982. System.out.println("\n Current Thread name : "+S);
  1983.  
  1984. p = t.getPriority();
  1985. System.out.println("\n Current thread priority : "+p);
  1986.  
  1987. t.setName("My Thread");
  1988. S = t.getName();
  1989. System.out.println("\nChanged Name : "+S);
  1990.  
  1991. t.setPriority(2);
  1992. p = t.getPriority();
  1993. System.out.println("\nChanged Priority : "+p);
  1994. }
  1995. }
  1996. Q2 :
  1997. import java.awt.*;
  1998. import java.awt.event.*;
  1999. import javax.swing.*;
  2000. import java.sql.*;
  2001.  
  2002. class DDLOperations extends JFrame{
  2003. private JPanel panNorth,panSouth;
  2004. private JLabel lblQuery;
  2005. private JTextArea txtQuery;
  2006. private JButton btnCreate,btnAlter,btnDrop;
  2007.  
  2008. public DDLOperations(){
  2009. lblQuery = new JLabel("Type DDL Query");
  2010. txtQuery = new JTextArea(4,50);
  2011.  
  2012. panNorth = new JPanel();
  2013. panNorth.add(lblQuery);
  2014. panNorth.add(new JScrollPane(txtQuery));
  2015.  
  2016. btnCreate = new JButton("Create Table");
  2017. btnAlter = new JButton("Alter Table");
  2018. btnDrop = new JButton("Drop Table");
  2019.  
  2020. panSouth = new JPanel();
  2021. panSouth.add(btnCreate);
  2022. panSouth.add(btnAlter);
  2023. panSouth.add(btnDrop);
  2024.  
  2025. setTitle("DDL Operations");
  2026. setSize(400,300);
  2027. add(panNorth,"North");
  2028. add(panSouth,"South");
  2029. setVisible(true);
  2030. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  2031.  
  2032. ButtonHandler bh = new ButtonHandler();
  2033. btnCreate.addActionListener(bh);
  2034. btnAlter.addActionListener(bh);
  2035. btnDrop.addActionListener(bh);
  2036. }
  2037.  
  2038. class ButtonHandler implements ActionListener{
  2039. public void actionPerformed(ActionEvent ae){
  2040. try{
  2041. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  2042. con=DriverManager.getConnection("jdbc:odbc:lab.dsn");
  2043.  
  2044. String sql = txtQuery.getText();
  2045. Statement s = con.createStatement();
  2046. s.execute(sql);
  2047. txtQuery.setText("");
  2048. }
  2049. catch(Exception e){
  2050. JOptionPane.showMessageDialog(null,e);
  2051. }
  2052. }
  2053. }
  2054.  
  2055. public static void main(String args[]){
  2056. new DDLOperations();
  2057. }
  2058. }
  2059. Q3 :
  2060. Html file :
  2061.  
  2062. <html>
  2063. <body>
  2064. <form action=Que14.php method=get>
  2065. <center>
  2066. Full Name :<input type=text name=nm> <br>
  2067. <font color=red size=2>(Format is:First,Middle,Surname) </font>
  2068. <br>Email ID :<input type=text name=eid>
  2069. <br><input type=submit value=Show>
  2070. </center>
  2071. </form>
  2072. </body> </html>
  2073.  
  2074.  
  2075.  
  2076.  
  2077. Php file :
  2078.  
  2079. <?php
  2080.  
  2081. $nm=$_GET['nm'];
  2082.  
  2083. $eid=$_GET['eid'];
  2084.  
  2085. echo "<br>Capitalization of each word of each name :".ucwords($nm);
  2086.  
  2087.  
  2088. $e=explode('@',$eid);
  2089.  
  2090. If (count($e)==2)
  2091. {
  2092. echo "<br>Email id contains @ symbol ";
  2093. }
  2094. else
  2095. echo "<br>email id doesn’t contains @ symbol or contains more @ symbol";
  2096. ?>
  2097. Q4 :
  2098. Html file :
  2099.  
  2100. <html>
  2101. <head>
  2102. <title>login</title> </head>
  2103. <body>
  2104.  
  2105. <center> <form action="slip_16.php" method="post"> <table>
  2106. <tr><td><label>Email id :</label></td>
  2107. <td><input type=text name=emailid></td></tr>
  2108. <tr><td><label >Password :</label></td>
  2109. <td><input type=password name=password></td></tr>
  2110. <tr><td><input type=submit value="login & continue"></td>
  2111. <td></td></tr>
  2112. </table>
  2113. </form> </center>
  2114.  
  2115. </body> </html>
  2116.  
  2117.  
  2118. Php file :
  2119.  
  2120. <?php
  2121. $con=mysql_connect("localhost","root","") or die("I cannot connect");
  2122. //echo "connected successfuly";
  2123. $d=mysql_select_db("bca_programs",$con);
  2124. $q=mysql_query("select * from login");
  2125.  
  2126. $emailid=$_REQUEST['emailid'];
  2127. //echo $emailid;
  2128. $password=$_REQUEST['password'];
  2129.  
  2130. $n=0;
  2131. while($row=mysql_fetch_array($q))
  2132. {
  2133. if($row[0]==$emailid && $row[1]==$password)
  2134. $n=1;
  2135. }
  2136.  
  2137. if($n==1)
  2138. echo "<center><h3>WELCOME USER</h3><center>";
  2139. else
  2140.  
  2141. echo "<i>Emailid or Password Missmatch</i>";
  2142.  
  2143. ?>
  2144.  
  2145. Slip no 18
  2146. Q1 :
  2147. class PrintDemo
  2148. {
  2149. public void printCount()
  2150. {
  2151. try
  2152. {
  2153. for(int i = 5; i > 0; i--)
  2154. {
  2155. System.out.println("Counter --- " + i );
  2156. }
  2157. }
  2158. catch (Exception e)
  2159. {
  2160. System.out.println("Thread interrupted.");
  2161. }
  2162. }
  2163.  
  2164. }
  2165.  
  2166. class ThreadDemo extends Thread
  2167. {
  2168. private Thread t;
  2169. private String threadName;
  2170. PrintDemo PD;
  2171.  
  2172. ThreadDemo( String name, PrintDemo pd)
  2173. {
  2174. threadName = name;
  2175. PD = pd;
  2176. }
  2177. public void run()
  2178. {
  2179. synchronized(PD)
  2180. {
  2181. PD.printCount();
  2182. }
  2183. System.out.println("Thread " + threadName + " exiting.");
  2184. }
  2185.  
  2186. public void start ()
  2187. {
  2188. System.out.println("Starting " + threadName );
  2189. if (t == null)
  2190. {
  2191. t = new Thread (this, threadName);
  2192. t.start ();
  2193. }
  2194. }
  2195.  
  2196. }
  2197.  
  2198. public class slip18
  2199. {
  2200. public static void main(String a[])
  2201. {
  2202.  
  2203. PrintDemo PD = new PrintDemo();
  2204.  
  2205. ThreadDemo T1 = new ThreadDemo( "Thread - 1 ", PD );
  2206. ThreadDemo T2 = new ThreadDemo( "Thread - 2 ", PD );
  2207.  
  2208. T1.start();
  2209. T2.start();
  2210.  
  2211. // wait for threads to end
  2212. try
  2213. {
  2214. T1.join();
  2215. T2.join();
  2216. }
  2217. catch( Exception e)
  2218. {
  2219.  
  2220. }
  2221. }
  2222. }
  2223. Q2 :
  2224. import java.io.*;
  2225. import javax.servlet.*;
  2226. import javax.servlet.http.*;
  2227. import java.util.*;
  2228.  
  2229. public class info_check extends HttpServlet
  2230. {
  2231. public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
  2232. {
  2233. try
  2234. {
  2235. res.setContentType("text/html");
  2236. PrintWriter out = res.getWriter();
  2237. out.println("<html>");
  2238. out.println("<body>");
  2239. java.util.Properties p=System.getProperties();
  2240. out.println("Server Name :"+req.getServerName()+"<br>");
  2241. out.println("Operating System Name :"+p.getProperty("Linux")+"<br>");
  2242. out.println("IP Address :"+req.getRemoteAddr()+"<br>");
  2243. out.println("Remote User:"+req.getRemoteUser()+"<br>");
  2244. out.println("Remote Host:"+req.getRemoteHost()+"<br>");
  2245. out.println("Local Name :"+req.getLocalName()+"<br>");
  2246. out.println("Server Port:"+req.getServerPort()+"<br>");
  2247. out.println("Servlet Name :"+this.getServletName()+"<br>");
  2248. out.println("Protocol Name :"+req.getProtocol()+"<br>");
  2249. out.println("</html>");
  2250. out.println("</body>");
  2251. }
  2252. catch(Exception e)
  2253. {
  2254. e.printStackTrace();
  2255.  
  2256. }
  2257. }
  2258. }
  2259. Q3 :
  2260. Html file :
  2261. <slip_18.html>
  2262.  
  2263. <html> <body>
  2264.  
  2265. <form action="slip_18.php" method="get">
  2266. <center> <h2> Enployee Details :</h2>
  2267. <br> <table>
  2268. <tr> <td><input type=radio name=r value="1"></td>
  2269. <td><b>Create Employee Table:</b></td>
  2270. </tr>
  2271.  
  2272. <tr> <td><input type=radio name=r value="2"></td>
  2273. <td><b> Read/Insert Values :</b></td>
  2274. </tr>
  2275. <tr>
  2276. <td><input type=radio name=r value="3"></td>
  2277. <td><b>Update Values :</b></td>
  2278. </tr>
  2279. <tr>
  2280. <td><input type=radio name=r value="4"></td>
  2281. <td><b>Display :</b>
  2282. </td>
  2283. </tr>
  2284.  
  2285. </table> <br> <input type=submit value=Submit name=submit> </center> </form>
  2286.  
  2287. </body> </html>
  2288.  
  2289. Php file :
  2290. (slip_18.php) :
  2291.  
  2292. <?php
  2293. $r=$_GET['r'];
  2294. $con = mysql_connect("localhost","root","");
  2295.  
  2296. $d = mysql_select_db("bca_programs",$con);
  2297.  
  2298. if($r==1)
  2299. {
  2300. $q=mysql_query("create table emp_slip_18(empno int,ename varchar(10),date_of_join date,salary int,address varchar(20))");
  2301. echo "<center><b><h2> Table Created Successfully.....!!!</h2><b></center>";
  2302. }
  2303.  
  2304. else if($r==2)
  2305. {
  2306. header("location:slip_18_insert.html");
  2307. }
  2308. /*$q2=mysql_query("insert into emp_slip_18 values($a_no,'$a_name','$d_join',$a_sal,'$a_add')");
  2309. echo "<center><b><h2> Values Inserted Successfully.....!!!</h2><b></center>"; */
  2310. else if($r==3)
  2311. {
  2312. header("location:slip_18update.html");
  2313.  
  2314. }
  2315.  
  2316. else if($r==4)
  2317. {
  2318. $q4=mysql_query("select *from emp_slip_18");
  2319. echo "<center>";
  2320. echo "<table border=1 width=30% height=20%>";
  2321. 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))
  2322. {
  2323. echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[ 3]."</td><td>".$row[4]."</td></tr>"; }
  2324. echo "</table>";
  2325. echo "</center>";
  2326. }
  2327.  
  2328.  
  2329. ?>
  2330.  
  2331. <slip_18_insert.html> :
  2332.  
  2333. <html> <body>
  2334.  
  2335. <form action="slip_18_insert.php" method="get"> <center> <h2>Enter Enployee Details :</h2> <br> <table>
  2336.  
  2337. <tr> <td>Enter Employee no :</td
  2338. ><td><input type=text name=a_no> </td>
  2339. </tr>
  2340. <tr> <td>Enter Employee name :</td>
  2341. <td><input type=text name=a_name></td> </tr>
  2342. <tr> <td>Enter Date Of Join :</td><td><input type=text name=d_join></td> </tr>
  2343. <tr> <td>Enter Salary :</td>
  2344. <td><input type=text name=a_sal></td>
  2345. </tr>
  2346. <tr>
  2347. <td>Enter Address :</td>
  2348. <td><input type=text name=a_add></td>
  2349. </tr>
  2350.  
  2351. <tr>
  2352. <td><input type=submit value=Show name=submit></td>
  2353. </tr>
  2354.  
  2355. </table> </center> </form>
  2356.  
  2357. </body> </html>
  2358.  
  2359. (slip_18_insert.html) :
  2360.  
  2361. <html> <body>
  2362.  
  2363. <form action="slip_18_insert.php" method="get">
  2364. <center>
  2365. <h2>Enter Enployee Details :</h2>
  2366. <br>
  2367. <table>
  2368. <tr>
  2369. <td>Enter Employee no :</td>
  2370. <td><input type=text name=a_no> </td>
  2371. </tr>
  2372. <tr>
  2373. <td>Enter Employee name :</td>
  2374. <td><input type=text name=a_name></td> </tr>
  2375. <tr> <td>Enter Date Of Join :</td>
  2376. <td><input type=text name=d_join></td> </tr>
  2377. <tr> <td>Enter Salary :</td><td><input type=text name=a_sal></td> </tr>
  2378. <tr> <td>Enter Address :</td><td><input type=text name=a_add></td> </tr>
  2379. <tr> <td><input type=submit value=Show name=submit></td> </tr>
  2380. </table> </center>
  2381. </form>
  2382. </body> </html>
  2383.  
  2384. (slip_18_insert.php) :
  2385. <?php
  2386. $a_no=$_GET['a_no'];
  2387. $a_name=$_GET['a_name'];
  2388. $d_join=$_GET['d_join'];
  2389. $a_sal=$_GET['a_sal'];
  2390. $a_add=$_GET['a_add'];
  2391. $con = mysql_connect("localhost","root","");
  2392. $d = mysql_select_db("bca_programs",$con);
  2393. $q2=mysql_query("insert into emp_slip_18 values($a_no,'$a_name','$d_join',$a_sal,'$a_add')");
  2394. echo "<center><b><h2> Values Inserted Successfully.....!!!</h2><b></center>";
  2395. ?>
  2396.  
  2397. (slip_18_update.html) :
  2398. <?php
  2399. $edit=$_GET['edit'];
  2400.  
  2401. $c=mysql_connect("localhost","root","");
  2402. $d=mysql_select_db("bca_programs",$c);
  2403. $q=mysql_query("select * from emp_slip_18");
  2404.  
  2405. $row=mysql_fetch_array($q);
  2406.  
  2407. ?>
  2408.  
  2409. <html>
  2410. <body>
  2411.  
  2412. <form action="slip_18_update.php" method="get"> <center> <h2>Update Enployee Details :</h2> <br>
  2413.  
  2414. <table>
  2415. <tr> <td> Employee no :</td>
  2416. <td><input type=text name=a_no value="<?php echo $row[0];?>"> </td> </tr>
  2417. <tr> <td> Employee name :</td><td><input type=text name=a_name value="<?php echo $row[1];?>"></td>
  2418. </tr>
  2419. <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>
  2420.  
  2421. <tr> <td><input type=submit value=Show name=submit></td> </tr>
  2422.  
  2423. </table> </center> </form>
  2424.  
  2425. </body> </html>
  2426.  
  2427. (slip_18_update1.php) :
  2428. <?php
  2429. $a_no=$_GET['a_no'];
  2430. $a_name=$_GET['a_name'];
  2431. $d_join=$_GET['d_join'];
  2432. $a_sal=$_GET['a_sal'];
  2433. $a_add=$_GET['a_add'];
  2434. $con = mysql_connect("localhost","root","");
  2435. $d = mysql_select_db("bca_programs",$con);
  2436. $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");
  2437.  
  2438. ?>
  2439. Slip no 19
  2440. Q1 :
  2441. <html>
  2442. <body>
  2443. <form method=get action="slip19_1.jsp">
  2444. Enter Any Number : <input type=text name=num><br><br>
  2445. <input type=submit value="Display">
  2446. </form>
  2447. </body>
  2448. </html>
  2449. Slip19_1.jsp :
  2450. <%@page language="java"%>
  2451.  
  2452. <html>
  2453. <body>
  2454. <font color=red>
  2455. <%! int i,n;
  2456. String s1;
  2457. %>
  2458. <% s1=request.getParameter("num");
  2459. n=s1.length();
  2460. i=0;
  2461. do
  2462. {
  2463. char ch=s1.charAt(i);
  2464. switch(ch)
  2465. {
  2466. case '0': out.println("Zero ");break;
  2467. case '1': out.println("One ");break;
  2468. case '2': out.println("Two ");break;
  2469. case '3': out.println("Three ");break;
  2470. case '4': out.println("Four ");break;
  2471. case '5': out.println("Five ");break;
  2472. case '6': out.println("Six ");break;
  2473. case '7': out.println("Seven ");break;
  2474. case '8': out.println("Eight ");break;
  2475. case '9': out.println("Nine ");break;
  2476. }
  2477. i++;
  2478. }while(i<n);
  2479. %>
  2480. </font>
  2481. </body>
  2482. </html>
  2483. Q2 :
  2484. Applet :
  2485. <html>
  2486. <body>
  2487. <applet code="Smile.class" height=200 width=200>
  2488. </applet>
  2489. </body>
  2490. </html>
  2491. Smile :
  2492. import java.applet.Applet;
  2493. import java.io.*;
  2494. import java.awt.*;
  2495. import java.util.*;
  2496. public class Smile extends Applet implements Runnable
  2497. {
  2498. Thread t;
  2499. int x=0;
  2500.  
  2501. public void run()
  2502. {
  2503. repaint();
  2504. }
  2505.  
  2506. public void init()
  2507. {
  2508. Smile s1=new Smile();
  2509. t=new Thread(s1);
  2510. t.start();
  2511. setSize(500,500);
  2512. setBackground(Color.blue);
  2513. }
  2514.  
  2515. public void paint(Graphics g)
  2516. {
  2517. if(x==0)
  2518. {
  2519. g.drawOval(40,40,130,130);
  2520. g.drawOval(57,75,20,20);
  2521. g.drawOval(110,75,20,20);
  2522. g.drawArc(60,110,80,40,180,180);
  2523. x=1;
  2524. }
  2525. else if(x==1)
  2526. {
  2527. g.drawOval(40,40,130,130);
  2528. g.drawOval(57,75,20,20);
  2529. g.drawOval(110,75,20,20);
  2530. g.drawArc(60,110,80,40,-180,-180);
  2531. x=0;
  2532. }
  2533. try
  2534. {
  2535. Thread.sleep(2000);
  2536. }
  2537. catch(Exception e)
  2538. {
  2539. e.printStackTrace();
  2540. }
  2541. repaint();
  2542. }
  2543. }
  2544. Q3 :
  2545. php file :
  2546.  
  2547. <html>
  2548. <body> <form method=post action="<?php echo $_SERVER['PHP_SELF'] ?>">
  2549. Enter String : <input type=text name=str1><br>
  2550. <input type=submit name=submit>
  2551. </form>
  2552. <?php
  2553. if(isset($_POST['submit']))
  2554. {
  2555. $str=$_POST['str1'];
  2556. $nstr=strrev($str);
  2557. echo"<br>".$nstr;
  2558. }
  2559. ?>
  2560. </body> </html>
  2561. Q4 :
  2562. Html file :
  2563.  
  2564. <html> <body>
  2565.  
  2566. <form action="slip_19.php" method="get"> <b>Enter the title of project :: </b>
  2567. <input type=text name=ptitle><br>
  2568. <input type=submit value=SUBMIT>
  2569. </form>
  2570. </body>
  2571. <html>
  2572.  
  2573. Php file :
  2574.  
  2575. <?php
  2576. $ptitle = $_GET['ptitle'];
  2577. $con = mysql_connect("localhost","root","");
  2578. $d = mysql_select_db("bca_programs",$con);
  2579. $q = mysql_query("select s_name from student_slip19,project where project_title='$ptitle' && student_slip19.p_group_no=project.p_group_no");
  2580. echo "Student Name :<br>";
  2581. while($row = mysql_fetch_array($q))
  2582. {
  2583. echo $row['s_name'];
  2584. }
  2585. mysql_close();
  2586. ?>
  2587.  
  2588.  
  2589. Slip no 21
  2590. Q1 :
  2591. import java.sql.*;
  2592. class slip21
  2593. {
  2594. public static void main(String args[])
  2595. { Connection con;
  2596. try
  2597. {
  2598. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  2599. con=DriverManager.getConnection("jdbc:odbc:dsn");
  2600.  
  2601. System.out.println("Connection Established...");
  2602.  
  2603. Statement stmt=con.createStatement();
  2604. ResultSet rs=stmt.executeQuery("select * from employee where name like 'S%'");
  2605. System.out.println("eno\t"+"ename\t"+"department\t"+"sal");
  2606. while(rs.next())
  2607. {
  2608. System.out.println("\n"+rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getString(3)+"\t"+rs.getInt(4));
  2609. }
  2610. }
  2611. catch(Exception e)
  2612. {
  2613.  
  2614.  
  2615. }
  2616. }
  2617. }
  2618. Q2 :
  2619. set2bn :
  2620.  
  2621. import java.io.*;
  2622. import javax.servlet.*;
  2623. import javax.servlet.http.*;
  2624.  
  2625.  
  2626. public class setb2n extends HttpServlet
  2627. {
  2628.  
  2629. public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
  2630. {
  2631.  
  2632. PrintWriter out = null;
  2633. try
  2634. {
  2635. out=res.getWriter();
  2636. Cookie c[]=req.getCookies();
  2637. for(int i=0;i<c.length;i++)
  2638. {
  2639. String s1=c[i].getName();
  2640. out.println("selected hobby are :"+s1);
  2641. }
  2642. }
  2643. catch(Exception e)
  2644. {
  2645. e.printStackTrace();
  2646. }
  2647. }
  2648. }
  2649. Setb21 :
  2650.  
  2651. import java.io.*;
  2652. import javax.servlet.*;
  2653. import javax.servlet.http.*;
  2654.  
  2655.  
  2656. public class Setb21 extends HttpServlet {
  2657.  
  2658.  
  2659. public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
  2660. {
  2661.  
  2662. PrintWriter out = null;
  2663. try
  2664. {
  2665. out=res.getWriter();
  2666. String hb=req.getParameter("ch");
  2667. Cookie c1=new Cookie("hobby",hb);
  2668. out.println("hobby are:"+hb);
  2669. //res.addCookie(c1);
  2670. }
  2671. catch(Exception e)
  2672. {
  2673. e.printStackTrace();
  2674.  
  2675. }
  2676. }
  2677. }
  2678. Html :
  2679. <html>
  2680. <body>
  2681. <form method="GET" action="http://localhost:8080/choice">
  2682. select your hobbie:<br>
  2683. <input type="radio" name="ch" value="painting">PAINTING<br>
  2684. <input type="radio" name="ch" value="drawing">DRAWING<br>
  2685. <input type="radio" name="ch" value="swiming">SWIMING<br>
  2686. <input type="radio" name="ch" value="singing">SINGING<br>
  2687. <br><input type="submit" value="select">
  2688. <br><input type="reset">
  2689. </form>
  2690. </body>
  2691. </html>
  2692. Q3 :
  2693.  
  2694.  
  2695.  
  2696. Php file :
  2697. <html> <body>
  2698. <FORM ACTION="<?php $_SERVER['PHP_SELF']; ?>" method="POST">
  2699. Enter first no :<input type=text name=no1 ><br>
  2700. Enter second no :<input type=text name=no2><br>
  2701. Select Operation which u have to perform :
  2702. <select name=cal>
  2703. <option value="1">Addition</option>
  2704. <option value="2">Substraction</option>
  2705. <option value="3">Multiplication</option>
  2706. <option value="4">Division</option>
  2707. </select><br>
  2708. <input type=submit name=submit value=Calculate>
  2709. </form>
  2710. </body>
  2711. </html>
  2712.  
  2713. <?php
  2714. if(isset($_POST['submit']))
  2715. {
  2716. $no1=$_POST['no1'];
  2717. $no2=$_POST['no2'];
  2718. $cal=$_POST['cal'];
  2719. if((!empty($no1)) && (!empty($no2)))
  2720. {
  2721. switch($cal)
  2722. {
  2723. case 1:
  2724. $add=$no1+$no2;
  2725. echo "addition=".$add;
  2726. break;
  2727. case 2:
  2728. $sub=$no1-$no2;
  2729. echo "subtraction=".$sub;
  2730. break;
  2731. case 3:
  2732. $mult=$no1*$no2;
  2733. echo "multiplication=".$mult;
  2734. break;
  2735. case 4:
  2736. $div=$no1/$no2;
  2737. echo "division=".$div;
  2738. break;
  2739. }
  2740. }
  2741. else echo "Please enter both 2 nos";
  2742. }
  2743. else
  2744. die("not able to acccess");
  2745. ?>
  2746. Q4 :
  2747. Html file :
  2748.  
  2749. <html>
  2750. <body> <form action="slip_21.php" method="get">
  2751. Enter the Name Of Hospital : <input type=text name=hosp><br>
  2752. <input type=submit value=SUBMIT>
  2753. </form>
  2754. </body>
  2755. <html>
  2756. Php file :
  2757. <?php
  2758. $hosp=$_GET['hosp'];
  2759. $con=mysql_connect("localhost","root","");
  2760. $d=mysql_select_db("bca_programs",$con);
  2761. $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");
  2762. echo "<tr><td>Doctor no--</td><td>Doctor Name--</td><td>Address-</td><td>city--</td><td>Area</td></tr>";
  2763. while($row=mysql_fetch_array($q))
  2764. {
  2765. echo "<br><tr><td>".$row[0]." | </td><td>".$row[1]." | </td><td>".$row[2]." | </td><td>".$row[3]." |</td><td>".$row[4]." |</td></tr>";
  2766. }
  2767. mysql_close();
  2768.  
  2769. ?>
  2770.  
  2771. Slip no 22
  2772. Q1 :
  2773. //server.java :
  2774. import java.net.*;
  2775. import java.io.*;
  2776. public class server
  2777. {
  2778. public static void main(String args[])
  2779. {
  2780. try
  2781. {
  2782. ServerSocket ss =new ServerSocket(2222);
  2783. System.out.println("Server is started");
  2784. while(true)
  2785. {
  2786. Socket s=ss.accept();
  2787. System.out.print("Connection request Received");
  2788. InputStream is=s.getInputStream();
  2789. InputStreamReader isr= new InputStreamReader(is);
  2790. BufferedReader br=new BufferedReader(isr);
  2791. OutputStream os=s.getOutputStream();
  2792. PrintWriter pw= new PrintWriter(os,true);
  2793. String no= br.readLine();
  2794. //System.out.print("no:"+ " " + (char)no);
  2795. int no1=Integer.parseInt(no);
  2796. int fact=1,i=0;
  2797. while(no1>i)
  2798. {
  2799. fact=fact*no1;
  2800. no1--;
  2801. //System.out.println("fact="+fact+"no="+no1);
  2802. }
  2803. pw.println(fact);
  2804. s.close();
  2805. }
  2806. }
  2807. catch(Exception e)
  2808. {
  2809. e.printStackTrace();
  2810. }
  2811. }
  2812. }
  2813. //client.java :
  2814. import java.net.*;
  2815. import java.io.*;
  2816. public class client
  2817. {
  2818. public static void main(String args[])
  2819. {
  2820. try
  2821. {
  2822. Socket s = new Socket("localhost",2222);
  2823. InputStream is=s.getInputStream();
  2824. InputStreamReader isr= new InputStreamReader(is);
  2825. BufferedReader br=new BufferedReader(isr);
  2826. OutputStream os=s.getOutputStream();
  2827. PrintWriter pw= new PrintWriter(os,true);
  2828. String msg="5";
  2829. pw.println(msg);
  2830. msg=br.readLine();
  2831. int gh=Integer.parseInt(msg) ;
  2832. System.out.println("factorial="+gh);
  2833. s.close();
  2834. }
  2835. catch (Exception e)
  2836. {
  2837. e.printStackTrace();
  2838. }
  2839. }
  2840. }
  2841. Q2 :
  2842. import java.sql.*;
  2843. import java.io.*;
  2844. import javax.sql.*;
  2845.  
  2846. class slip6
  2847. {
  2848. public static void main(String args[])
  2849. {
  2850. Connection con;
  2851. Statement state;
  2852. ResultSet rs;
  2853. int ch;
  2854.  
  2855. boolean flag=true;
  2856. String decision;
  2857. int no;
  2858.  
  2859.  
  2860. try
  2861. {
  2862. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  2863. con = DriverManager.getConnection("jdbc:odbc:lab.dsn");
  2864.  
  2865. System.out.println("Statement object created");
  2866.  
  2867. do
  2868. {
  2869. System.out.println("\n");
  2870. System.out.println("Menu:");
  2871. System.out.println("1.create Table");
  2872. System.out.println("2.Insert Record into the Table");
  2873. System.out.println("3.Display all the Records from the Table");
  2874. System.out.println("4.Exit");
  2875. System.out.println("Enter your choice: ");
  2876.  
  2877. BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  2878. ch=Integer.parseInt(br.readLine());
  2879.  
  2880. switch(ch)
  2881. {
  2882. case 1:
  2883. state=con.createStatement();
  2884. String query="create table student"+"(rno int ,"+" sname varchar(20),"+" per int,"+" address varchar(20))";
  2885. state.executeUpdate(query);
  2886. System.out.println("Table created");
  2887.  
  2888.  
  2889. case 2:
  2890. System.out.println("Enter student Number: ");
  2891. int rno=Integer.parseInt(br.readLine());
  2892.  
  2893. System.out.println("Enter student Name: ");
  2894. String sname=br.readLine();
  2895.  
  2896. System.out.println("Enter per: ");
  2897. int per=Integer.parseInt(br.readLine());
  2898.  
  2899. System.out.println("Enter address: ");
  2900. String address=br.readLine();
  2901.  
  2902. String sql="insert into student values(?,?,?,?)";
  2903. PreparedStatement p=con.prepareStatement(sql);
  2904. p.setInt(1,rno);
  2905. p.setString(2,sname);
  2906. p.setInt(3,per);
  2907. p.setString(4,address);
  2908.  
  2909. p.executeUpdate();
  2910. System.out.println("Record Added");
  2911.  
  2912. break;
  2913.  
  2914.  
  2915. case 3:
  2916. state=con.createStatement();
  2917. sql="select * from student";
  2918. rs=state.executeQuery(sql);
  2919. while(rs.next())
  2920. {
  2921. System.out.println("\n");
  2922. System.out.print("\t" +rs.getInt(1));
  2923. System.out.print("\t" +rs.getString(2));
  2924. System.out.print("\t" +rs.getInt(3));
  2925. System.out.print("\t" +rs.getString(4));
  2926. }
  2927. break;
  2928.  
  2929. case 4:
  2930. System.exit(0);
  2931.  
  2932. default:
  2933. System.out.println("Invalid Choice");
  2934. break;
  2935. }
  2936. }while(ch!=4);
  2937. }catch(Exception e)
  2938. {
  2939. System.out.println(e);
  2940. }
  2941. }
  2942. }
  2943. Q3 :
  2944. Html file :
  2945.  
  2946. <html> <head> <title> Number of times the web page has been viited.</title> </head>
  2947.  
  2948. <body>
  2949. <?php
  2950. session_start();
  2951. if(isset($_SESSION['count']))
  2952. $_SESSION['count']=$_SESSION['count']+1;
  2953. else
  2954. $_SESSION['count']=1;
  2955. echo "<h3>This page is accessed</h3>".$_SESSION['count'];
  2956. ?>
  2957. Q4 :
  2958.  
  2959.  
  2960. html file :
  2961.  
  2962. <html> <body> <form action="slip_22.php" method="get">
  2963.  
  2964. <h3>Enter Actor Name : <input type=text name=nm> </h3>
  2965. <input type=radio name=a value=1>Display Movie Name<br><br>
  2966.  
  2967. <h3>Enter movie no :<input type=text name=m_no> </h3>
  2968. <h3>Enter movie name :<input type=text name=m_nm></h3>
  2969. <h3>Enter release year :<input type=text name=r_yr> </h3>
  2970. <h3>Enter actor no :<input type=text name=a_no> </h3>
  2971. <h3>Enter actor name :<input type=text name=a_nm> </h3>
  2972. <input type=radio name=a value=2>Insert New movie info<br><br>
  2973. <input type=submit value=OK> </form>
  2974. <div id="place">
  2975. </div>
  2976. </body>
  2977. </html>
  2978.  
  2979. php file :
  2980.  
  2981. <?php
  2982. $r = $_GET['a'];
  2983. $con = mysql_connect("localhost","root","");
  2984. $d = mysql_select_db("bca_programs",$con);
  2985. if($r == 1)
  2986. {
  2987. $actor_name = $_GET['nm'];
  2988. $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'");
  2989. echo "<br>Movie Name </br>";
  2990. while($row=mysql_fetch_array($q))
  2991. {
  2992. echo $row[0]."<br>";
  2993. }
  2994. }
  2995. else if($r == 2)
  2996. {
  2997. $m_no = $_GET['m_no'];
  2998. $m_name = $_GET['m_nm'];
  2999. $r_yr = $_GET['r_yr'];
  3000. $a_no = $_GET['a_no'];
  3001. $a_name = $_GET['a_nm'];
  3002. $q = mysql_query("insert into movie values($m_no,'$m_name',$r_yr)");
  3003. $q1 = mysql_query("insert into actor values($a_no,'$a_name')");
  3004. echo "Value Inserted";
  3005. }
  3006. mysql_close();
  3007. ?>
  3008. Slip no 23
  3009. Q1 :
  3010. <html>
  3011. <head>
  3012.  
  3013. <body>
  3014. <h1>Enter Information</h1>
  3015. <form action="slip23_1.jsp" method="post">
  3016. Roll No : <input type="text" name="rno"><br><br>
  3017.  
  3018. Name : <input type="text" name="name"><br><br>
  3019.  
  3020. Gender : <input type="radio" name="gender" value="Male" checked>Male
  3021. <input type="radio" name="gender" value="Female">Female
  3022. <br><br>
  3023.  
  3024. Comp_Know : <input type="radio" name="know" value="Yes" checked>Yes
  3025. <input type="radio" name="know" value="No">No
  3026. <br><br>
  3027.  
  3028. Class : <select name="Class">
  3029. <option value="11">11Th</option>
  3030. <option value="12">12Th</option>
  3031. <option value="FY">FY</option>
  3032. <option value="SY">SY</option>
  3033. <option value="TY">TY</option>
  3034. </select>
  3035. <br><br>
  3036.  
  3037. <input type="submit" value="Submit">
  3038. </form>
  3039. </body>
  3040. </html>
  3041. Slip23_1.jsp :
  3042. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  3043.  
  3044. <%
  3045.  
  3046. int rno = Integer.parseInt(request.getParameter("rno"));
  3047.  
  3048. String s_name = request.getParameter("name");
  3049.  
  3050. String s_gender = request.getParameter("gender");
  3051.  
  3052. String s_know = request.getParameter("know");
  3053.  
  3054. String s_class = request.getParameter("Class");
  3055.  
  3056. out.println("\nRoll No :"+rno);
  3057. out.println("\nName :"+s_name);
  3058. out.println("\nGender :"+s_gender);
  3059. out.println("\nComp_Know :"+s_know);
  3060. out.println("\nClass :"+s_class);
  3061. %>
  3062. Q2 :
  3063. import java.sql.*;
  3064. import java.io.*;
  3065. import javax.sql.*;
  3066.  
  3067. class Elements{
  3068. public static void main(String args[]){
  3069. try{
  3070. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  3071. con=DriverManager.getConnection("jdbc:odbc:lab.dsn");
  3072.  
  3073. Statement s=null;
  3074. PreparedStatement ps=null;
  3075. ResultSet rs=null;
  3076.  
  3077. char ch = args[0].charAt(0);
  3078.  
  3079. String name="",symbol="";
  3080. int weight=0;
  3081.  
  3082. switch(ch)
  3083. {
  3084. case 'R':
  3085. s = con.createStatement();
  3086. rs = s.executeQuery("select * from elements");
  3087. while(rs.next()){
  3088. System.out.println(rs.getInt(1)+"\t"+
  3089. rs.getString(2)+"\t"+
  3090. rs.getString(3));
  3091. }
  3092. break;
  3093. case 'D':
  3094. name = args[1];
  3095. ps = con.prepareStatement("delete from elements where name=?");
  3096. ps.setString(1,name);
  3097. if(ps.executeUpdate()==1)
  3098. System.out.println("Element "+name+" deleted successfully.");
  3099. else
  3100. System.out.println("Element "+name+" not found.");
  3101. break;
  3102. case 'U':
  3103. weight = Integer.parseInt(args[1]);
  3104. name = args[2];
  3105. symbol = args[3];
  3106.  
  3107. ps = con.prepareStatement("update elements set atomic_weight=?,chemical_symbol=? where name=?");
  3108.  
  3109. ps.setInt(1,weight);
  3110. ps.setString(2,symbol);
  3111. ps.setString(3,name);
  3112.  
  3113. if(ps.executeUpdate()==1)
  3114. System.out.println("Element "+name+" updated successfully.");
  3115. else
  3116. System.out.println("Element "+name+" not found.");
  3117. }
  3118.  
  3119. con.close();
  3120. }
  3121. catch(Exception e){
  3122. System.out.println(e);
  3123. }
  3124. }
  3125. }
  3126. Q3 :
  3127. Book.xml :
  3128.  
  3129. <?xml version="1.0"?>
  3130. <BookStore>
  3131. <Books>
  3132. <PHP>
  3133. <title>Programming PHP</title>
  3134. <publication>O’RELLY</publication>
  3135. </PHP>
  3136. <PHP>
  3137. <title>Beginners PHP</title>
  3138. <publication>WROX</publication>
  3139. </PHP>
  3140. </Books>
  3141. </BookStore>
  3142.  
  3143. Book.php :
  3144.  
  3145. <html>
  3146. <body>
  3147. <?php $xml=simplexml_lode_file('book.xml')or die("Cannot Die!!!");
  3148. ?>
  3149. <center><b>...BOOK DETAILS...</B><center>
  3150. <table border='2'> <th>Book title</th>
  3151. <th>Publication</th>
  3152. <?php
  3153. foreach($xml->book as $a)
  3154. {
  3155. echo"<tr><td>".$a['Book title']."</td>"; echo"<tr><td>".$a['Publication']."</td></tr>"; }
  3156. ?>
  3157. </table>
  3158. </body> </html>
  3159. Q4 :
  3160.  
  3161. Html file :
  3162.  
  3163. <html>
  3164. <body>
  3165. <form action="slip_23.php" method="get"> <center>
  3166. <h3>Enter the Bill Number : <input type=text name=bno><br></h3>
  3167. <input type=submit value=SUBMIT></center>
  3168. </form> </body> <html>
  3169.  
  3170. Php file :
  3171. <?php
  3172. $bno = $_GET['bno'];
  3173. $con = mysql_connect("localhost","root","");
  3174. $d = mysql_select_db("bca_programs",$con);
  3175. $q = mysql_query("select * from bill_master where bill_no=$bno");
  3176. echo "<center>";
  3177. while($row = mysql_fetch_array($q))
  3178. {
  3179. echo " <h3><br>Bill No : ".$row[0]."Bill Date : ".$row[2]."</h3>";
  3180. echo "<h3>Customer Name : ".$row[1]."</h3>";
  3181. }
  3182. $i=1;
  3183. $gt=0;
  3184. $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");
  3185. echo "<table border=1 width=30% height=10%>";
  3186. 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))
  3187. {
  3188. $t=$row1[1]*$row1[2];
  3189. echo "<br><tr><td>".$i++."</td><td>".$row1[0]."</td><td>".$row1[1]."</td><td>".$r ow1[2]."</td><td>".$t."</td><tr>";
  3190. $gt+=$t;
  3191. }
  3192. echo "</table>";
  3193. echo "<br><b> Gross Ammount is :: ".$gt."</b>";
  3194. echo "<center>";
  3195. mysql_close();
  3196. ?>
  3197.  
  3198. Slip no 24
  3199. Q1 :
  3200. <html>
  3201. <body>
  3202. <form name=f1 action="EmailCheck.jsp">
  3203. <fieldset>
  3204. <legend>Enter Email Id...!!!</legend>
  3205. Enter Email Id:<input type="text" name="t1" >
  3206. </fieldset>
  3207. <div align=center>
  3208. <input type="submit" name="Submit" value="Submit">
  3209. </div>
  3210. </form>
  3211. </body>
  3212. </html>
  3213. Emailcheck.jsp :
  3214. <html>
  3215. <body>
  3216. <%@ page language="java" %>
  3217. <%
  3218. String email=request.getParameter("t1");
  3219. if(email.contains("@") && email.contains("."))
  3220. {
  3221. out.println("Given Email Id is Valid");
  3222. }
  3223. else {
  3224. out.println("Given Email id is not Valid");
  3225. }
  3226. %>
  3227. </body>
  3228. </html>
  3229. Q2 :
  3230. import java.sql.*;
  3231. import java.awt.*;
  3232. import java.awt.event.*;
  3233. import javax.swing.*;
  3234.  
  3235. class College extends JFrame{
  3236. private JLabel lblID,lblName,lblAddr,lblYear;
  3237. private JTextField txtID,txtName,txtAddr,txtYear;
  3238. private JButton btnSave,btnClose;
  3239. private JPanel panCenter,panSouth;
  3240.  
  3241. private Connection con;
  3242. private PreparedStatement ps;
  3243.  
  3244. public College(){
  3245. lblID = new JLabel("College ID:");
  3246. lblName = new JLabel("College Name:");
  3247. lblAddr = new JLabel("Address:");
  3248. lblYear = new JLabel("Year:");
  3249.  
  3250. txtID = new JTextField();
  3251. txtName = new JTextField();
  3252. txtAddr = new JTextField();
  3253. txtYear = new JTextField();
  3254.  
  3255. panCenter = new JPanel();
  3256. panCenter.setLayout(new GridLayout(4,2));
  3257. panCenter.add(lblID);
  3258. panCenter.add(txtID);
  3259. panCenter.add(lblName);
  3260. panCenter.add(txtName);
  3261. panCenter.add(lblAddr);
  3262. panCenter.add(txtAddr);
  3263. panCenter.add(lblYear);
  3264. panCenter.add(txtYear);
  3265.  
  3266. btnSave = new JButton("Save");
  3267. btnClose = new JButton("Close");
  3268.  
  3269. panSouth = new JPanel();
  3270. panSouth.add(btnSave);
  3271. panSouth.add(btnClose);
  3272.  
  3273. setTitle("College Information");
  3274. setSize(400,200);
  3275. setLocation(100,100);
  3276. add(panCenter,"Center");
  3277. add(panSouth,"South");
  3278. setVisible(true);
  3279. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  3280.  
  3281. try{
  3282. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  3283. con=DriverManager.getConnection("jdbc:odbc:lab.dsn");
  3284. }
  3285. catch(Exception e){
  3286. JOptionPane.showMessageDialog(null,e);
  3287. dispose();
  3288. }
  3289.  
  3290. btnSave.addActionListener(new ActionListener(){
  3291. public void actionPerformed(ActionEvent ae){
  3292. try{
  3293. int cid = Integer.parseInt(txtID.getText());
  3294. String cname = txtName.getText();
  3295. String addr = txtAddr.getText();
  3296. int yr = Integer.parseInt(txtYear.getText());
  3297.  
  3298. ps = con.prepareStatement("insert into college values(?,?,?,?)");
  3299.  
  3300. ps.setInt(1,cid);
  3301. ps.setString(2,cname);
  3302. ps.setString(3,addr);
  3303. ps.setInt(4,yr);
  3304.  
  3305. ps.executeUpdate();
  3306.  
  3307. txtID.setText("");
  3308. txtName.setText("");
  3309. txtAddr.setText("");
  3310. txtYear.setText("");
  3311.  
  3312. txtID.requestFocus();
  3313. }
  3314. catch(Exception e){
  3315. JOptionPane.showMessageDialog(null,e);
  3316. }
  3317. }
  3318. });
  3319.  
  3320. btnClose.addActionListener(new ActionListener(){
  3321. public void actionPerformed(ActionEvent ae){
  3322. dispose();
  3323. }
  3324. });
  3325. }
  3326. Q3 :
  3327.  
  3328. ADDITION.html :
  3329.  
  3330. <html>
  3331. <script language="javascript">
  3332. var req=false;
  3333. if(window.XMLHttpRequest)
  3334. {
  3335. req=new XMLHttpRequest();
  3336. }
  3337. else if(window.ActiveXObject)
  3338. {
  3339. req=new ActiveXObject("Microsoft.XMLHttp");
  3340. }
  3341. function add(url,divID) {
  3342. if(req)
  3343. {
  3344. req.open("POST",url);
  3345. req.onreadystatechange=function()
  3346. {
  3347. if(req.readyState==4 && req.status==200)
  3348. {
  3349. document.getElementById(divID).innerHTML=req.responseText;
  3350. }
  3351. }
  3352. req.send();
  3353. }
  3354. }
  3355. function ad(divID)
  3356. {
  3357. var t1=ducument.f1.t1value;
  3358. var t2=document.f1.t1.value;
  3359. var url="Addx.php?t1="+t1+"&t2="+t2;
  3360. add(url,divID);
  3361. }
  3362. </script>
  3363. <body>
  3364. <form name=f1> No. 1 :<input type=text name=t1><br><br>
  3365. No. 2 :<input type=text name=t2><br><br>
  3366. <input type=button value=add onClick="ad('mydiv')"> </form>
  3367. <div id="mydiv"> </div>
  3368. </body>
  3369. </html>
  3370.  
  3371.  
  3372.  
  3373. Q4 :
  3374.  
  3375. BOOK.XML :
  3376.  
  3377. <?xml version="1.0"?>
  3378. <BookStore>
  3379. <Books>
  3380. <PHP>
  3381. <title>Programming PHP</title>
  3382. <publication>O’RELLY</publication>
  3383. </PHP>
  3384. <PHP>
  3385. <title>Beginners PHP</title>
  3386. <publication>WROX</publication>
  3387. </PHP>
  3388. </Books>
  3389. </BookStore>
  3390.  
  3391.  
  3392. BOOK.PHP :
  3393.  
  3394. <?php
  3395. $xml=simplexml_load_sreing($myXMLData) or die(“Error : Create object”);
  3396. print_r($xml);
  3397. ?>
  3398. Slip no 25
  3399. Q1 :
  3400. <%@page language="java"%>
  3401. <html>
  3402. <body>
  3403. <%!int cnt=0;
  3404. String uname,nname;%>
  3405. <%
  3406. uname=request.getParameter("a");
  3407. nname=request.getParameter("b");
  3408. cnt++;
  3409. if(cnt%2==0)
  3410. out.println("HEllo"+nname+"..visit count"+cnt);
  3411. else
  3412. out.println("HEllo"+uname+"..visit count"+cnt);
  3413. %>
  3414. <a href="slip25-1.jsp">Visit</a>
  3415. </body>
  3416. </html>
  3417. Slip25-1.jsp :
  3418. <HTML>
  3419. <HEAD>
  3420. <TITLE> 4.JSP SET B:1 </TITLE>
  3421. </HEAD>
  3422. <BODY>
  3423. <form action="http://localhost:8080/ty/slip25.jsp" method="POST">
  3424. Enter the user name:
  3425. <input type="text" name="a">
  3426. <br><br>
  3427. Enter the nick name:
  3428. <input type="text" name="b">
  3429. <br><br>
  3430. <input type="Submit" value="Submit"/>
  3431. </form>
  3432. </BODY>
  3433. </HTML>
  3434. Q2 :
  3435. import java.io.*;
  3436.  
  3437. import java.sql.*;
  3438.  
  3439. public class slip6
  3440. {
  3441. public static void main(String args[])
  3442. {
  3443. try
  3444. {
  3445. BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  3446. Connection con=null;
  3447. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  3448. con = DriverManager.getConnection("jdbc:odbc:lab");
  3449.  
  3450. Statement sta=con.createStatement();
  3451.  
  3452.  
  3453. sta=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
  3454. ResultSet rs=sta.executeQuery("select * from employee");
  3455.  
  3456. for(;;)
  3457. {
  3458. System.out.println("---------MAIN MENU---------");
  3459. System.out.println("1:Next");
  3460. System.out.println("2:First");
  3461. System.out.println("3:Previous");
  3462. System.out.println("4:Last");
  3463. System.out.println("5:Exit");
  3464. System.out.println("ENTER your choice :");
  3465. int choice=Integer.parseInt(br.readLine());
  3466.  
  3467. switch(choice)
  3468. {
  3469. case 1:
  3470. System.out.println("Display next record");
  3471. rs.next();
  3472. System.out.println(" eNo:"+rs.getInt(1));
  3473. System.out.println("eName:"+rs.getString(2));
  3474. System.out.println("sal:"+rs.getFloat(3));
  3475. break;
  3476. case 2:
  3477. System.out.println("Display first record");
  3478. rs.first();
  3479. System.out.println("eNo:"+rs.getInt(1));
  3480. System.out.println("eName:"+rs.getString(2));
  3481. System.out.println("sal:"+rs.getFloat(3));
  3482. break;
  3483. case 3:
  3484. System.out.println("Display previous record");
  3485. rs.previous();
  3486. System.out.println("eNo:"+rs.getInt(1));
  3487. System.out.println("eName:"+rs.getString(2));
  3488. System.out.println("sal:"+rs.getFloat(3));
  3489. break;
  3490. case 4:
  3491. System.out.println("Display last record");
  3492. rs.last();
  3493. System.out.println("eNo:"+rs.getInt(1));
  3494. System.out.println("eName:"+rs.getString(2));
  3495. System.out.println("sal:"+rs.getFloat(3));
  3496. break;
  3497. case 5:
  3498. System.exit(0);
  3499. break;
  3500. }
  3501. }
  3502. }
  3503. catch(Exception e)
  3504. {
  3505. System.out.println(e);
  3506. }
  3507. }
  3508. }
  3509. Q3 :
  3510. Introspection.php :
  3511.  
  3512. <?php
  3513. class Myclass
  3514. {
  3515. public $a;
  3516. public $b=10;
  3517. public $c='ABC';
  3518. function Myclass()
  3519. {
  3520. //Myclass function
  3521. }
  3522. function myfun1()
  3523. {
  3524. //functin
  3525. }
  3526. function myfun2()
  3527. {
  3528. //functin
  3529. }
  3530. }
  3531. $class=get_declared_classes();
  3532. foreach($class as $cname)
  3533. {
  3534. echo"$cname <br>";
  3535. }
  3536. echo"<br>Class Methods are : <br>";
  3537. $m=get_class_methods('Myclass');
  3538. foreach($m as $mname)
  3539. {
  3540. echo"$mname <br>";
  3541. }
  3542. $cp=get_class_vars('Myclass');
  3543. echo"class variables are :<br>";
  3544. foreach($cp as $cpname => $v)
  3545. {
  3546. echo"$cpname : $v <br>";
  3547. }
  3548. ?>
  3549.  
  3550.  
  3551. Q4 :
  3552.  
  3553.  
  3554. BOOK.XML :
  3555.  
  3556. <?xml version=”1.0” encoding=”utf-8”?>
  3557. <ABCBOOLK>
  3558. <Technical>
  3559. <Book>
  3560. <Book_PubYear>ABC</Book_PubYear>
  3561. <Book_Title>nvdklv </Book_Title>
  3562. <Book_Author>400</Book_Author>
  3563. </Book>
  3564. </Technical>
  3565. <Cooking>
  3566. <Book>
  3567. <Book_PubYear>ABC</Book_PubYear>
  3568. <Book_Title>nvdklv </Book_Title>
  3569. <Book_Author>400</Book_Author>
  3570. </Book>
  3571. </Cooking>
  3572. <Yoga>
  3573. <Book>
  3574. <Book_PubYear>ABC</Book_PubYear>
  3575. <Book_Title>nvdklv </Book_Title>
  3576. <Book_Author>400</Book_Author>
  3577. </Book>
  3578. </Yoga>
  3579. </ABCBOOLK>
  3580.  
  3581.  
  3582. BOOK.php :
  3583. <?php
  3584.  
  3585. $xml=simplexml_load_file("Book.xml") or die("cannnot load");
  3586. $xmlstring=$xml->asXML();
  3587. echo $xmlstring;
  3588.  
  3589. ?>
  3590. Slip no 26
  3591. Q1 :
  3592. import java.io.*;
  3593. import java.util.*;
  3594. class slip26 implements Runnable
  3595. {
  3596. Thread t;
  3597. public slip26()
  3598. {
  3599. t=new Thread(this);
  3600. t.start();
  3601.  
  3602. }
  3603. public void run()
  3604. {
  3605. char ch;
  3606. for (ch='a';ch<='z';ch++)
  3607. {
  3608. System.out.println(ch);
  3609. try
  3610. {
  3611. Thread.sleep(300);
  3612. }
  3613. catch(Exception e)
  3614. {
  3615. }
  3616. }
  3617. }
  3618. public static void main(String args[])
  3619. {
  3620.  
  3621. slip26 s=new slip26();
  3622.  
  3623. }
  3624. }
  3625. Q2 :
  3626. import java.awt.*;
  3627. import java.awt.event.*;
  3628. import javax.swing.*;
  3629. import javax.swing.table.*;
  3630. import java.sql.*;
  3631. import java.util.*;
  3632. import java.text.*;
  3633.  
  3634. class SalesReport extends JFrame{
  3635. private JLabel lblStart,lblEnd;
  3636. private JComboBox cmbStart,cmbEnd;
  3637. private JPanel panNorth;
  3638. private JButton btnShow;
  3639. private JTable tabReport;
  3640. private DefaultTableModel dtm;
  3641.  
  3642. public SalesReport(){
  3643. lblStart = new JLabel("Start Date:");
  3644. lblEnd = new JLabel("End Date:");
  3645.  
  3646. cmbStart = new JComboBox();
  3647. cmbEnd = new JComboBox();
  3648.  
  3649. Calendar calendar = new GregorianCalendar();
  3650. java.util.Date d = new java.util.Date();
  3651. System.out.println(d.getDate());
  3652. calendar.set(Calendar.YEAR, d.getYear()+1900);
  3653. calendar.set(Calendar.MONTH, d.getMonth());
  3654. calendar.set(Calendar.DAY_OF_MONTH, d.getDate());
  3655.  
  3656. for(int i=1000;i>=1;i--){
  3657. String str = calendar.get(Calendar.YEAR)+"-"+
  3658. (calendar.get(Calendar.MONTH)+1)+"-"+
  3659. calendar.get(Calendar.DAY_OF_MONTH);
  3660. cmbStart.addItem(str);
  3661. cmbEnd.addItem(str);
  3662. calendar.add(Calendar.DAY_OF_MONTH, -1);
  3663. }
  3664.  
  3665. btnShow = new JButton("Show");
  3666.  
  3667. panNorth = new JPanel(new GridLayout(1,4));
  3668. panNorth.add(lblStart);
  3669. panNorth.add(cmbStart);
  3670. panNorth.add(lblEnd);
  3671. panNorth.add(cmbEnd);
  3672. panNorth.add(btnShow);
  3673.  
  3674. dtm = new DefaultTableModel();
  3675. dtm.addColumn("PID");
  3676. dtm.addColumn("PName");
  3677. dtm.addColumn("Amount");
  3678. dtm.addColumn("Date");
  3679.  
  3680. tabReport = new JTable(dtm);
  3681.  
  3682. setTitle("Sales Report");
  3683. setSize(400,400);
  3684. add(panNorth,"North");
  3685. add(new JScrollPane(tabReport),"Center");
  3686. setVisible(true);
  3687. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  3688.  
  3689. btnShow.addActionListener(new ActionListener(){
  3690. public void actionPerformed(ActionEvent ae){
  3691. try{
  3692. for(int i=0;i<dtm.getRowCount();i++)
  3693. dtm.removeRow(0);
  3694.  
  3695. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  3696. con=DriverManager.getConnection("jdbc:odbc:lab.dsn");
  3697.  
  3698. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
  3699. String sdate = cmbStart.getSelectedItem().toString();
  3700. String edate = cmbEnd.getSelectedItem().toString();
  3701.  
  3702. java.util.Date d = sdf.parse(sdate);
  3703. java.sql.Date newsdate = new java.sql.Date(d.getTime());
  3704.  
  3705. d = sdf.parse(edate);
  3706. java.sql.Date newedate = new java.sql.Date(d.getTime());
  3707.  
  3708. PreparedStatement ps = con.prepareStatement("select * from prod_sales where sale_date between ? and ?");
  3709. ps.setDate(1,newsdate);
  3710. ps.setDate(2,newedate);
  3711.  
  3712. ResultSet rs = ps.executeQuery();
  3713. while(rs.next()){
  3714. Vector v = new Vector();
  3715. v.add(rs.getString(1));
  3716. v.add(rs.getString(2));
  3717. v.add(rs.getString(3));
  3718. v.add(rs.getString(4));
  3719. dtm.addRow(v);
  3720. }
  3721. }
  3722. catch(Exception e){
  3723. JOptionPane.showMessageDialog(null,e);
  3724. }
  3725. }
  3726. });
  3727. }
  3728.  
  3729. public static void main(String args[]){
  3730. new SalesReport();
  3731. }
  3732. }
  3733. Q3 :
  3734.  
  3735. html file :
  3736.  
  3737. <html>
  3738.  
  3739. <body>
  3740.  
  3741. <form action=Que26.php method=GET>
  3742.  
  3743. enter student roll no :<input type=text name=rno><br>
  3744.  
  3745. enter student name : <input type=text name=s_name><br>
  3746.  
  3747. enter class : <input type=text name=cls><br>
  3748.  
  3749. <input type=submit name=submit value=submit >
  3750.  
  3751. </form>
  3752.  
  3753. </body>
  3754.  
  3755.  
  3756. </html>
  3757.  
  3758. Php file :
  3759.  
  3760. <?php
  3761.  
  3762. <?php
  3763.  
  3764. $rno=$_GET['rno'];
  3765.  
  3766. $s_name=$_GET['s_name'];
  3767.  
  3768. $cls=$_GET['cls'];
  3769.  
  3770.  
  3771.  
  3772. $con=mysql_connect("localhost","root","");
  3773.  
  3774. $d=mysql_select_db("bca_programs",$con);
  3775.  
  3776. $q=mysql_query("insert into stud values($rno,'$s_name','$cls')");
  3777.  
  3778.  
  3779.  
  3780. $q1=mysql_query("select * from stud order by sname");
  3781.  
  3782. echo "<table>";
  3783.  
  3784. echo "<tr><td>Roll no.</td><td>Name</td><td>Class</td></tr>";
  3785.  
  3786.  
  3787.  
  3788. while($row=mysql_fetch_array($q1))
  3789.  
  3790. { echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td></tr>";
  3791.  
  3792. }
  3793.  
  3794. echo "</table>";
  3795.  
  3796.  
  3797. mysql_close();
  3798.  
  3799. ?
  3800. Slip no 27
  3801. Q1 :
  3802. import java.io.*;
  3803. import java.sql.*;
  3804. class Deleteemp
  3805. {
  3806. static Connection cn;
  3807. static Statement st;
  3808. static ResultSet rs;
  3809. static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  3810. public static void main(String args[])
  3811.  
  3812. {
  3813. int e,k,ch,sal;
  3814. String en;
  3815. try
  3816. {
  3817.  
  3818. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  3819. cn=DriverManager.getConnection("jdbc:odbc:Emp","","");
  3820. st=cn.createStatement();
  3821.  
  3822. do
  3823. {
  3824.  
  3825. System.out.println("1. Delete ");
  3826. System.out.println("2. Exit ");
  3827. System.out.println("Enter Ur Choice");
  3828. ch=Integer.parseInt(br.readLine());
  3829. switch(ch)
  3830. {
  3831.  
  3832.  
  3833. case 1:
  3834. System.out.println("Enter the Eno");
  3835. e=Integer.parseInt(br.readLine());
  3836. String sd="delete from emp where eno=" +e;
  3837. k=st.executeUpdate(sd);
  3838. if(k>0)
  3839. {
  3840. System.out.println("Record Is Deleted");
  3841. }
  3842. break;
  3843. case 2:
  3844. System.exit(0);
  3845. }
  3846. }
  3847. while(ch!=2);
  3848. }
  3849. catch(Exception et)
  3850. {
  3851. System.out.println(et);
  3852. }
  3853. }
  3854. }
  3855. Q2 :
  3856. import java.awt.*;
  3857. import java.awt.event.*;
  3858. import java.util.*;
  3859.  
  3860. public class slip27 extends Frame implements
  3861.  
  3862. ActionListener,Runnable
  3863. {
  3864. Button start,stop;
  3865. TextField tf;
  3866. int x=0,y=0;
  3867. String msg="";
  3868.  
  3869. Thread t1=new Thread(this);
  3870. public slip27()
  3871. {
  3872. setLayout(new FlowLayout());
  3873. start=new Button("start");
  3874. stop=new Button("stop");
  3875. add(start);
  3876. add(stop);
  3877.  
  3878. start.addActionListener(this);
  3879. stop.addActionListener(this);
  3880. addWindowListener(new
  3881.  
  3882. WindowAdapter()
  3883. {
  3884. public void
  3885.  
  3886. windowClosing(WindowEvent e)
  3887. {
  3888. System.exit(0);
  3889. }
  3890. });
  3891.  
  3892. setSize(200,200);
  3893. setVisible(true);
  3894. }
  3895.  
  3896. public void actionPerformed(ActionEvent ae)
  3897. {
  3898. Button btn=(Button)ae.getSource();
  3899. if(btn==start)
  3900. {
  3901. t1.start();
  3902. }
  3903.  
  3904.  
  3905. if(btn==stop)
  3906. {
  3907. t1.stop();
  3908. }
  3909. }
  3910.  
  3911.  
  3912. public void run()
  3913. {
  3914. try
  3915. {
  3916. while(true)
  3917. {
  3918. repaint();
  3919. Thread.sleep(350);
  3920. }
  3921. }
  3922.  
  3923.  
  3924. catch(Exception e)
  3925. {
  3926. }
  3927. }
  3928.  
  3929. public void paint(Graphics g)
  3930. {
  3931.  
  3932. int sec,min,hr;
  3933. GregorianCalendar date = new GregorianCalendar();
  3934. sec = date.get(Calendar.SECOND);
  3935. min = date.get(Calendar.MINUTE);
  3936. hr = date.get(Calendar.HOUR);
  3937. msg = hr+":"+min+":"+sec;
  3938. g.drawString(msg,10,y+=10);
  3939. }
  3940.  
  3941. public static void main(String args[])
  3942. {
  3943. new slip27();
  3944. }
  3945. }
  3946. Q3 :
  3947. <html>
  3948. <body>
  3949. <script type="text/javascript">
  3950. function show_confirm()
  3951. {
  3952. var r=confirm("Press a button !");
  3953. if(r==true)
  3954. {
  3955. ver i;
  3956. var game = new Array();
  3957. game[0]="Car ";
  3958. game[1]="GTA";
  3959. game[2]="cricket";
  3960. for(i=0;i<game.length;i++)
  3961. {
  3962. document.write(game[i]+"<br/>");
  3963. }
  3964. }
  3965. else
  3966. {
  3967. alert("Cancel game cannot br displayed !");
  3968. }
  3969. }
  3970. </script>
  3971. </head>
  3972. <body>
  3973. <input type="button" onclick="show_confirm()" value="List of game"/>
  3974. </body>
  3975. </html>
  3976.  
  3977.  
  3978. Q4 :
  3979. <?xml version="1.0" encoding="utf-8"?>
  3980. <CricketTeam>
  3981. <Team country=”India”>
  3982. <player>sachin</player>
  3983. <runs>36000</runs>
  3984. <wicket>88</wicket>
  3985. </Team>
  3986. <Team country=”Australia”>
  3987. <player>watsun</player>
  3988. <runs>10000</runs>
  3989. <wicket>44</wicket>
  3990. </Team>
  3991. <Team country=”Pakisthan”>
  3992. <player>Afridhi</player>
  3993. <runs>6000</runs>
  3994. <wicket>65</wicket>
  3995. </Team>
  3996. </CricketTeam>
  3997.  
  3998. cricket.php
  3999.  
  4000. <?php
  4001. $xml=simplexml_load_file(“cricket.xml”)or die(“cannotnload”);
  4002. $xmlstring=$xml->asXML();
  4003. Echo $xmlstring;
  4004.  
  4005. ?>
  4006. Slip no 28
  4007. Q1 :
  4008. <html>
  4009. <body>
  4010. <form method=post action="armstrong.jsp">
  4011. Enter Number : <input type=text name=t1><br>
  4012. <input type=submit>
  4013. </form>
  4014. </body>
  4015. </html>
  4016. Armstrong.jsp :
  4017. <html>
  4018. <body>
  4019. <%! int n,m,sum=0,rem; %>
  4020. <% n=Integer.parseInt(request.getParameter("t1"));
  4021. m=n;
  4022. while(n>0)
  4023. {
  4024. rem=n%10;
  4025. sum=sum+(rem*rem*rem);
  4026. n=n/10;
  4027. }
  4028. if(sum==m)
  4029. out.print("the no. is armstrong "+sum);
  4030. else
  4031. out.print("the no. is not armstrong "+sum);
  4032. %>
  4033. </body>
  4034. </html>
  4035. Q2 :
  4036. import java.awt.*;
  4037.  
  4038. import java.awt.event.*;
  4039.  
  4040. import javax.swing.*;
  4041.  
  4042. import javax.swing.table.*;
  4043.  
  4044. import java.util.*;
  4045.  
  4046. import java.sql.*;
  4047.  
  4048.  
  4049. class EmpView extends JFrame{
  4050.  
  4051. private JTable tabRecord;
  4052.  
  4053. private JLabel lblEmp;
  4054.  
  4055. private JComboBox cmbEmp;
  4056.  
  4057. private JPanel panNorth;
  4058.  
  4059. private DefaultTableModel dtm;
  4060.  
  4061.  
  4062. private Connection con;
  4063.  
  4064. private PreparedStatement ps;
  4065.  
  4066. private Statement s;
  4067.  
  4068. private ResultSet rs;
  4069.  
  4070.  
  4071. public EmpView(){
  4072.  
  4073. lblEmp = new JLabel("Employee:");
  4074.  
  4075. cmbEmp = new JComboBox();
  4076.  
  4077.  
  4078. panNorth = new JPanel();
  4079.  
  4080. panNorth.add(lblEmp);
  4081.  
  4082. panNorth.add(cmbEmp);
  4083.  
  4084.  
  4085. dtm = new DefaultTableModel();
  4086.  
  4087. dtm.addColumn("EmpNo");
  4088.  
  4089. dtm.addColumn("Name");
  4090.  
  4091. dtm.addColumn("Salary");
  4092.  
  4093. //dtm.addColumn("Designation");
  4094.  
  4095.  
  4096. tabRecord = new JTable(dtm);
  4097.  
  4098.  
  4099. setTitle("View Employee");
  4100.  
  4101. setSize(500,150);
  4102.  
  4103. add(panNorth,"North");
  4104.  
  4105. add(new JScrollPane(tabRecord),"Center");
  4106.  
  4107. setVisible(true);
  4108.  
  4109. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  4110.  
  4111.  
  4112.  
  4113. try{
  4114.  
  4115. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  4116.  
  4117. con=DriverManager.getConnection("jdbc:odbc:lab.dsn");
  4118.  
  4119. s = con.createStatement();
  4120.  
  4121.  
  4122. rs = s.executeQuery("select * from emp");
  4123.  
  4124. cmbEmp.addItem("---");
  4125.  
  4126. while(rs.next()){
  4127.  
  4128. cmbEmp.addItem(rs.getString(2));
  4129.  
  4130. }
  4131.  
  4132. }
  4133.  
  4134. catch(Exception e){
  4135.  
  4136. JOptionPane.showMessageDialog(null,e);
  4137.  
  4138. }
  4139.  
  4140.  
  4141.  
  4142. cmbEmp.addItemListener(new ItemListener(){
  4143.  
  4144. public void itemStateChanged(ItemEvent ie){
  4145.  
  4146. try{
  4147.  
  4148. String name = cmbEmp.getSelectedItem().toString();
  4149.  
  4150. ps = con.prepareStatement("select * from emp where name=?");
  4151.  
  4152. ps.setString(1,);
  4153.  
  4154. rs = ps.executeQuery();
  4155.  
  4156. if(rs.next()){
  4157.  
  4158. Vector rec = new Vector();
  4159.  
  4160. rec.add(rs.getString(1));
  4161.  
  4162. rec.add(rs.getString(2));
  4163.  
  4164. rec.add(rs.getString(3));
  4165.  
  4166. // rec.add(rs.getString(4));
  4167.  
  4168.  
  4169. if(dtm.getRowCount()>0)
  4170.  
  4171. dtm.removeRow(0);
  4172.  
  4173. dtm.addRow(rec);
  4174.  
  4175. }
  4176.  
  4177. }
  4178.  
  4179. catch(Exception e){
  4180.  
  4181. JOptionPane.showMessageDialog(null,e);
  4182.  
  4183. }
  4184.  
  4185. }
  4186.  
  4187. });
  4188.  
  4189. }
  4190.  
  4191.  
  4192. public static void main(String args[]){
  4193.  
  4194. new EmpView();
  4195.  
  4196. }
  4197.  
  4198. }
  4199. Q3 :
  4200. Html file :
  4201.  
  4202.  
  4203. <html> <body>
  4204. <form action="slip_28_Q3-1.php" method="get">
  4205. <center> <b>Select font style :</b>
  4206. <input type=text name=s1> <br>
  4207. <b>Enter font size : </b><input type=text name=s><br>
  4208. <b>Enter font color : </b><input type=text name=c><br>
  4209. <b>Enter background color :</b>
  4210. <input type=text name=b><br>
  4211. <input type=submit value="Next">
  4212. </center>
  4213. </form>
  4214. </body>
  4215. </html>
  4216.  
  4217. Php file :
  4218. slip_28_1.php
  4219. <?php
  4220. echo "style is ".$_GET['s1']."<br>color is ".$_GET['c']."<br>Background color is ".$_GET['b']."<br>size is ".$_GET['s'];
  4221.  
  4222. setcookie("set1",$_GET['s1'],time()+3600); setcookie("set2",$_GET['c'],time()+3600); setcookie("set3",$_GET['b'],time()+3600); setcookie("set4",$_GET['s'],time()+3600);
  4223. ?>
  4224.  
  4225. <html>
  4226. <body>
  4227.  
  4228. <form action="slip28_2.php">
  4229. <input type=submit value=OK>
  4230. </form>
  4231. </body>
  4232. </html>
  4233. php file : slip28_2.php
  4234. <?php
  4235. $style=$_COOKIE['set1'];
  4236. $color=$_COOKIE['set2'];
  4237. $size=$_COOKIE['set4'];
  4238. $b_color=$_COOKIE['set3'];
  4239. $msg="NR Classes";
  4240. echo "<body bgcolor=$b_color>";
  4241. echo "<font color=$color size=$size>$msg";
  4242. echo "</font></body>";
  4243.  
  4244. ?>
  4245. Slip no 29
  4246. Q1 :
  4247. <html>
  4248. <body>
  4249. <form method=post action="Vote.jsp">
  4250. Enter Your Age : <input type=text name=t1><br>
  4251. <br>
  4252. <input type=submit>
  4253. </form>
  4254. </body>
  4255. </html>
  4256. Vote.jsp :
  4257. <html>
  4258. <body>
  4259. <%! int n; %>
  4260. <% n=Integer.parseInt(request.getParameter("t1"));
  4261. if(n>=18)
  4262. out.print("You are eligible for voting....!");
  4263. else
  4264. out.print("You are not eligible for voting....!");
  4265. %>
  4266. </body>
  4267. </html>
  4268. Q2 :
  4269. import java.sql.*;
  4270. import java.io.*;
  4271. class slip29
  4272. {
  4273. public static void main(String args[])
  4274. {
  4275. Connection con;
  4276. Statement state;
  4277. ResultSet rs;
  4278. int ch,k;
  4279.  
  4280. boolean flag=true;
  4281. String decision;
  4282. int rno;
  4283.  
  4284.  
  4285. try
  4286. {
  4287. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  4288. con = DriverManager.getConnection("jdbc:odbc:lab.dsn");
  4289.  
  4290. System.out.println("Statement object created");
  4291.  
  4292. do
  4293. {
  4294. System.out.println("\n");
  4295. System.out.println("Menu:");
  4296. System.out.println("1.Insert Record into the Table");
  4297. System.out.println("2.Update The Existing Record.");
  4298. System.out.println("3.Display all the Records from the Table");
  4299. System.out.println("4.Delete Record into the Table");
  4300. System.out.println("5.Search The Existing Record.");
  4301. System.out.println("6.Exit");
  4302. System.out.println("Enter your choice: ");
  4303. BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  4304. ch=Integer.parseInt(br.readLine());
  4305.  
  4306. switch(ch)
  4307. {
  4308. case 1:
  4309. System.out.println("Enter Student Number: ");
  4310. rno=Integer.parseInt(br.readLine());
  4311.  
  4312. System.out.println("Enter Student Name: ");
  4313. String name=br.readLine();
  4314.  
  4315. System.out.println("Enter Percentage: ");
  4316. int per=Integer.parseInt(br.readLine());
  4317. String sql="insert into Student values(?,?,?)";
  4318. PreparedStatement p=con.prepareStatement(sql);
  4319. p.setInt(1,rno);
  4320. p.setString(2,name);
  4321. p.setInt(3,per);
  4322. p.executeUpdate();
  4323. System.out.println("Record Added");
  4324.  
  4325. break;
  4326.  
  4327.  
  4328. case 2:
  4329.  
  4330.  
  4331. state=con.createStatement();
  4332. System.out.println("Enter the rno");
  4333. rno=Integer.parseInt(br.readLine());
  4334.  
  4335. System.out.println("Enter the per");
  4336. per=Integer.parseInt(br.readLine());
  4337.  
  4338. String ss="update Student set Student.per="+per+" where(((Student.[rno])="+rno+"))";
  4339.  
  4340. k=state.executeUpdate(ss);
  4341. System.out.println(ss);
  4342.  
  4343. if(k>0)
  4344. {
  4345. System.out.println("Record Is Updated");
  4346. }
  4347. break;
  4348.  
  4349.  
  4350. case 3:
  4351. state=con.createStatement();
  4352. sql="select * from Student";
  4353. rs=state.executeQuery(sql);
  4354. while(rs.next())
  4355. {
  4356. System.out.println("\n");
  4357. System.out.print("\t" +rs.getInt(1));
  4358. System.out.print("\t" +rs.getString(2));
  4359. System.out.print("\t" +rs.getInt(3));
  4360. }
  4361. break;
  4362.  
  4363. case 4:
  4364.  
  4365.  
  4366. state =con.createStatement();
  4367.  
  4368. while(flag)
  4369. {
  4370. System.out.println("Enter Student Number for the record you wish to Delete: ");
  4371. rno=Integer.parseInt(br.readLine());
  4372.  
  4373. sql="delete from Student where rno="+rno;
  4374. System.out.println(sql);
  4375. int rows=state.executeUpdate(sql);
  4376. System.out.println(rows+"rows sucessfully Deleted");
  4377. System.out.println("Do u want to Delete more data:y/n:");
  4378.  
  4379. decision=br.readLine().toLowerCase();
  4380. if(decision.charAt(0)=='n')
  4381. flag=false;
  4382.  
  4383.  
  4384. }
  4385. break;
  4386.  
  4387. case 5:
  4388. state=con.createStatement();
  4389. System.out.println("enter roll no u want to search");
  4390. rno=Integer.parseInt(br.readLine());
  4391. sql="select * from Student where rno="+rno;
  4392. rs=state.executeQuery(sql);
  4393.  
  4394. System.out.println("success");
  4395. while(rs.next())
  4396. {
  4397. System.out.println("RollNo="+rs.getInt(1)+""+"name="+rs.getString(2)+" "+"per="+rs.getInt(3));
  4398. }
  4399. break;
  4400.  
  4401.  
  4402. case 6:
  4403. System.exit(0);
  4404.  
  4405. default:
  4406. System.out.println("Invalid Choice");
  4407. break;
  4408. }
  4409. }while(ch!=6);
  4410. }catch(Exception e)
  4411. {
  4412. System.out.println(e);
  4413. }
  4414. }
  4415. }
  4416. Q3 :
  4417. <?xml version=”1.0” encoding=”utf-8”?>
  4418. <Course>
  4419. <Computer Science>
  4420. <Student name>Sachin pawar</Student name>
  4421. <Class name>SYBCS</Class name>
  4422. <percentage>56</percentage> </Computer Science>
  4423. </Course>
  4424.  
  4425. <Course>
  4426. <Computer Science>
  4427. <Student name>Sachin pawar</Student name>
  4428. <Class name>SYBCS</Class name>
  4429. <percentage>56</percentage>
  4430. </Computer Science>
  4431. </Course>
  4432. <Course>
  4433. <Computer Science>
  4434. <Student name>Sachin pawar</Student name>
  4435. <Class name>SYBCS</Class name>
  4436. <percentage>56</percentage>
  4437. </Computer Science>
  4438. </Course>
  4439. <Course>
  4440. <Computer Science>
  4441. <Student name>Sachin pawar</Student name>
  4442. <Class name>SYBCS</Class name>
  4443. <percentage>56</percentage>
  4444. </Computer Science>
  4445. </Course>
  4446.  
  4447.  
  4448. Q4 :
  4449.  
  4450. Userpass.html
  4451. <html>
  4452. <body>
  4453. <form method=get action="userpass.php">
  4454. Enter UserName : <input type=text name="t1"><br><br>
  4455. Enter Password : <input type=text name="t2"><br><br>
  4456. <input type=submit value="Log In">
  4457. </form>
  4458. </body>
  4459. </html>
  4460. Userpass.php :
  4461.  
  4462.  
  4463. <?php
  4464. session_start();
  4465. session_register("chance");
  4466. if($_SERVER['REQUEST_METHOD']=='GET')
  4467. {
  4468. ?>
  4469. <form method=post action="<?php echo $_SERVER['PHP_SELF']?>">
  4470. <P>Name : <input type=text name=uname value="<?php if(isset($_POST['uname'])) echo $_POST['uname'];?>">
  4471. </p>
  4472. <P>Passoword : <input type=text name=pass value="<?php if(isset($_POST['pass'])) echo $_POST['pass'];?>"></p>
  4473. <input type=submit name=submit value=submit> </form>
  4474. <?php
  4475. }
  4476. else if($_SERVER['REQUEST_METHOD']=='POST')
  4477. {
  4478. $name=$_POST['uname'];
  4479. $pass=$_POST['pass'];
  4480. if(($name=="ABC") && ($pass=="abc"))
  4481. echo"Hello <a href='next.php'>next form</a>";
  4482. else echo"wrong username password ".session_register("chance")."!!!"; $chance++;
  4483. if($chance==3)
  4484. echo"sorry!!! your chance are finished!!!!!";
  4485. }
  4486. else
  4487. {
  4488. die("not able to process script");
  4489. }
  4490. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement