Pages

Monday, 7 March 2011

Sem 2 JAVA Servlet


/***************************************************************
NAME     :
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :

Write a servlet which accepts the user name from an HTML page and returns a message which greets the user.
***************************************************************/

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

 class seta1 extends HttpServlet
 {
    public void doGet(HttpServletRequest req,
                      HttpServletResponse res)
    {
      try
       {
        PrintWriter out = res.getWriter();
        String s1 =req.getParameter("txtname");
        out.println("<center>"+s1);      
        out.println("<center> WELCOME TO SERVLET PROGRAMING <br>");
      
       }
       catch(Exception e)
       {
         e.printStackTrace();

       }
    }
 }
****************************************************************************************

/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 

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

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

 class seta2 extends HttpServlet
 {
    public void doGet(HttpServletRequest req,
                      HttpServletResponse res)
    {
      try
       {  
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
        out.println("<html>");        
        out.println("<body>");
        java.util.Properties p=System.getProperties();
        out.println("Server Name :"+req.getServerName()+"<br>");        
        out.println("Operating System Name :"+p.getProperty("Linux")+"<br>"); 
        out.println("IP Address :"+req.getRemoteAddr()+"<br>");        
        out.println("Remote User:"+req.getRemoteUser()+"<br>"); 
        out.println("Remote Host:"+req.getRemoteHost()+"<br>"); 
        out.println("Local Name :"+req.getLocalName()+"<br>");         
        out.println("Server Port:"+req.getServerPort()+"<br>");        
        out.println("Servlet Name :"+this.getServletName()+"<br>"); 
        out.println("Protocol Name :"+req.getProtocol()+"<br>");     
        out.println("</html>");                   
        out.println("</body>");
       }
       catch(Exception e)
       {
         e.printStackTrace();

       }
    }
 }
***********************************************************************************************


/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 

Write a servlet which counts how many times a user has visited a web page. If the user is visiting the page for the first time, display a welcome message. If the user is re- visiting the page, display the number of times visited. (Use cookies)
***************************************************************/

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


 class firstcook extends HttpServlet {


    public void doGet(HttpServletRequest req,
                      HttpServletResponse res)
    {
      
        PrintWriter out = null;
      try
       {   
        out = res.getWriter();
         
        Cookie c[]=req.getCookies();
        int i;
       //to search the cookie in the existig cookie
 
       for( i=0;i<c.length;i++)
       {
         String s=c[i].getName();
         if(s.equals("count1"))
        {
         String s1=c[i].getValue();
         int n=Integer.parseInt(s1)+1;
         out.println("page is visited for"+n);
         Cookie c2=new Cookie("count",Integer.toString(n));
          res.addCookie(c2);
          break;
        }
       }
  
       //if cookie not found
        
        if(i==c.length)
       {
        Cookie c1=new Cookie("count","1");
         res.addCookie(c1);
         out.println("welcome");
       }
       }
       catch(Exception e)
       {
         e.printStackTrace();

       }
    }
 }
*************************************************************************************
/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 

Create an HTML page with text boxes for login id and password. Pass these to the servlet. If the login name = “BSc” and password = “CS”, display welcome.html else display an error.html  (hint: Return the <a href=http://server- p:8080/Welcome.html> tag to the client machine)
***************************************************************/

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


 class seta4 extends HttpServlet
 {
    public void doGet(HttpServletRequest req,
                      HttpServletResponse res)
    {
      try
       {  
        PrintWriter out = res.getWriter();
        String s1=req.getParameter("txtname");        
        String s2=req.getParameter("txtpass"); 
         if(s1=="BSC" && s2=="CS")
        {
          //out.println("<a href=http://localhost:8080/dipa/welcome.html>next </a>");
         res.sendRedirect("welcome.html");
        }
         else
        {
         //out.println("<a href=http://localhost:8080/dipa/error.html>next </a>");
        res.sendRedirect("error.html");  
        }
        }catch(Exception e)
       {
         e.printStackTrace();

       }
    }
 }
*********************************************************************************************

/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 

Write a program  to  create  a hopping  mall. User  must be allowed to do purchase from two pages. Each page should have a page total. The third page should display a bill, which consists of a page total of what ever the purchase has been done and print the total. (Use HttpSession)
***************************************************************/

//form1.html

                                            
<html>
<body>
<form action="http://localhost:8080/nitish/p1" method=get>
 <table border=1>
        <tr><th>Iteam name </th><th>Price</th><th>qty </th></tr>
          <tr>
          <td><input type=text name=txtname value=Pond's /></td>
          <td><input type=text name=txtunit value=70 /></td>
          <td><input type=text name=txtqty /></td>
         </tr>
          <tr>
         <td><input type=text name=txtname value=Shampo /></td>
         <td><input type=text name=txtunit value=80 /></td>
          <td><input type=text name=txtqty /></td>
         </tr>
         <tr>
          <td><input type=text name=txtname value=Camera /></td>
          <td><input type=text name=txtunit value=102 /></td>
          <td><input type=text name=txtqty /></td>
          </tr>
          </table>
         <br><input type=submit name=NEXT />
         <br><input type=reset name=RESET />
          </form>
</body>
</html>                                


//page1.java

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


 class page1 extends HttpServlet
 {
    public void doGet(HttpServletRequest req,
                      HttpServletResponse res)
    {
       
        PrintWriter out = null; 
        try
       { 
        out=res.getWriter();
         HttpSession htpses=req.getSession(true);
         String name[]=req.getParameterValues("txtname");
         String price[]=req.getParameterValues("txtunit");
         String qty[]=req.getParameterValues("txtqty");
         int sum=0;
        for(int i=0;i<name.length;i++)
        {                             
         int cost=Integer.parseInt(price[i])*Integer.parseInt(qty[i]);
           sum+=cost;
         } 
         out.println("Last Page Total="+sum);
         htpses.setAttribute("page1",Integer.toString(sum));
         //second html page
          res.setContentType("text/html");
          out.println("<form method=get action='http://localhost:8080/dipa/p2' >");
          out.println("<table border=1>");
          out.println("<tr><th>Iteam name </th><th>Price</th><th>qty </th></tr>");
          out.println("<tr>");
          out.println("<td><input type=text name=txtname value=Toothbrush /></td>");
          out.println("<td><input type=text name=txtunit value=10 /></td>");
          out.println("<td><input type=text name=txtqty /></td>");
          out.println("</tr>");
          out.println("<tr>");
          out.println("<td><input type=text name=txtname value=Towel /></td>");
          out.println("<td><input type=text name=txtunit value=70 /></td>");
          out.println("<td><input type=text name=txtqty /></td>");
          out.println("</tr>");
          out.println("<tr>");
          out.println("<td><input type=text name=txtname value=Shoes /></td>");
          out.println("<td><input type=text name=txtunit value=500 /></td>");
          out.println("<td><input type=text name=txtqty /></td>");
          out.println("</tr>");
          out.println("</table>");
          out.println("<br><input type=submit name=NEXT />");
          out.println("<br><input type=reset name=RESET />"); 
          out.println("</form>");
                          
        }catch(Exception e)                      
       {
         out.println("error="+e);

       }
     }
   }



//page2.java

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


 class page2 extends HttpServlet
 {
    public void doGet(HttpServletRequest req,
                      HttpServletResponse res)
    {
       
        PrintWriter out = null; 
        try
       { 
        out=res.getWriter();
         HttpSession htpses=req.getSession(true);
         String name[]=req.getParameterValues("txtname");
         String price[]=req.getParameterValues("txtunit");
         String qty[]=req.getParameterValues("txtqty");
         int sum=0;
        for(int i=0;i<name.length;i++)
        {
         int cost=Integer.parseInt(price[i])*Integer.parseInt(qty[i]);
         htpses.setAttribute(name[i],Integer.toString(cost));  
          sum+=cost;
         } 
          String s=(String)htpses.getAttribute("page1");
          int total=sum+Integer.parseInt(s);
         out.println("Total Bill="+total);
          
        }catch(Exception e)
       {
         out.println("error="+e);

       }
     }
   }


//Setb1.xml

  <?xml version="1.0" encoding="ISO-8859-1" ?> 
- <web-app>
- <servlet>
  <servlet-name>SETB1</servlet-name> 
  <servlet-class>page1</servlet-class> 
  </servlet>
- <servlet-mapping>
  <servlet-name>SETB1</servlet-name> 
  <url-pattern>/p1</url-pattern> 
  </servlet-mapping>
- <servlet>
  <servlet-name>SETB11</servlet-name> 
  <servlet-class>page2</servlet-class> 
  </servlet>
- <servlet-mapping>
  <servlet-name>SETB11</servlet-name> 
  <url-pattern>/p2</url-pattern> 
  </servlet-mapping>
  </web-app>
*****************************************************************************************

/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :

Design an HTML page containing 4 option buttons (Painting, Drawing, Singing and swimming) and 2 buttons reset and submit. When the user clicks submit, the server responds by adding a cookie containing the selected hobby and sends a message back to 
the client. Program should not allow duplicate cookies to be written.
***************************************************************/

//Setb2.html

<html>
<body>
<form method=get action="http://localhost:8080/dipa/choice">
select your hobbie:<br>
<input type=radio name=ch value=painting>PAINTING<br>
<input type=radio name=ch value=drawing>DRAWING<br>
<input type=radio name=ch value=swiming>SWIMING<br>
<input type=radio name=ch value=singing>SINGING<br>
<br><input type=submit value=select>
<br><input type=reset>
</form>
</body>
</html>    


//Setb21.java

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


 class setb21 extends HttpServlet {


    public void doGet(HttpServletRequest req,
                      HttpServletResponse res)
    {
      
        PrintWriter out = null;
      try
       {   
         out=res.getWriter();
         String hb=req.getParameter("ch");
         Cookie c1=new Cookie("hobby",hb);
         out.println("hobby are:"+hb);
         //res.addCookie(c1);
       }
       catch(Exception e)
       {
         e.printStackTrace();

       }
    }
 }



//Setb2n.java

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


 class setb2 extends HttpServlet {


    public void doGet(HttpServletRequest req,
                      HttpServletResponse res)
    {
      
        PrintWriter out = null;
      try
       {   
        out=res.getWriter();
        Cookie c[]=req.getCookies();
        for(int i=0;i<c.length;i++)
        {
         String s1=c[i].getName();
         out.println("selected hobby are :"+s1);  
        }
       }
       catch(Exception e)
       {
         e.printStackTrace();
       }
    }
 }


//Setb2.xml

  <?xml version="1.0" encoding="ISO-8859-1" ?> 
- <web-app>
- <servlet>
  <servlet-name>SETB2</servlet-name> 
  <servlet-class>setb2</servlet-class> 
  </servlet>
- <servlet-mapping>
  <servlet-name>SETB2</servlet-name> 
  <url-pattern>/choice</url-pattern> 
  </servlet-mapping>
  </web-app>


Sem 2 JAVA COLLECTION


/***************************************************************
NAME     :
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :

Accept ‘n’ integers from the user and store them in a collection. Display them in the sorted order. The collection should not accept duplicate elements. (Use a suitable collection).
***************************************************************/

import java.util.*;
import java.io.*;

class cola1
{
  public static void main(String[] args) throws Exception
  {
   int num,ele,i;
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   ArrayList al=new ArrayList();
   System.out.println("Enter the no for how many element to have:");
   num=Integer.parseInt(br.readLine());
   for(i=0;i<num;i++)
   {
     System.out.println("Enter the elements in position:"+i);
     ele=Integer.parseInt(br.readLine());
    al.add(ele);
   }
 
     System.out.println("The elements of ArrayList before:"+al);
     Collections.sort(al);
     System.out.println("The elements of ArrayList after sort:"+al);
}
}

/*****************************output****************************

[root@localhost ~]# java collection1
Enter the no for how many element to have:
5
Enter the elements in position:0
5
Enter the elements in position:1
3
Enter the elements in position:2
7
Enter the elements in position:3
2
Enter the elements in position:4
8
The elements of ArrayList before:[5, 3, 7, 2, 8]
The elements of ArrayList after sort:[2, 3, 5, 7, 8]

*****************************************************************************/


/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 

Construct a linked List containing name of colors: red, blue, yellow and orange. Then extend your program to do the following: 
i.Display the contents of the List using an Iterator; 
ii.Display the contents of the List in reverse order using a ListIterator; 
iii.Create another list containing  pink and  green. Insert the elements of this list between blue and yellow.
***************************************************************/

import java.util.*;

class collection2
{
  public static void main(String[] args)
  {
   LinkedList ll=new LinkedList();
   ll.add("Red");
   ll.add("Blue");
   ll.add("Yellow");
   ll.add("Orange");
   Iterator i=ll.iterator();
   System.out.println("contents of the List using an Iterator:");
   while(i.hasNext()) 
    {
     String s=(String)i.next();
     System.out.println(s);
    }
 ListIterator litr = ll.listIterator();
    while(litr.hasNext())
   {
     String elt = (String)litr.next();
   }
   System.out.println("contents of the List in reverse order using a ListIterator : ");
while(litr.hasPrevious())
    {
    System.out.println(litr.previous());
    }
   ll.add(2,"Pink");
     ll.add(3,"Green");
    System.out.println("list between blue and yellow is:");
    System.out.println(ll);
   }
}

/******************************output***************************

[root@localhost ~]# java collection2
contents of the List using an Iterator:
Red
Blue
Yellow
Orange
contents of the List in reverse order using a ListIterator : 
Orange
Yellow
Blue
Red
list between blue and yellow is:
[Red, Blue, Pink, Green, Yellow, Orange]

*******************************************************************************************/

/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 

Create a Hash table containing student name and percentage. Display the details of the hash table. Also search for a specific student and display percentage of that student.
***************************************************************/

import java.util.*;

class collection3
{
 public static void main(String[] args) throws Exception
  {
   Hashtable ht=new Hashtable();
   ht.put("Anand",66.2);
   ht.put("Anil",65.7);
   ht.put("Shashank",64.8);
   Enumeration keys=ht.keys();
   Enumeration values=ht.elements();
   while(keys. hasMoreElements())
     {
     while(values. hasMoreElements())
       {
        System.out.println("student name:"+keys.nextElement()+"\tpercentage:"+values.nextElement());
        }
      }
   System.out.println("specific student name is Anand & percentage is:"+ht.get("Anand"));
  }
}

/*****************************output****************************

[root@localhost ~]# java collection3
student name:Anand percentage:66.2
student name:Shashank percentage:64.8
student name:Anil percentage:65.7
specific student name is Anand & percentage is:66.2

**************************************************************************************************/


/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 
Implement Hash table to store ‘n’ records of students (Name, Percentage). Write a menu driven program to: 
 1.  Add student 
 2.  Display details of all students 
 3.  Search student 
 4.  Find out highest marks
***************************************************************/

import java.io.*;
import java.util.*;
public class collection4
{
public static void main(String[] args) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

Hashtable hashtable = new Hashtable();
String str, name = null;
int n=Integer.parseInt(br.readLine());
String nm="";
double per;
double max=0;
for(int i=0;i<n;i++)
{
System.out.println("Enter the Student Name?");
nm=br.readLine();
System.out.println("Enter the Student Percentage ?");
per=Double.parseDouble(br.readLine());
hashtable.put(nm,per);
}
int ch;
do
{
System.out.println("1:Add Stduent \n2:Display details of Student\n3:Serach\n4:Findout Highest Marks ");
    System.out.println("Enter the Choice");
    ch=Integer.parseInt(br.readLine());
switch(ch)
{
case 1:
System.out.println("Enter the Student Name?");
nm=br.readLine();
System.out.println("Enter the Student Percentage ?");
per=Double.parseDouble(br.readLine());
hashtable.put(nm,per);
break;
case 2:
System.out.println("Retriving all Name from the Hashtable");
Enumeration keys = hashtable.keys();
while( keys. hasMoreElements() )
System.out.println( keys.nextElement() );

System.out.println("Retriving all Percentage from the table");
Enumeration values = hashtable.elements();
while( values. hasMoreElements() )
System.out.println( values.nextElement() );
break;
case 3:
System.out.println("Enter the Student Name?");
String nm1=br.readLine();
if(hashtable.containsKey(nm1))
{
System.out.println("Name "+nm1+" is Present");
}
else
System.out.println("Name "+nm1+"\t Not Present");
break;
case 4:
keys = hashtable.keys();
values = hashtable.elements();
while( values. hasMoreElements() )
{
double per1=((Double)values.nextElement()).doubleValue();
nm1=(String)keys.nextElement();
if(per1>max){
max=per1;
name=nm1;
}
}
System.out.println("Max Percentage ="+max);
System.out.println("Name"+name);
}
}while(ch!=5);

}
}

/******************************output***************************

[root@localhost collection1]# java collection4 
2
Enter the Student Name?
Anand Warghad
Enter the Student Percentage ?
65
Enter the Student Name?
Anil lokhande
Enter the Student Percentage ?
70
1:Add Stduent 
2:Display details of Student
3:Serach
4:Findout Highest Marks 
Enter the Choice
1
Enter the Student Name?
Gaurav Kadam
Enter the Student Percentage ?
60
1:Add Stduent 
2:Display details of Student
3:Serach
4:Findout Highest Marks 
Enter the Choice
2
Retriving all Name from the Hashtable
Anil lokhande
Gaurav Kadam
Anand Warghad
Retriving all Percentage from the table
70.0
60.0
65.0
1:Add Stduent 
2:Display details of Student
3:Serach
4:Findout Highest Marks 
Enter the Choice
3
Enter the Student Name?
Anand Warghad
Name Anand Warghad is Present
1:Add Stduent 
2:Display details of Student
3:Serach
4:Findout Highest Marks 
Enter the Choice
4
Max Percentage =70.0
NameAnil lokhande
1:Add Stduent 
2:Display details of Student
3:Serach
4:Findout Highest Marks

***************************************************************/

Sem 2 JAVA JDBC


/***************************************************************
NAME     :
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :
Create a student table with fields roll number, name,percentage. Insert values in the table. Display all the details of the student table using JDBC.
***************************************************************/
import java.sql.*;
public class m1
{
public static void main(String a[]) throws Exception
{
Connection con;
Statement r2;
ResultSet r;
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost/
student","root","");
r2=con.createStatement();
r2.executeUpdate("create table student(rollno int
primary key,name text,per int)");
r2.executeUpdate("insert into student values(1,'Rutuja',67)");
r2.executeUpdate("insert into student values(2,'Harshali',63)");
r2.executeUpdate("insert into student values(3,'Tejashree',61)");
r=r2.executeQuery("select * from student");
while(r.next())
System.out.println("\nRoll no="+r.getInt(1)+"\nname="
+r.getString(2)+"\npercentage="+r.getInt(3));
}
}

/* OUTPUT:-
Roll no=1
name=Nitish
percentage=67

Roll no=2
name=Dipali
percentage=63

Roll no=3
name=Nalini
percentage=61

*/
***********************************************************************************



/***************************************************************
NAME     :
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :

Write a program to display information about the database and list all the tables in the database. (Use DatabaseMetaData).
***************************************************************/

import java.sql.*;
public class mysql1
{
    public static void main(String[] args) throws Exception
    {
    DatabaseMetaData d;
    Connection con;
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql://localhost/student","root","");
    d=con.getMetaData();
    System.out.println("Driver name="+d.getDriverName());
    System.out.println("Version is="+d.getDriverVersion());
    System.out.println("user name="+d.getUserName());

    ResultSet n=d.getTables(null, null, null, new String[]{"TABLE"});
    System.out.println("\nInformation about tables");
    while(n.next())
    {
        System.out.println("Table name="+n.getString("TABLE_NAME"));
        System.out.println("Table type="+n.getString("TABLE_TYPE"));
    }
    }
}

/* OUTPUT:-
Driver name=MySQL-AB JDBC Driver
Version is=mysql-connector-java-5.1.14 ( Revision: ${bzr.revision-id} )
user name=root@localhost
Information about tables
Table name=student
Table type=TABLE
*/
***********************************************************************************

/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 

Write a program to display information about all columns in the student table. (Use ResultSetMetaData).
***************************************************************/

import java.sql.*;
public class mysql2
{
    public static void main(String[] args) throws Exception
    {
    ResultSetMetaData d;
    Connection con;
    Statement s;
    ResultSet rs;
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql://localhost/student","root","");
    s=con.createStatement();
    rs=s.executeQuery("select * from student");
    d=rs.getMetaData();
    System.out.println("column no="+d.getColumnCount());
    for(int i=1;i<=d.getColumnCount();i++)
    {
    System.out.println("column Name="+d.getColumnName(i));
    System.out.println("column type name="+d.getColumnTypeName(i));
    }
    }

}

/* OUTPUT:-
column no=3
column Name=rollno
column type name=INT
column Name=name
column type name=VARCHAR
column Name=per
column type name=INT
*/
********************************************************************************************

/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 

Write a menu driven program to perform the following operations on student table.
1. Insert        
2. Modify      
3. Delete       
4. Search        
5. View All 
6. Exit
***************************************************************/

import java.sql.*;
import java.io.*;
public class mysql3
{
    public static void main(String[] args) throws Exception
    {
    Connection con;
    ResultSet rs;
    Statement t;
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql://localhost/student","root","");
    do
    {
    System.out.println("\n1.Insert\n2.Modify\n3.Delete\n4.Search\n5.View all\n6.Exit");
    System.out.println("Enter the choice");
    int ch=Integer.parseInt(br.readLine());
    switch(ch)
    {
        case 1:
            System.out.println("Enter the Rollno");
            int roll=Integer.parseInt(br.readLine());
            System.out.println("Enter the name");
            String n=br.readLine();
            System.out.println("Enter the percentage");
            int per=Integer.parseInt(br.readLine());
            t=con.createStatement();
            t.executeUpdate("insert into student values("+roll+",'"+n+"',"+per+")");
            break;
        case 2:
            System.out.println("Enter the roll no for update record");
            roll=Integer.parseInt(br.readLine());
            System.out.println("Enter the name");
            n=br.readLine();
            System.out.println("Enter the percentage");
            per=Integer.parseInt(br.readLine());
            t=con.createStatement();
            t.executeUpdate("update student set name='"+n+"',per="+per+" where rollno="+roll);
            break;
        case 3:
            System.out.println("Enter the roll no for delete record");
            int no=Integer.parseInt(br.readLine());
            t=con.createStatement();
            t.executeUpdate("delete from student where rollno="+no);
            break;
        case 4:
            System.out.println("Enter the roll no for search");
            no=Integer.parseInt(br.readLine());
            t=con.createStatement();
            rs=t.executeQuery("select * from student where rollno="+no);
            while(rs.next())
            {
                System.out.println("Roll no="+rs.getInt(1));
                System.out.println("name="+rs.getString(2));
                System.out.println("percentage="+rs.getInt(3));
            }
            break;
        case 5:
            t=con.createStatement();
            rs=t.executeQuery("select * from student");
            while(rs.next())
            {
                System.out.println("Roll no="+rs.getInt(1));
                System.out.println("name="+rs.getString(2));
                System.out.println("percentage="+rs.getInt(3));
            }
            break;
        case 6:
            System.exit(0);
            break;
    }
    }while(true);
    }

}

/* OUTPUT:-

1.Insert
2.Modify
3.Delete
4.Search
5.View all
6.Exit
Enter the choice
1
Enter the Rollno
4
Enter the name
Rutuja
Enter the percentage
85

1.Insert
2.Modify
3.Delete
4.Search
5.View all
6.Exit
Enter the choice
5
Roll no=1
name=Pallavi
percentage=67
Roll no=2
name=Vinaya
percentage=63
Roll no=3
name=Trupti
percentage=61
Roll no=4
name=Rutuja
percentage=85

1.Insert
2.Modify
3.Delete
4.Search
5.View all
6.Exit
Enter the choice
2
Enter the roll no for update record
4
Enter the name
Rutuja
Enter the percentage
35

1.Insert
2.Modify
3.Delete
4.Search
5.View all
6.Exit
Enter the choice
3
Enter the roll no for delete record
4

1.Insert
2.Modify
3.Delete
4.Search
5.View all
6.Exit
Enter the choice
5
Roll no=1
name=Pallavi
percentage=67
Roll no=2
name=Vinaya
percentage=63
Roll no=3
name=Trupti
percentage=61

1.Insert
2.Modify
3.Delete
4.Search
5.View all
6.Exit
Enter the choice
4
Enter the roll no for search
2
Roll no=2
name=Vinaya
percentage=63

1.Insert
2.Modify
3.Delete
4.Search
5.View all
6.Exit
Enter the choice
6
*/
**********************************************************************************
/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 

Program to Read ,Update and Delete any record from Elements table. The table has following fields ( Atomic weight, Name (primary key), Chemical symbol). The input should be provided through Command Line Arguments along with the appropriate data.
The operations are: R : Read, U: Update, D: Delete.
  The syntax for Read: R
  The syntax for Delete: D name
  The syntax for Update: U name new-atomic-weight new-symbol
***************************************************************/

import java.sql.*;
public class mysql4
{
    public static void main(String[] args) throws Exception
    {
    Connection con;
    ResultSet rs;
    Statement t;
    PreparedStatement pr;
    Class.forName("com.mysql.jdbc.Driver");
    con=DriverManager.getConnection("jdbc:mysql://localhost/chemical","root","");
    char ch=args[0].charAt(0);
    switch(ch)
    {
        case 'R':
            t=con.createStatement();
            rs=t.executeQuery("select * from element");
            while(rs.next())
            {
                System.out.println("name="+rs.getString(2));
                System.out.println("automic wt="+rs.getInt(1));
                System.out.println("symbol="+rs.getString(3));
            }
            break;
        case 'D':
            String name=args[1];
            t=con.createStatement();
            t.executeUpdate("delete from element where name='"+name+"'");
            break;
        case 'U':
            name=args[1];
            int awt=Integer.parseInt(args[2]);
            String sm=args[3];
            t=con.createStatement();
            t.executeUpdate("update element set automicwt="+awt+",chemical_sym='"+sm+"' where name='"+name+"'");
            break;
    }
    }

  }

/* OUTPUT:-

[root@localhost setb]# java mysql4 R
name=iron
automic wt=132
symbol=al
name=silver
automic wt=32
symbol=s
name=mercury
automic wt=52
symbol=hg
name=zink
automic wt=52
symbol=zn

2:
[root@localhost setb]# java mysql4 D iron 
[root@localhost setb]# java mysql4 R 
name=silver
automic wt=32
symbol=s
name=mercury
automic wt=52
symbol=hg
name=zink
automic wt=52
symbol=zn

3:

[root@localhost setb]# java mysql4 U silver 32 ag 
[root@localhost setb]# java mysql4 R 
name=silver
automic wt=32
symbol=ag
name=mercury
automic wt=52
symbol=hg
name=zink
automic wt=52
symbol=zn

*/


Sem 2 JAVA THREAD


/***************************************************************
NAME     :
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :
Write a program that create 2 threads – each displaying a message (Pass the message as a parameter to the constructor). The threads should display the messages continuously till the user presses ctrl-c. Also display the thread information as it is running.
***************************************************************/

import java.io.*;
class Ass_seta1 extends Thread
{
String msg="";
Ass_seta1(String msg)
{
this.msg=msg;
}
public void run()
{
try
{ while(true)
{
System.out.println(msg);
Thread.sleep(200);
}
}
catch(Exception e){}
}
}
public class seta1
{
public static void main(String a[])
{
Ass_seta1 t1=new Ass_seta1("Hello............");
t1.start();
}
}

/******************************output***************************
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
Hello............
-------------------------------------------------------------*/
*******************************************************************************

/***************************************************************
NAME     :
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :

Define a thread called “PrintText_Thread” for printing text on command prompt forn number of times. Create three threads and run them. Pass the text and n as parameters to the thread constructor. Example:
i.   First thread prints “I am in FY” 10 times
ii. Second thread prints “I am in SY” 20 times
iii. Third thread prints “I am in TY” 30 times
***************************************************************/

import java.io.*;
import java.lang.String.*;

class Ass_seta3 extends Thread
{
String msg="";
int  n;
Ass_seta3(String msg,int n)
{
this.msg=msg;
this.n=n;
}
public void run()
{
try
{ for(int i=1;i<=n;i++)
{
System.out.println(msg+" "+i+" times");
}
}
catch(Exception e){}
}
}
public class seta3
{
public static void main(String a[])
{
int n=Integer.parseInt(a[0]);
Ass_seta3 t1=new Ass_seta3("I am in FY",n);
t1.start();
Ass_seta3 t2=new Ass_seta3("I am in SY",n+10);
t2.start();
Ass_seta3 t3=new Ass_seta3("I am in TY",n+20);
t3.start();
}
}


**********************************************************************************


/***************************************************************
NAME     :
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :
Define a thread to move a ball inside a panel vertically.The Ball should be created when user clicks on the Start Button. Each ball should have a different color and vertical position(calculated randomly). Note: Suppose user has clicked buttons 5 times then five balls should be created and move inside the panel. Ensurethat ball is moving within the panel border only.
***************************************************************/

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

class boucingthread extends JFrame implements Runnable
{
Thread t;
int x,y;

boucingthread()
{
super();
t= new Thread(this);
x=10;
y=10;
t.start();
setSize(1000,200);
setVisible(true);
setTitle("BOUNCEING BOLL WINDOW");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void run()
{
try
{
while(true)
{
x+=10;
y+=10;
repaint();
Thread.sleep(1000);
}
}catch(Exception e)
{

}
}

public void paint(Graphics g)
{

g.drawOval(x,y,7,7);

}

public static void main(String a[])throws Exception
{
boucingthread t=new boucingthread();
Thread.sleep(1000);
}
}



***************************************************************************************





Sem 2 JAVA Swings


/***************************************************************
NAME     :
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. :
Write a Java program to display “Hello 2D Graphics” using various fonts and sizes.
***************************************************************/

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

 class seta1 extends JFrame
 {
   seta1()
  {
   setVisible(true);
   setSize(500,500);
   setTitle("Hello Graphics");
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }

   public  void paint(Graphics g)
  {
    g.setFont(new Font("Arial",Font.BOLD,40));
    g.drawString("Hello 2D Graphics",20,70);
    g.setFont(new Font("Times new roman",Font.ITALIC,50));
    g.drawString("Hello 2D Graphics",20,200);
    g.setFont(new Font("Times new roman",Font.PLAIN,50));
    g.drawString("Hello 2D Graphics",20,350);

  }

  public static void main(String a[])
 {
   new seta1();
 }
 }
**********************************************************************************

/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 

Write a program to list all machine fonts and their font metrics.
***************************************************************/

 import java.awt.*;
 import javax.swing.*;
 
  class seta2 extends JFrame
 {
    seta2()
   {
    setVisible(true);
    setTitle("font family");
    setSize(500,500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   }

    public void paint(Graphics g)
   {
    GraphicsEnvironment g1= GraphicsEnvironment.getLocalGraphicsEnvironment();
     String s[]=g1.getAvailableFontFamilyNames();
     FontMetrics fm=g.getFontMetrics();
     int x=fm.getHeight();
     Font f=fm.getFont();
     g.drawString("height="+x+"font="+f.getFontName(),10,40);
     int y=50;
     for(int i=0;i<s.length;i++)
     {
      g.drawString(s[i],10,y);
       y=y+15;
     }
   }
  
   public static void main(String a[])
  {
   new seta2();
  }
 }
************************************************************************************

/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 

Write a Java program to obtain the information of the current font used by the graphics object and displays the information about that font on a screen. ***************************************************************/

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

  class seta3 extends JFrame
 {
    seta3()
   {
    setVisible(true);
    setTitle("font family");
    setSize(500,500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   }

    public void paint(Graphics g)
   {
     Font f=g.getFont();
     g.setFont(new Font("Arial",Font.PLAIN,20));
     g.drawString("font name="+f.getFontName(),30,50);
     g.drawString("font size="+f.getSize(),20,70);
     g.drawString("font family="+f.getFamily(),20,90);
     g.drawString("font style="+f.getStyle(),20,200);
     g.drawString("font logical name="+f.getName(),20,400);
   }

   public static void main(String a[])
  {
   new seta3();
  }
 }     
**********************************************************************************

/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 
Write a program to accept the name of an image (using file open dialog) and display it on a panel such that it occupies the whole panel area. ***************************************************************/

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

  class seta4 extends JFrame implements ActionListener
 {  
    JPanel p=new JPanel();
    JButton b=new JButton("open");
    Image img;    //object image
    int a=1;
   
    seta4()
   {
    setLayout(new FlowLayout());
    add(b);
    add(p);
    b.addActionListener(this);
    setVisible(true);
    setTitle("font family");
    setSize(500,500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   }

    public void actionPerformed(ActionEvent e)
   {
    try
    {
     FileDialog f=new FileDialog(this,"open");
      f.setVisible(true);
     System.out.println("name="+f.getDirectory()+""+f.getFile());
      img=ImageIO.read(new File(f.getDirectory()+f.getFile()));
     
      repaint();
    }
     catch(Exception e1)
     {
      System.out.println("error="+e1);
     }
   }
   
    public void paint(Graphics g)
   {
     if(a==1);
     g.drawImage(img,20,20,null);
   }

   public static void main(String a[])
  {
   new seta4();
  }
 }
************************************************************************************

/***************************************************************
NAME     : 
CLASS    : T.Y.B.Sc(Comp.Sci.)
ROLL NO. : 

Write a Java program to draw the following graphics:
 
***************************************************************/

  import java.awt.*;
  import javax.swing.*;
  import java.awt.geom.*;

  class setb1 extends JFrame 
 {
    setb1()
   {
    setVisible(true);
    setTitle("font family");
    setSize(500,500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   }

    public void paint(Graphics g)
   {
     int x[]={110,150,75};
     int y[]={30,75,75};
     g.drawPolygon(x,y,3);
     g.drawOval(100,50,20,20);
     g.drawRect(75,75,75,100);
     g.drawRect(95,120,30,55);
     g.drawRect(210,65,47,55);
     g.drawRect(210,120,150,55);
     g.drawOval(220,175,20,25);
     g.drawOval(300,175,20,25);    
   }

   public static void main(String a[])
  {
   new setb1();
  }
 }

Sem 2 PHP XML

Movie :

<?xml version="1.0" ?>
<RajashreeProductions>
    <Movie>
        <MovieName>Mujhe Kuch Kehna Hai</MovieName>
        <ActorName>Tushar Kapur</ActorName>
        <ReleaseYear>2003</ReleaseYear>
    </Movie>
      <Movie>
        <MovieName>Jeena Sirf Mere Liye</MovieName>
        <ActorName>Tushar Kapur</ActorName>
        <ReleaseYear>2003</ReleaseYear>
    </Movie>
<Movie>
        <MovieName>Golmal</MovieName>
        <ActorName>Tushar Kapur</ActorName>
        <ReleaseYear>2007</ReleaseYear>
    </Movie>
<Movie>
        <MovieName>Golmal REturns</MovieName>
        <ActorName>Tushar Kapur</ActorName>
        <ReleaseYear>2009</ReleaseYear>
    </Movie>
<Movie>
        <MovieName>Kya Love Story Hai</MovieName>
        <ActorName>Tushar Kapur</ActorName>
        <ReleaseYear>2008</ReleaseYear>
    </Movie>
</RajashreeProductions>
******************************************************************************

<?xml version="1.0" ?>
<?xml-stylesheet type="text/css" href="raj.css" ?>
<RajashreeProductions>
    <Movie>
        <MovieName>Mujhe Kuch Kehna Hai</MovieName>
        <ActorName>Tushar Kapur</ActorName>
        <ReleaseYear>2003</ReleaseYear>
    </Movie>
      <Movie>
        <MovieName>Jeena Sirf Mere Liye</MovieName>
        <ActorName>Tushar Kapur</ActorName>
        <ReleaseYear>2003</ReleaseYear>
    </Movie>
<Movie>
        <MovieName>Golmal</MovieName>
        <ActorName>Tushar Kapur</ActorName>
        <ReleaseYear>2007</ReleaseYear>
    </Movie>
<Movie>
        <MovieName>Golmal REturns</MovieName>
        <ActorName>Tushar Kapur</ActorName>
        <ReleaseYear>2009</ReleaseYear>
    </Movie>
<Movie>
        <MovieName>Kya Love Story Hai</MovieName>
        <ActorName>Tushar Kapur</ActorName>
        <ReleaseYear>2008</ReleaseYear>
    </Movie>
</RajashreeProductions>



//css file

MovieName
{
display:block;
Color:Black;
Font-Family:Copperplate Gothic Light;
Font-Size:16pt;
Font:Bold;
}
ActorName,ReleaseYear
{
display:block;
Color:Red;
Font-Family:Bodoni MT;
Font-Size:12pt;
Font:Bold;
}

*******************************************************************************
<?xml version="1.0" encoding="iso-8859-1" ?>
  <BookInfo>

    <Book Category="technical">   
        <Book_PubYear>2009</Book_PubYear>
        <Book_Title>PRogrammingPHP</Book_Title>
        <Book_Author>dvd</Book_Author>
    </Book>
    <Book Category="Cooking">   
        <Book_PubYear>2009</Book_PubYear>
        <Book_Title>Total Foods</Book_Title>
        <Book_Author>jjj</Book_Author>
    </Book>
    <Book Category="Yoga">   
        <Book_PubYear>2009</Book_PubYear>
        <Book_Title>total Yoga</Book_Title>
        <Book_Author>Ram Dev</Book_Author>
    </Book>
 
</BookInfo>
**********************************************************************************

//book1.xml

<?xml version="1.0" encoding="iso-8859-1" ?>
  <BookInfo>

    <Book Category="technical">   
        <Book_PubYear>2009</Book_PubYear>
        <Book_Title>PRogrammingPHP</Book_Title>
        <Book_Author>dvd</Book_Author>
    </Book>
    <Book Category="Cooking">   
        <Book_PubYear>2009</Book_PubYear>
        <Book_Title>Total Foods</Book_Title>
        <Book_Author>jjj</Book_Author>
    </Book>
    <Book Category="Yoga">   
        <Book_PubYear>2009</Book_PubYear>
        <Book_Title>total Yoga</Book_Title>
        <Book_Author>Ram Dev</Book_Author>
    </Book>
 
</BookInfo>

//book.php

<?php
$xml=simplexml_load_file('book1.xml') or die("can't load");
echo"ok <h1><b><i>books</b></i></h1><br>";

foreach($xml->Book as $v)
{
echo$v->Book_PubYear."<br>";
echo$v->Book_Title."<br>";
echo$v->Book_Author."<br>";
}
?>
******************************************************************************
//cricket.xml

<?xml version="1.0" encoding="iso-8859-1" ?>
  <CricketTeam>

    <Team Country="India">
        <player>Raina</player>
        <runs>5000</runs>
        <wicket>40</wicket>
      </Team>
 </CricketTeam>

//add ele in cricket.xml using php script

<?php
$xml=simplexml_load_file('cricket.xml') or die("can't load");

$s=$xml->addChild('Team');
$s->AddAttribute('Contry','Australia');
$s->addChild('player','ponting');
$s->addChild('runs','12000');
$s->addChild('wicket','25');
header("Content-type:text/xml");
echo $xml->asXML();
?>
********************************************************************






Sem 2 PHP Gaphics

Ass 2 Q1

<?php
$in=imagecreate(500,500)or die("could not create");
$bc=imagecolorallocate($in,255,255,255);
$c=imagecolorallocate($in,255,2,2);
$c1=imagecolorallocate($in,255,255,2);
$c2=imagecolorallocate($in,255,2,255);
$c3=imagecolorallocate($in,2,255,255);
$a=array(400,60,350,120,450,120,400,60);
$a1=array(100,300,70,350,70,400,130,400,130,350,100,300);
$a2=array(350,300,300,350,350,400,400,400,450,350,400,300,350,300);
imagefilledpolygon($in,$a,4,$c);
imagefilledpolygon($in,$a1,6,$c1);
imagefilledpolygon($in,$a2,7,$c2);
imagefilledrectangle($in,50,60,120,120,$c3);

header("content-type:image/png");
imagepng($in);
?>
********************************************************************************
Circle.php

<?php
$i=imagecreate(800,800);
$col=imagecolorallocate($i,255,255,255);

$y=15;
$k=20;
for($j=0;$j<12;$j++)
{
 $r=70+$y;
 $b=10+$y;
 $g=30+$y;
 $c=imagecolorallocate($i,$r,$b,$g);
 imagefilledellipse($i,400,400,300-$k,300-$k,$c);
 $k=$k+20;
 $y=$y+15;
}

$ncol=imagecolorallocate($i,0,0,255);
imagestring($i,30,300,400,"welcome to mind game",$ncol);

header('content-type:image/jpeg');
imagejpeg($i);
imagedestroy($i);
?>
*******************************************************************************
// html file

<html>
<body>
<pre>
<form action="test.php" method="POST"> Create image
Width<input type="text" name="w">
Height<input type="text" name="h"><br>
Text color:<br>
Red:<input type="text" name="r">
Green:<input type="text" name="g">
Blue:<input type="text" name="b"><br>
Text string:<input type="text" name="t"><br>
X Co-ordinat:<input type="text" name="xc">
y Co-ordinat:<input type="text" name="yc"><br>
Shape<select name =shape>
<option>ellipse</option>
<option>rectangle</option>
</select><br>
<input type="submit" value="draw image"><br> </pre> </form>                                                                              </body> </html>


//php file

<?php
  $w=$_POST['w'];
 $h=$_POST['h'];
 $r=$_POST['r'];
 $g=$_POST['g'];
 $b=$_POST['b'];
 $t=$_POST['t'];
 $xc=$_POST['xc'];
 $yc=$_POST['yc'];
 $shape=$_POST['shape'];

 $i=imagecreate(500,500);
 $col=imagecolorallocate($i,255,255,255);
 header('content-type:image/jpeg');

 $ncol=imagecolorallocate($i,$r,$g,$b);
 imagestring($i,10,$xc,$yc,$t,$ncol);
 if($shape=="ellipse")
   imageellipse($i,$xc,$yc,$w,$h,$ncol);
 else
   imagerectangle($i,$xc,$yc,$w,$h,$ncol);
  imagejpeg($i);
  imagedestroy($i);
?>
***************************************************************************
image.php


<?php

<?php

 $i=imagecreatefromjpeg("php.jpeg");
 $x=imagesx($i);
 $y=imagesy($i);

 $icopy=imagecreate($x/4,$y/4);
 imagecopyresized($icopy,$i,0,0,0,0,$x/4,$y/4,$x,$y);

 header('content-type:image/jpeg');
 imagejpeg($icopy,"fe.jpeg");
 imagedestroy($icopy);
?>
?>



Q 4b)

<?php

 $i=imagecreatefromjpeg("fe.jpeg");
 $x=imagesx($i);
 $y=imagesy($i);

 $icopy=imagecreate(2*$x/4,2*$y/4);
 imagecopyresized($icopy,$i,0,0,0,0,2*$x/4,2*$y/4,$x,$y);

 header('content-type:image/jpeg');
 imagejpeg($icopy);
 imagedestroy($icopy);
?>
*********************************************************************************
Computer
<?php

 $i=imagecreate(500,500);
 $col=imagecolorallocate($i,255,255,255);
 $c=imagecolorallocate($i,0,0,0);
 imagerectangle($i,100,100,250,250,$c);
 imagerectangle($i,110,110,240,240,$c);
 imagerectangle($i,70,300,280,260,$c);
 $a=array(70,310,50,370,300,370,280,310,70,310);
 imagepolygon($i,$a,5,$c);
 imagesetthickness($i,5);
 imageline($i,70,320,280,320,$c);
 imageline($i,68,340,282,340,$c);
 imageline($i,64,360,286,360,$c);
 header('content-type:image/jpeg');
 imagejpeg($i,"comp.jpeg");
 imagedestroy($i);
?>
*****************************************************************************

SQUARE


<?
$in=imagecreate(500,500)or die("could not create");
$bc=imagecolorallocate($in,255,255,255);
$c=imagecolorallocate($in,0,0,0);
$c1=imagecolorallocate($in,255,255,255);
imagefilledrectangle($in,30,60,300,250,$c);
imagefilledrectangle($in,50,80,280,230,$c1);
imagefilledrectangle($in,70,100,260,210,$c);
imagefilledrectangle($in,90,120,240,180,$c1);
imagefilledrectangle($in,120,140,220,160,$c);
header("content-type:image/png");
imagepng($in);
?>
**************************************************************************

3 circles :


<?php
$i = imagecreate(200,200);
$col = imagecolorallocate($i,200,200,0);
$col = imagecolorallocate($i,0,0);
$x = 100;
$y = 100;
$w = 50;
$h = 50;
for($cnt = 0; $cnt < 3 ;$cnt ++ )
{
    $y = $y - 10 ;
    $w = $w + 20 ;
    $h = $h + 20;
    imageellipse($i , $x,  $y,  $h, $w, $lcol );
}
header(" content_type:image/jpeg ");
imagejpeg ( $i );
imagedestroy ( $i );
?>