WEB PAGE CREATION
EX.NO
:1
DATE
:
Aim:
To create a web page for displaying the registration
form using dynamic HTML.
Algorithm
:
Step1:
Start the program.
Step2: Create a home
page to displaying the registration form.
Step3: Write the
required html code to create the form.
Step4:
Design the page with styles.
Step5:
Create the link needed for the external web pages.
Step6:
In each link page, display the some content for
particular style sheet.
Step7:
To go to home page click the link home.
Step8:
Stop the program.
Coding:
Main:
<html>
<head>
<title>
krishnan wepage
</title>
<script
type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
Main:
function displaymessage()
{
alert("Updated Successfully");
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
<table width="500"
border="0">
<tr>
<td colspan="2"
style="background-color:green;">
<h1>Main Title of Web Page</h1>
</td>
</tr>
<tr valign="top">
<td style="background-color:#FFD700;width:100px;text-align:top;">
<a href="F:/examples/inline.html
"><b>Inline</b> </a><br />
<a href="F:/examples/embedded.html
">Embedded</a><br />
<a
href="F:/examples/external.html">External</a><br />
<a href="F:/examples/import.html
">Importstylesheet</a><br />
</td>
<td
style="background-color:#EEEEEE;height:700px;width:900px;text-align:top;">
Register Here
</br></br></br>
</br>Name<input
type="text" size="20"
maxlength="40"></br></br>
Gender
<select>
<option selected>choose one</option>
<option>Male</option>
<option>Female</option>
</select></br></br>
</br>Mail Id <input
type="text" size="20"
maxlength="40"></br>
</br>Phone <input
type="text" size="20"
maxlength="40"></br></br>
Address<br>
<textarea wrap="virtual"
name="Comments" rows=7 cols=20
maxlength=50></textarea></br></br>
Hobbies<input type="text"
size="20" maxlength="40"></br></br>
<form>
<input type="button"
value="Submit!" onclick="displaymessage()" />
</form>
</td>
</tr>
<tr>
<td colspan="2"
style="background-color:green;text-align:center;">
Copyright
©jradhakrishnan0107.blogspot.com</td>
</tr>
</table>
</body>
</html>
Inline
style sheet:
<html>
<head>
<title>Inline Style
Sheet</title>
</head>
<body>
<h1 Style="font-family:monotype
corsiva;color:orange">Inline Style sheet:</h1>
<p>
Krishnan </br></br>
Prabakaran</br></br>
Radha</br></br>
<a
href="F:/examples/hghk.html"> back </a>
</p>
</body>
</html>
External
Style sheet
<html>
<head>
<title> External Style
Sheet</title>
<link rel="stylesheet"
type="text/css" href="style.css" />
</head>
<body>
<h1>External Style sheet:</h1>
<center>Indian Cricket Players
<p>
Krishnan </br></br>
Prabakaran</br></br>
Radha</br></br>
</p></center>
<a
href="F:/examples/hghk.html"> back </a>
</body>
</html>
Style
Sheet using import Function
<html>
<head>
<title>Import Style
Sheet</title>
<style>
@import url("style.css");
</style>
</head>
<body bgcolor="orange">
<h1>Import Style sheet:</h1>
<p>
Saurav Ganguly</br></br>
Sachin Tendulakr</br></br>
Rahul
Dravid</br></br>
</p>
<a
href="F:/examples/hghk.html"> back </a>
</body>
</html>
Embedded
style sheet
<html>
<head>
<title> Embedded Style
Sheet</title>
<style type="text/css">
body{font-family: Arial;font-size:12x;}
h1{font-family:
Georgia;font-size:16px;font-weight: bold;color:blue;}
P{font-style:italic;color:red;}
</style>
</head>
<body>
<h1>Embedded Style sheet:</h1>
<p>
Praveen Kumar</br></br>
Irfan Pathan</br></br>
Yusuf Pathan </br></br>
</p>
<a href="F:/examples/hghk.html">
back </a>
</body>
</html>
Css:
body{font-family: Arial;font-size: 12px;}
h1{font-family: Georgia;font-size:
16px;font-weight: bold; color:blue}
P{ font-weight: normal;color:red}
Output:
Result:
Thus
the web page was created successfully using Cascading style sheet and Dynamic
HTML.
Ex.No: 2
Date :
STUDENT INFORMATION USING JDBC
AIM:
To write a java program to
retrieve student information from the database using JDBC Connection.
ALGORITHM:
Step 1: Start the program.
Step 2: Declare the header variables.
Step 3: Create the buffered reader object br as static.
Step 4: Inside the main function include the class
Sun.jdbc.odbc.JdbcOdbcDriver.
Step 5: Create a connection object and get the connection using Driver
Message.
Step 6: Create the statement using the connection object and assign to
statement object.
Step 7: Using switch statement perform
various operations like add, show, delete and exit.
Step 8: Create a result set object and execute the query.
Step 9: Print the value in the database table.
Step 10: Compile and run the program.
Step 11: Stop the program
/*STUDENT INFORMATION
USING JDBC*/
import
java.io.*;
import
java.sql.*;
public class
studd
{
public static BufferedReader br;
public static int opt;
public static void main(String
args[])throws IOException
{
String name,dept,addr;
int sno,regno,no;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:studd");
Statement st=con.createStatement();
PreparedStatement ps=null;
ResultSet rs=null;
BufferedReader br=new
BufferedReader(new InputStreamReader(System.in));
while(opt<4)
{
System.out.printf("\n1.ADD\n2.SHOW\n3.DELETE\n4.EXIT");
System.out.print("\nEnter
your choice:");
opt=Integer.parseInt(br.readLine());
switch(opt)
{
case 1:
name=dept=addr=null;
sno=regno=0;
try
{
System.out.print("\nEnter the
sno:");
sno=Integer.parseInt(br.readLine());
System.out.print("\nEnter the
regno:");
regno=Integer.parseInt(br.readLine());
System.out.print("\nEnter the student
name:");
name=br.readLine();
System.out.print("\nEnter the
department:");
dept=br.readLine();
System.out.print("\nEnter the
address:");
addr=br.readLine();
}
catch(IOException e)
{}
ps=con.prepareStatement("insert
into tudd(sno,regno,name,dept,addr)values(?,?,?,?,?)");
ps.setInt(1,sno);
ps.setInt(2,regno);
ps.setString(3,name);
ps.setString(4,dept);
ps.setString(5,addr);
ps.executeUpdate();
ps.close();
System.out.println("one
record has been updated successfully");
break;
case 2:
rs=st.executeQuery("select
* from studd");
System.out.println("Sno\tRegno\tName\tDept\tAddress");
while(rs.next())
{
System.out.println(rs.getInt("sno")+"\t"+rs.getInt("regno")+"\t"
+rs.getString("name")+"\t"+rs.getString("dept")+"\t"+
rs.getString("addr"));
}
break;
case 3:
System.out.print("\nEnter
the regno to delete:");
no=Integer.parseInt(br.readLine());
st.executeUpdate("delete
* from studd where regno="+no);
System.out.println("\nOne
record has been deleted successfully");
break;
case 4:
System.exit(0);
}
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
OUTPUT:
F:\sathya>javac
studd.java
F:\sathya>java
studd
1.ADD
2.SHOW
3.DELETE
4.EXIT
Enter your
choice:1
Enter the sno:02
Enter the
regno:654
Enter the
student name:Gowri
Enter the
department:MBA
Enter the
address:2,Nehru str,Sathy.
one record has
been updated successfully
1.ADD
2.SHOW
3.DELETE
4.EXIT
Enter your
choice:2
Sno Regno
Name Dept Address
1 123 Kavi
MCA 24,Gandhi str,CBE.
2 654 Gowri
MBA 2,Nehru str,Sathy.
1.ADD
2.SHOW
3.DELETE
4.EXIT
Enter your
choice:3
Enter the regno
to delete:123
One record has
been deleted successfully
1.ADD
2.SHOW
3.DELETE
4.EXIT
Enter your
choice:2
Sno Regno
Name Dept Address
2 654 Gowri
MBA 2,Nehru str,Sathy.
1.ADD
2.SHOW
3.DELETE
4.EXIT
Enter your choice:4
RESULT:
The student information using JDBC has been compiled and successfully executed.
Ex.No : 3
Date :
Date :
STUDENT INFORMATION USING
SERVLET
AIM:
To write a servlet program to manipulate the student information
from the database.
ALGORITHM:
Step 1: Start the program.
Step 2: Create an emp.java
file to perform the operations such as insert, display and
delete.
Step 3: Before compiling
the java program set the class path as given C:\jakarta-tomcat-
5[1].5.4-preconfigured\jakarta-tomcat-5.5.4\common\lib\servlet-api.jar.
Step 4: Compile the java
program and copy the class file from the jdk1.5\bin.
Step 5: Paste the copied
class file to the location.
Step 6: Create main.html
to perform the operation like insertion, deletion, and display in
the web page.
Step 7: Create insert
.html file to insert the data to the database.
Step 8: Create
display.html file to display data from the database.
Step 9: Create delete.html
file to delete data from the database.
Step 10: Create the
stu.mdb database in MS access to store the datas.
Step 11: Make the
connection to the database using ODBC data source.
Step 12: Run the tomcat
server from C:\jakarta-tomcat-5[1].5.4-preconfigured\jakarta-
tomcat-5.5.4\ bin and double
click the startup batch file.
Step 13: Run the main.html
to perform the operations.
Step 14: Stop the tomcat
server.
Step 15: Stop the program.
/*STUDENT INFORMATION
USING SERVLET*/
Main.html
<html>
<head>
<title>student
info</title>
</head>
<body
bgcolor="pink">
<center><br><h1>STUDENT
DATABASE MANIPULATION</h1>
<a
href="insert.html"> INSERT</a><br><br>
<a
href="display.html"> DISPLAY</a><br><br>
<a
href="delete.html"> DELETE</a><br><br>
</center></body>
</html>
Insert.html
<html>
<head>
<title>Insert
an item</title>
</head>
<body
bgcolor="lightgreen">
<form
method="get"
action="http://localhost/servlets-examples/servlet/emp">
<center><h1>Inserting
an item to table</h1></center><br>
<input
type="hidden" name="id" value="1">
<center><table
bgcolor="pink" width=300 height=400 border=1>
<tr>
<td><strong>Regno</strong></td>
<td><center><input
type="text" name="regno"></center></td>
</tr>
<tr>
<td><strong>Name</strong></td>
<td><center><input
type="text" name="name"></center></td>
</tr>
<tr>
<td><strong>Department</strong></td>
<td><center><input
type="text" name="dept"></center></td>
</tr>
<tr>
<td><strong>Mark1</strong></td>
<td><center><input
type="text" name="mark1"></center></td>
</tr>
<tr>
<td><strong>Mark2</strong></td>
<td><center><input
type="text" name="mark2"></center></td>
</tr>
</table></center>
<br>
<center><input
type="submit" name="submit"></center>
</form>
</body>
</html>
Display.html
<html>
<head>
<title>DISPLAYING
ITEMS</title>
</head>
<body>
<form method="GET"
action="http://localhost/servlets-examples/servlet/emp">
<h1>WANT TO DISPLAY ALL ITEMS IN
THE TABLE CLICK
SUBMIT</h1><br>
<input type="hidden"
name="id" value="2">
<input type="submit"
value="submit">
</form>
</body>
</html>
Delete.html
<html>
<head>
<title>Deleting
item</title>
</head>
<body>
<form
method="GET"
action="http://localhost/servlets-examples/servlet/emp">
<center><h1>DELETING
AN ITEM FROM TABLE</h1>
</center><br>
<input
type="hidden" name="id" value="3">
<strong>REG
NO</strong>
<input
type="text" name="regno"/>
<input
type="submit" value="submit">
</form>
</body>
</html>
Emp.java
import java.io.*;
import java.sql.*;
import
javax.servlet.*;
import
javax.servlet.http.*;
public class emp
extends HttpServlet
{
int n;
public void doGet(HttpServletRequest
request,HttpServletResponse response)throws IOException,ServletException
{
PrintWriter
out=response.getWriter();
ResultSet rs=null;
n=Integer.parseInt(request.getParameter("id"));
response.setContentType("text/html");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
c=DriverManager.getConnection("Jdbc:Odbc:stu");
Statement
s=c.createStatement();
switch(n)
{
case 1:int
rno=Integer.parseInt(request.getParameter("regno"));
String
name=request.getParameter("name");
String
dept=request.getParameter("dept");
int
m1=Integer.parseInt(request.getParameter("mark1"));
int
m2=Integer.parseInt(request.getParameter("mark2"));
int
t=m1+m2;
s.executeUpdate("insert
into
stu(regno,name,dept,mark1,mark2,total) values
('"+rno+"','"+name+"','"+dept+"',"+m1+","+m2+","+t+")");
out.println("<h1>An
item is inserted</h1>");
break;
case 2:
rs=s.executeQuery("select * from stu");
out.println("<table
border=1>");
out.println("<tr><th>Regno</th><th>Name</th><th>Dept</th>
<th>Mark1</th><th>Mark2</th><th>Total</th></tr>");
while(rs.next())
{
out.println("<tr><td>"+rs.getInt("regno")+"</td>");
out.println("<td>"+rs.getString("name")+"</td>");
out.println("<td>"+rs.getString("dept")+"</td>");
out.println("<td>"+rs.getInt("mark1")+"</td>");
out.println("<td>"+rs.getInt("mark2")+"</td>");
out.println("<td>"+rs.getInt("total")+"</td></tr>");
}
rs.close();
break;
case 3:
rno=Integer.parseInt(request.getParameter("regno"));
s.executeUpdate("delete
* from stu where regno="+rno);
out.println("<h1>item
is deleted</h1>");
break;
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
OUTPUT:
RESULT:
The program for manipulating student information using servlet
program has been compiled and executed successfully.
Ex. No: 4
Date:
DISPLAYING DATE AND TIME USING UDP
AIM:
To display the date
and time using UDP by creating a java program.
ALGORITHM:
SERVER:
Step 1: Start the program.
Step 2: Declare the necessary header files.
Step 3: Create Datagram Socket object s and pass 8000 as port number.
Step 4: Create Datagram Socket object inpack to receive the data.
Step 5: Using toString function convert date and store in the variable d.
Step 6: Send the date to using outpack object of Datagram Packet to client.
Step 7: Close the connection.
Step 8: Compile and run the program.
Step 9: Stop the program.
/*DISPLAYING DATE AND TIME USING UDP*/
SERVER:
import java.net.*;
import java.io.*;
import
java.util.*;
import
java.lang.*;
public class udps
{
public static void main(String args[])throws
IOException
{
String d;
try
{
DatagramSocket s=new DatagramSocket(8000);
bytedata[]=new byte[100];
DatagramPacket inpack=new DatagramPacket(data,data.length);
s.receive(inpack);
d=new Date().toString();
data=d.getBytes();
DatagramPacket outpack=new
DatagramPacket(data,data.length,inpack.getAddress(),inpack.getPort());
s.send(outpack);
s.close();
}
catch(IOException e)
{
System.out.println(e);
}
}
}
ALGORITHM:
CLIENT:
Step 1: Start the program.
Step 2: Declare the necessary header files.
Step 3: Create Datagram Socket object s and Datagram Packet object outpack
and
inpack.
Step 4: Get the data using getData. Function.
Step 5: Store the time in the variable d.
Step 6: Display the data and close the Datagram Socket..
Step 7: Compile and run the program.
Step 9: Stop the program.
CLIENT:
import java.net.*;
import java.io.*;
import
java.util.*;
import
java.lang.*;
public class udpc
{
public static void main(String
args[])throws IOException
{
String d;
try
{
DatagramSocket s=new DatagramSocket();
DatagramPacket outpack,inpack;
byte data[]=new byte[1024];
outpack=new DatagramPacket
(data,data.length,InetAddress.getLocalHost(),8000);
s.send(outpack);
inpack=new DatagramPacket(data,data.length);
s.receive(inpack);
d=new String(inpack.getData());
System.out.println("Date & Time using
UDP:"+d);
s.close();
}
catch(IOException e)
{
System.out.println(e);
}
}
}
OUTPUT:
RESULT:
The UDP using Date and Time function has been displayed
successfully.
DISPLAYING DATE AND TIME USING TCP
AIM:
To display the date
and time using UDP by creating a java program.
ALGORITHM:
SERVER:
Step 1: Start the program.
Step 2: Declare the necessary header files.
Step 3: Create Server Socket object s and pass 2456 as a port number.
Step 4: Create DataInputStream object
dis to read the data.
Step 5: Using toString function to get date and store in the variable str.
Step 6: Using the getTime function for get time and store in the variable
d.
Step 7: Print the date and time to using the getTime function.
Step 8: Close the connection.
Step 9: Compile and run the program.
Step 10: Stop the program.
SERVER:
import java.io.*;
import java.net.*;
import
java.util.*;
import
java.lang.*;
public class
tcpser
{
public static void main(String
arg[])throws IOException
{
String time;
ServerSocket s=new
ServerSocket(2456);
Socket soc=s.accept();
InputStream
is=soc.getInputStream();
DataInputStream dis=new
DataInputStream(is);
System.out.println(dis.readLine());
time=getTime();
String str=new
String(time.toString());
OutputStream
os=soc.getOutputStream();
PrintStream ps=new
PrintStream(os);
ps.println("Date&Time
is:"+str);
}
public static String getTime()
{
Date d=new Date();
return(d.toString());
}
}
ALGORITHM:
CLIENT:
Step 1: Start the program.
Step 2: Declare the necessary header files.
Step 3: Create Socket object soc and OutputStream object os.
Step 4: Get the data using getInputStream function.
Step 5: Display the data and close the Datagram Socket.
Step 6: Compile and run the program.
Step 7: Stop the program
CLIENT:
mport java.io.*;
import java.net.*;
import
java.util.*;
import
java.lang.*;
public class
tcpcli
{
public static void main(String
args[])throws Exception
{
Socket soc=new
Socket("127.0.0.1",2456);
OutputStream
os=soc.getOutputStream();
PrintStream ps=new
PrintStream(os);
ps.println("What is
the time now.....? ");
InputStream is
=soc.getInputStream();
DataInputStream dis=new
DataInputStream(is);
System.out.println(dis.readLine());
soc.close();
}
}
OUTPUT:
RESULT:
The TCP using Date and Time function
has been displayed successfully.
Ex.No:5
Date :
DOWNLOADING FILES USING FTP
AIM:
To write a java program for
downloading files using FTP.
ALGORITHM:
SERVER:
Step 1: Start the program.
Step 2: Create a class named server.
Step 3: Create a server socket objects and pass 2000 as Port number.
Step 4: Create socket objects and using server socket object call accept
function.
Step 5: Create a Buffered Reader object in and specify as getInputStream().
Step 6: Create a FileInputStream object fin and using that open the file
fname.
Step 7: Using the PrintWriter object out
print data.
Step 8: If value i!=35, break.
Step 9: Close the connection.
Step 10: Compile and run the program.
Step 11: Stop the program.
CODING:
SERVER:
import java.io.*;
import java.net.*;
class ftps
{
public static void main(String
args[])throws IOException
{
char
ch[]=new char[35];
String str;
int i=0,j;
ServerSocket ss=new ServerSocket(2000);
Socket s=ss.accept();
BufferedReader in=new BufferedReader(new
InputStreamReader(s.getInputStream()));
PrintWriter out=new PrintWriter(new BufferedWriter(new
OutputStreamWriter(s.getOutputStream())),true);
String fname=in.readLine();
FileInputStream fin=new FileInputStream(fname);
while(true)
{
for(i=0;i<35;i++)
{
j=fin.read();
ch[i]=(char)j;
if(j==-1)
break;
}
Str=new String(ch,0,i);
out.println(str);
if(i!=35)
break;
}
out.println("EOF");
in.close();
out.close();
s.close();
ss.close();
}
}
ALGORITHM:
CLIENT:
Step 1: Start the program.
Step 2: Create a class named client.
Step 3: Create a Buffered Reader object in1 and in2.
Step 4: Create a socket object s and pass 2000 as port number.
Step 5: Declare the object out as PrintWriter.
Step 6: Enter the source file name.
Step 7: Enter the destination file name.
Step 8: Read the data from the source file using in1 object.
Step 9: Close the socket d the server socket.
Step 10: Compile and run the program.
Step 11: Stop the program.
CODING:
CLIENT:
import java.io.*;
import java.net.*;
class ftpc
{
public static void main(String
args[])throws IOException
{
BufferedReader in1=new BufferedReader(new
InputStreamReader(System.in));
System.out.println("\nEnter the host name,\n U want to
connect:");
Socket s=new Socket(InetAddress.getByName(in1.readLine()),2000);
BufferedReader in2=new BufferedReader(new
InputStreamReader(s.getInputStream()));
PrintWriter out=new PrintWriter(new BufferedWriter(new
OutputStreamWriter
(s.getOutputStream())),true);
System.out.println("\nEnter the source file name:");
out.println(in1.readLine());
System.out.println("\n Enter the destination file name:");
FileOutputStream o=new FileOutputStream(in1.readLine());
String data;
int i=0;
while(true)
{
data=in2.readLine();
if(data.equals("EOF"))
break;
char ch[]=new char[55];
data.getChars(0,data.length(),ch,0);
for(i=0;i<data.length();i++)
{
o.write(ch[i]);
System.out.println(ch[i]);
}
o.close();
in1.close();
in2.close();
out.close();
s.close();
}
}
}
OUTPUT:
SERVER:
CLIENT:
RESULT:
The program in java for downloading files using FTP has been
compiled and executed successfully.
Ex. No: 6
Date:
PERSONAL DATA ENTRY USING JSP
AIM:
To write a JSP program to perform
the personal data entry in Bio-data.
ALGORITHM:
Step 1: Start the program.
Step 2: Create the
Biodata.jsp and Display.jsp file and save it in C:\jakarta-tomcat-
5[1].5.4-preconfigured\jakarta-tomcat-5.5.4\webapps\jsp-examples.
Step 3: Create
Biodata.html and Display.html file to link with the jsp.file
Step 4: Create the
database biodata.mdb to receive the data from database.
Step 5: Make a database
connection by using ODBC data source.
Step 6: Make sure that
field entered in access should be same as the fields given in the
Biodata.jsp file.
Step 7: Run the tomcat
server and double click the startup batch file.
Step 8: Run and stop the
program.
/*PERSONAL DATA ENTRY USING JSP*/
Biodata.html:
<html>
<body
bgcolor="darkolivegreen"
style="font-family:segoescript;">
<form
method="post"
action="http://localhost/jsp-examples/biodata.jsp">
<br>
<font size=5
color="red">
<center><h1
style="color:red;">BIODATA</h1></center>
<br>
<input
type=hidden name="id" value="1">
Name
:<input type="text" name="name"><br>
Email
:<input type="text" name="email"><br>
Phone
:<input type="text" name="phone"><br>
<fieldset
style="width:200;">
<legend style="color:red">Gender</legend>
<input
type="radio" name="gender"
value="male">Male<br>
<input
type="radio" name="gender"
value="female">Female<br>
</fieldset><br>
<fieldset
style="width:200">
<legend
style="color:red">DOB</legend>
<input
type="text" name="date" size="1">
<input
type="text" name="month" size="1">
<input
type="text" name="year" size="1">
</fieldset><br><br>
<select
name="work"
style="color:blue;background-color:olivedrab">
<option
value="student">student
<option
value="Employee">employee
</select><br>
Qualification:
<br>
<input
type="checkbox" name="qu"
value="BE"/>BE<br>
<input
type="checkbox" name="qu" value="ARTS"/>ARTS
<br>
<input
type="checkbox" name="qu"
value="OTHERS"/>OTHERS <br>
<center><input
type="submit" value="submit"><center></font>
</form>
</body>
</html>
Display.html:
<html>
<body
bgcolor="teal">
<form
method="post"
action="http://localhost/jsp-examples/display.jsp">
<br>
<br>
<center>
<h1>Display
all biodata from database</h1>
<input
type="hidden" name="id">
<input
type="submit" value="submit"
style="color:Green;width:100;height:50;">
</center>
</form>
</body>
</html>
Biodata.jsp:
<%@page
language="java"%>
<%@page
import="java.lang.*"%>
<%@page
import="java.io.*"%>
<%@page
import="java.util.*"%>
<%@page
import="java.sql.*"%>
<html>
<body
bgcolor="slategray" style="color:yellow;">
<font size=5
color="red">
<%
String
email=request.getParameter("email");
String
name=request.getParameter("name");
int
phone=Integer.parseInt(request.getParameter("phone"));
String gender=request.getParameter("gender");
String
qualification=request.getParameter("qu");
String
dob=request.getParameter("date")+"."+request.getParameter("month")+"."+request.getParameter("year");
String
work=request.getParameter("work");
%>
<%try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
c=DriverManager.getConnection("Jdbc:Odbc:biodata");
Statement s=c.createStatement();
%>
<%
s.executeUpdate("insert into
biodata(Name,Email,Phone,Gender,DOB,Work,Qualification)values('"+name+"','"+email+"',"+phone+",'"+gender+"','"+dob+"','"+work+"','"+qualification+"')");
%>
<h1>AN ITEM
INSERTED</h1>
<%}
catch(Exception
e){}
%>
</font>
</table>
</body>
</html>
Display.jsp:
<%@page
language="java"%>
<%@page
import="java.lang.*"%>
<%@page
import="java.io.*"%>
<%@page
import="java.util.*"%>
<%@page
import="java.sql.*"%>
<html>
<body
bgcolor="slategray" style="color:yellow;">
<font>
<%try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
c=DriverManager.getConnection("Jdbc:Odbc:biodata");
Statement s=c.createStatement();
ResultSet
rs=s.executeQuery("select * from biodata");
%>
<center><h1>BIODATA<h1><br>
<table
border="1">
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Gender</th>
<th>DOB</th>
<th>Work</th>
<th>Qualification</th>
</tr>
<%while(rs.next()){%>
<tr>
<td><%
out.print(rs.getString("Name"));%></td>
<td><%
out.print(rs.getString("Email"));%></td>
<td><%
out.print(rs.getInt("Phone"));%></td>
<td><%
out.print(rs.getString("Gender"));%></td>
<td><% out.print(rs.getString("DOB"));%></td>
<td><%
out.print(rs.getString("Work"));%></td>
<td><%
out.print(rs.getString("Qualification"));%></td>
</tr>
<%}
rs.close();
}
catch(Exception e){}
%>
</font>
</table>
</center>
</body>
</html>
Ex. No: 7
Date :
ASP USING COMPONENTS
AIM:
To write the program for creating ASP application using components
such as adrotator and browser type.
ALGORITHM:
Step 1: Start the program.
Step 2: Create the
advertisement.asp file for displaying the advertisement using adrotator
component.
Step 3: Create the
broswer.asp file for displaying the various supporting applications of
the current browsing using browser type.
Step 4: Create the ad.txt
file for monitoring the collection of advertisement for
advertisement.asp file.
Step 5: Create the
aspcomp.html page for linking the asp file.
Step 6: Copy and paste the
created files by creating folder in, C:\Inetpub\wwwroot.
Step 7: Now open the html
file and execute.
Step 8: Stop the program.
/*ASP USING COMPONENTS*/
ad.asp:
<html>
<marquee><h1><b><%response.write("Advertisement
Rotator")%></b></h1></marquee>
<br>
<center>
<%
dim a
set
a=server.createObject("mswc.adrotator")
response.write(a.getadvertisement("ad.txt"))
response.write(a.getadvertisement("ad.txt"))
response.write(a.getadvertisement("ad.txt"))
%>
</center>
</html>
ad.txt:
redirect
http:\\localhost\san\ad.asp
width 300
height 300
border
*
1.jpg
this is 1.jpg
4
2.jpg
this is 2.jpg
3
3.jpg
this is 3.jpg
2
aspcomp.html:
<html>
<form
name="f1" method="post" action="http:\\localhost\san\ad.asp">
<h3>Rotation
of Advertisement</h3>
<input
type="submit" value="click">
</form><br><br>
<form
name="f2" method="post"
action="http:\\localhost\san\brow.asp">
<h3>Features
of web browser</h3>
<input
type="submit" value="click">
</form>
</html>
brow.asp:
<html>
<marquee><h1>
<b><%response.write("FEATURES
OF WEB BROWSER")%></b>
</h1></marquee><br>
<%
dim b
set
b=server.createObject("mswc.browsertype")
response.write("Browser
supports java applets:-")%>
<b><%response.write(b.javaapplets)%></b></br>
<%response.write("version
of the browser:-")%>
<b><%response.write(b.version)%></b><br>
<%response.write("Major
version of the browser:-")%>
<b><%response.write(b.majorver)%></b>
<br>
<%response.write("Minor
version of the browser:-")%>
<b><%response.write(b.minorver)%></b>
<br>
<%response.write("Browser
supports ActiveX controls:-")%>
<b><%response.write(b.activexcontrols)%></b>
<br>
<%response.write("Browser
supports frames:-")%>
<b><%response.write(b.frames)%></b>
<br>
<%response.write("Browser
supports tables:-")%>
<b><%response.write(b.tables)%></b>
<br>
<%response.write("operating
system of the browser:-")%>
<b><%response.write(b.platform)%></b>
<br>
<%response.write("browser
runs on windows3.1x:-")%>
<b><%response.write(b.Win16)%></b>
<br>
<%response.write("Browser
still a beta version:-")%>
<b><%response.write(b.beta)%></b>
</html>
RESULT:
The JSP program to perform the
personal data entry in Bio-data has been executed successfully.
No comments:
Post a Comment
PLEASE ENTER THE VALUABLE COMMENTS