Post Your Resume

Get short listed & Apply All latest Recruitment’s
Submit Your Resume Here

Sunday, July 6, 2008

Guest Book Application Using Servlets

// guestbk.java //

import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class guestbk extends httpservlet
{
Connection con;
public void doPost(HttpServletRequest req,HttpServletResponse res)
throws
IOException,ServletException
{
PrintWriter out=new PrintWriter(res.getOutputStream());
int ctr=0;
res.setContentType("text/html");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:booksrc","","");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from gbook");
out.println("");
out.println("");
out.println("GuestBook");
out.println("");
out.println("");
out.println("

GUEST BOOK DETAILS


");
out.println("");
while(rs.next())
{
ctr++;
String email=rs.getString("emailid");
String cmt=rs.getString("comment");
out.println("");
}
out.println("
E-Mail
Address
Comment
"+email+""+cmt+"
");
if(ctr==0)
out.println("
No Records Found
");
stmt.close();
con.close();
}
catch(SQLException SQLExcep)
{
System.out.println("error");
}
catch(ClassNotFoundException CNFE)
{
System.out.println("error");
}
out.println("");
out.close();
}
}

// submit.java //
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class submit extends HttpServlet
{
Connection con;
public void doPost(HttpServletRequest req,HttpServletResponse res)
throws
IOException,ServletException
{
String str1,str2;
str1=req.getParameter("emailid");
str2=req.getParameter("comment");
System.out.println(str1);
System.out.println(str2);
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("

Guest Book is Successfully
Updated

");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:booksrc","","");
Statement stmt=con.createStatement();
ResultSet rs;
int i= stmt.executeUpdate("insert into gbook
values('"+str1+"','"+str2+"')");
if(i==1)
{
System.out.println("ok");
}
stmt.close();
con.close();
}
catch(SQLException SQLExcep)
{
System.out.println("error");
}
catch(ClassNotFoundException CNFE)
{
System.out.println("error");
}}
}

//guestbk.htm//


GUEST BOOK










ENTER YOUR EMAIL ADDRESS



COMMENTS ARE ALWAYS WELCOME

















Simple Program in Java to Implement Multithreading

// Multithreading (odd or even)

import java.io.*;
import java.lang.*;
import java.awt.*;
import java.awt.event.*;

class test extends Frame implements ActionListener,Runnable
{
int lower,upper;
Label l1=new Label("ODD");
Label l2=new Label("EVEN");
List lb1=new List();
List lb2=new List();
Button b2=new Button("EXIT");
test(int low,int up)
{
lower = low;
upper = up;
setLayout(new FlowLayout());
setSize(700,700);
setTitle("Thread Demo");
setVisible(true);
add(l1);add(lb1);add(l2);add(lb2);add(b2);
b2.addActionListener(this);
Thread t=new Thread(this);
t.start();


addWindowListener(
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{ System.exit(0); }
}
);

}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b2)
System.exit(0);
}
public void run()
{
try
{
if((lower % 2) != 0)
{
lower = lower + 1;
}
while(lower <= upper)
{
Thread.sleep(1000);
lb2.add(String.valueOf(lower));
lower += 2;
Thread.sleep(500);
}
}catch(Exception e){}
}

public static void main(String args[])
{
int lower,upper;
lower = Integer.parseInt(args[0]);
upper = Integer.parseInt(args[1]);
test ob = new test(lower,upper);

if((lower % 2) == 0)
{
lower = lower + 1;
}

try
{
while(lower <= upper)
{
Thread.sleep(1000);
ob.lb1.add(String.valueOf(lower));
lower = lower + 2;
Thread.sleep(500);
}
}
catch(Exception e){}
}

}

Tuesday, May 27, 2008

Telephone Directory

Code :
/*************************************************************************
PROJECT ON ELECTRONIC DAIRY

MADE BY:-
DIVYA BATRA
XII-A

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

/*************************************************************************
HEADER FILE FUNCTIONS

process.h exit()
dos.h delay()
conio.h clrscr()
gotoxy()
textbackground()
textcolor()
getch()
stdio.h gets()
string.h strcmp()
fstream.h open()
close()
**************************************************************************
*/
#include
#include
#include
#include
#include
#include

//************************************************************************
**
// Structure of telephone directory
//************************************************************************
**

struct tel
{
char telno[20];
char name[20];
char add[20];
}s;

//************************************************************************
**
// Functions
//************************************************************************
**

void display(void);
void enquiryt(void);
void enquiryn(void);
void delet(void);
void option(void);
void des(void);
void box_fill(void);

//************************************************************************
**
// Main Function
//************************************************************************
**

main()
{
clrscr();
textbackground(3);
textcolor(4);
for (int i=1;i<24;i++)
{
clrscr();
gotoxy(i,1);
cprintf(" ***Telephone Directory*** ");
delay(100);
}
for (int o=2;o<7;o++)
{
clrscr();
gotoxy(23,o);
cout<<" ***Telephone Directory*** ";
delay(100);
}
delay(1000);
gotoxy(33,9);
cout<<" Made By:- ";
delay (1000);
gotoxy(31,11);
cout<<" Divya Batra ";
delay(1000);
gotoxy(32,13);
cout<<" Class XII-A ";
delay(1000);
gotoxy(22,15);
cout<<" The Heritage School Vasant Kunj ";
delay(3000);
getch();
option();
}

//************************************************************************
**
// Main Menu
//************************************************************************
**

void option(void)
{
clrscr();
int j;
box_fill();
gotoxy(30,3);
cout<<"***** MAIN MENU *****";
gotoxy(15,6);
cout<<" 1. Add Records. ";
gotoxy(15,8);
cout<<" 2. Get enquiry from telephone number. ";
gotoxy(15,10);
cout<<" 3. Get enquiry from names of person. ";
gotoxy(15,12);
cout<<" 4. Delete Records. ";
gotoxy(15,14);
cout<<" 5. Exit. ";
gotoxy(15,16);
cout<<" Enter your choice:";
cin>>j;
switch(j)
{
case 1:
display();
break;

case 2:
enquiryt();
break;

case 3:
enquiryn();
break;

case 4:
delet();
break;

default:
exit(1);
}
}

void des(void)
{
gotoxy(10,23);
cout<<"
Press any key to see main menu again.....
";
getch();
option();
}
//************************************************************************
**
// Function to create file of people
//************************************************************************
**

void display(void)
{
clrscr();
char ans;
ans='y';
ofstream fp;
fp.open("Tel.dat",ios::app);
do
{
box_fill();
// char ch=cin.get();
gotoxy(13,6);
cout<<" Telephone number:";
gets(s.telno);
gotoxy(13,8);
cout<<" Name of Person:";
gets(s.name);
gotoxy(13,10);
cout<<" Address:";
cin>>s.add;
fp.write((char *)&s,sizeof(tel));
gotoxy(13,12);
cout<<" Do you want to Continue:";
cin>>ans;
}
while(ans=='y');
fp.close();
des();
}

//************************************************************************
**
// Function to get enquiry by telephone from main file
//************************************************************************
**

void enquiryt(void)
{
char v[20];
clrscr();
ifstream fp5;
fp5.open("Tel.dat");
box_fill();
gotoxy(15,10);
cout<<" Enter the desire telephone number:";
cin>>v;
while(fp5)
{
fp5.read((char *)&s,sizeof(tel));
if(!fp5)
break;
if(strcmp(s.telno,v)==0)
{
gotoxy(15,14);
cout<<" Telephone Number: "< gotoxy(15,16);
cout<<" Name: "< gotoxy(15,18);
cout<<" Address: "< }
}
fp5.close();
des();
}

//************************************************************************
**
// Function to get enquiry by name from main file
//************************************************************************
**

void enquiryn(void)
{
char a[20];
clrscr();
ifstream fp5;
fp5.open("Tel.dat");
box_fill();
gotoxy(15,10);
cout<<" Enter the name:";
cin>>a;
while(fp5)
{
fp5.read((char *)&s,sizeof(tel));
if(!fp5)
break;
if(strcmp(a,s.name)==0)
{
gotoxy(15,14);
cout<<" Telephone Number: "< gotoxy(15,16);
cout<<" Name: "< gotoxy(15,18);
cout<<" Address: "< }
}
fp5.close();
des();
}

//************************************************************************
**
// Function to delete any record from main file
//************************************************************************
**

void delet(void)
{
char v[20];
clrscr();
ifstream fp;
fp.open("Tel.dat");
ofstream fp1;
fp1.open("Tel1.dat");
while(fp)
{
fp.read((char *)&s,sizeof(tel));
if(!fp)
break;
fp1.write((char *)&s,sizeof(tel));
}
fp.close();
fp1.close();
ifstream afile;
ofstream bfile;
afile.open("Tel1.dat");
bfile.open("Tel.dat");
box_fill();
gotoxy(14,10);
cout<<" Enter the telephone number to be deleted: ";
cin>>v;
while(afile)
{
afile.read((char *)&s,sizeof(tel));
if(!afile)
break;
if(strcmp(s.telno,v)!=0)
{
bfile.write((char *)&s,sizeof(tel));
}
}
bfile.close();
afile.close();
des();
}

//************************************************************************
**
// Procedure for creating box for menues and prompts
//************************************************************************
**

void box_fill(void)
{
int xr,xc;
int la,ra;
gotoxy(10,2);
for(xr=1;xr<=60;xr++)
cout<<"*";
xc=3;
for(la=1;la<=19;la++)
{
gotoxy(10,xc);
cout<<"()";
gotoxy(69,xc);
cout<<"()";
xc++;
}
gotoxy(10,22);
for(xr=1;xr<=60;xr++)
cout<<"*";
}


Resistor color code reader

Resistor color code reader

Author:- A.Chermarajan.

Author Email:- chermarajan [at] yahoo.co.in

Description:- This program is for resistor color code useful for basic Electronic students.Just mention the color code for resistor program gives the exact value for it. If the value might be greater itself onvert to Kilo or Mega ohm as per.

Code :
#include
#include
#include
#include

void main()
{
start:
clrscr();
int i;
float r=0;
char a[10],b[10],c[10],d[10];
cout<<"_____________________________!Color code Reader
1.0!____________________________";
cout<<"Design by:A.Cherma rajan.BE.,";
cout<<"Enter your Resister colour code here
";
cout<<"Code 1:";
cin>>a;
cout<<"Code 2:";
cin>>b;
cout<<"Code 3:";
cin>>c;

{
if(!(strcmp(a,"black")))
r=0;
else if(!(strcmp(a,"brown")))
r=10;
else if(!(strcmp(a,"red")))
r=20;
else if(!(strcmp(a,"orenge")))
r=30;
else if(!(strcmp(a,"yellow")))
r=40;
else if(!(strcmp(a,"green")))
r=50;
else if(!(strcmp(a,"blue")))
r=60;
else if(!(strcmp(a,"violet")))
r=70;
else if(!(strcmp(a,"gray")))
r=80;
else if(!(strcmp(a,"white")))
r=90;
}

{
if(!(strcmp(b,"black")))
r+=0;
else if(!(strcmp(b,"brown")))
r+=1;
else if(!(strcmp(b,"red")))
r+=2;
else if(!(strcmp(b,"orenge")))
r+=3;
else if(!(strcmp(b,"yellow")))
r+=4;
else if(!(strcmp(b,"green")))
r+=5;
else if(!(strcmp(b,"blue")))
r+=6;
else if(!(strcmp(b,"violet")))
r+=7;
else if(!(strcmp(b,"gray")))
r+=8;
else if(!(strcmp(b,"white")))
r+=9;
}

{
if(!(strcmp(c,"black")))
r*=1;
else if(!(strcmp(c,"brown")))
r*=10;
else if(!(strcmp(c,"red")))
r*=100;
else if(!(strcmp(c,"orenge")))
r*=1000;
else if(!(strcmp(c,"yellow")))
r*=10000;
else if(!(strcmp(c,"green")))
r*=100000;
else if(!(strcmp(c,"blue")))
r*=1000000;
else if(!(strcmp(c,"violet")))
r*=10000000;
else if(!(strcmp(c,"gray")))
r*=100000000;
else if(!(strcmp(c,"white")))
r*=1000000000;
}
cout<<"Colour code value for your Resister:";
if(r/999999>=1)
cout<else if(r/999>=1)
cout<else
cout<
char ch=234,op;
cout<cout<<"

Continue (y/n):";
cin>>op;
if(op=='y')
goto start;
else
exit(1);
getch();
}