Webtech Record
Webtech Record
First frame:
<HTML>
<Head>
<title>
first page of html
</title>
</head>
<body>
<h1><b><i><u>this is my first lab of html</b></i></u></h1>
</body>
<html>
Second frame:
<html>
<head>
<title>
ordered and unoredered lists
</title>
2
</head>
<body>
<ol type=1>
<li>b-tech </li>
<li> mca </li>
<li> mba </li>
</ol>
<ul>
<li> cse </li>
<li> it </li>
<li> ece </li>
<li> eee </li>
</ul>
</body>
<html>
3
Output:
4
Output :
6
if((f.c3.checked!=true)&&(f.c2.checked!=true)&&(f.c1.checked!=true))
{
window.alert(" select a checkbox");
}
}
function check_radio()
{
if((f.c1[0].checked!=true)&&(f.c1[1].checked!=true)&&(f.c1[2].checked!=true))
{
window.alert("select only one option");
}
}
}
</script>
<body>
<form name="f" method="get">
<body bgcolor="pink">
<h1 align=center >REGISTRATION FORM</h1>
username:<input type="text" name=txtname size=30>
<br>
email id:<input type="text" name=txtuser size=30 onBlur="check()">
<br>
password:<input type="password" name=txtpwd size=30 >
<br>
confirmpassword:<input type="password" name=txtconfpwd size=20 onBlur=" text_box()"><br>
<h1><u>HOBBIES</u></h1>
cricket:<input type="checkbox" name=c1>
<br>
hockey:<input type="checkbox" name=c2>
<br>
baseball:<input type="checkbox" name=c3 onBlur="button_check()">
8
<br>
<h1><u>course</u></h1>
b-tech:<input type="radio" name=c1>
<br>
mba:<input type="radio" name=c1>
<br>
mca:<input type="radio" name=c1 onBlur="check_radio()">
<br>
<br>
<b>CITY</b>:<select type=city>
<option>hyd </option>
<option>vijayawada </option>
<option>kurnool</option>
<option>anatapur</option></select>
<br>
<center>
<input type="button" name="b" value="enter">
<input type=reset value=cancel name=b2></center>
</form>
</body>
</html>
9
Output:
10
Output:
email id:[email protected]
</p>
<a href="online.html"><u>homepage</u></a></li>
</body>
</html>
Output:
13
</body>
</html>
Output:
15
Output:
17
Output:
19
Output:
21
Output:
23
Output:
25
Source code:
CSS file:
a:hover{text-decoration:underline;color:red;background-color:blue}
h1 em{color:red}
li em{color:yellow;background-color:red;font-weight:bold}
ul {margin-left:2cm;color:red}
ul ul{text-decoration:underline;margin-left:1.5cm;color:yellow}
HTML file:
<html>
<head>
<title>external</tilte>
<link type="text/css" rel="stylesheet" href="file.css">
</head>
<h1>courses offered in <em>DRKIST</em></h1>
<ul>
<li>
mca</li>
<li>
b-tech
<ul>
<li>cse</li>
<li>ece</li>
<li>eee</li>
</ul>
</li>
<li>mba</li>
<li>m-tech</li>
26
Output:
29
30
Source code:
<html>
<head>
<title> max & min </title>
<script language="javascript">
var max,min,i,j,l,temp,n;
n=new Array(10);
for(i=0;i<n.length;i++)
{
n[i]=parseInt(window.prompt("enter element "+i+""));
}
document.writeln("array elements before sorting are:");
document.writeln("<br>");
for(i=0;i<n.length;i++)
{
document.writeln(""+n[i]+",");
}
for(i=0;i<n.length;i++)
{
for(j=i+1;j<n.length;j++)
{
if(n[i]>n[j])
{
temp=n[i];
n[i]=n[j];
n[j]=temp;
}
31
document.writeln("<br>");
document.writeln("array elements after sorting are:");
for(i=0;i<n.length;i++)
{
document.writeln(","+n[i]+"");
}
document.writeln("<br>");
document.writeln("max element is "+n[9]+"");
document.writeln("<br>");
document.writeln("min element is "+n[0]+"");
document.writeln("<br>");
k=parseInt(window.prompt("enter element to be searched:","0"));
document.writeln("<br>");
for(i=0;i<n.length;i++)
{
j=i+1;
if(k==n[i])
{
l=1;
document.writeln("element found at position "+j+"");
}
}
if(l!=1)
document.writeln("element not found");
</script>
32
Output:
33
34
35
Source code:
<html>
<head>
<title>
multiplication table
</title>
<script language="javascript">
var num;
first=window.prompt("enter number:");
var n1=parseInt(first);
document.writeln("<h1 align=center>multiplication table</h1>");
document.writeln("<table border=1 align=center width=20%>");
for(var i=1;i<=10;i++)
document.writeln("<tr><td>"+n1+"</td><td>"+i+"</td><td>"+mult(i)+"</td></tr>");
document.writeln("</table>");
function mult(i)
{
if(i<1)
return 1;
else
return n1*i;
}
</script>
</head>
</html>
36
Output:
37
Source code:
<html>
<head>
<title>
web page
</title>
<script language="javascript">
document.writeln("<h1>factorial of 1 to 10 numbers</h1>");
document.writeln("<table border='2' width='10%'>");
for(var i=1;i<=10;i++)
document.writeln("<tr><td>"+i+"</td><td>"+fact(i)+"</td></tr>");
document.writeln("</table>");
function fact(i)
{
if(i<=1)
return 1;
else
return i*fact(i-1);
}
</script>
</head>
<body bgcolor="yellow">
</body>
</html>
38
Output:
39
Output:
41
11.Aim:Validating a checkbox
Source code:
<html>
<head>
<title> validating checkbox </title>
<script language="javascript">
function button_check()
{
if((f.c3.checked!=true)&&(f.c2.checked!=true)&&(f.c1.checked!=true))
{
window.alert(" select a checkbox");
}
}
</script>
<body>
<form name="f">
<input type="checkbox" name=c1>playing <br>
<input type="checkbox" name=c2>reading <br>
<input type="checkbox" name=c3>studying <br>
<input type="button" name="b" value="enter" onBlur="button_check()">
</body>
</html>
42
Output:
43
Output:
45
}
}
</script>
<body>
<form name="f" method="get">
password:<input type="password" name=txtpwd size=20><br>
confirmpassword:<input type="password" name=txtconfpwd size=20><br>
<input type="button" name="b" value="enter" onBlur="text_box()">
</form>
</body>
</html>
46
Output:
47
Source code:
<html>
<head>
<title>
Email validation
</title>
<script language="javascript">
document.writeln("validation");
function check()
{
if((f.txtname.value.indexOf("."))-(f.txtname.value.indexOf("@"))<=1||
(f.txtname.value.indexOf("@"))==0)
{
window.alert("invalid email id");
f.txtname.value="";
f.txtname.focus();
}
}
</script>
<body>
<form name="f" method="get">
email id:<input type="text" name="txtname" size=20 onBlur="check()"><br>
password:<input type="password" name=pwd size=20 ><br>
</form>
</body>
</html>
48
Output:
49
Source code:
</customer>
<customer>
<name>
<last_name>asdf</last_name>
<first_name>asde</first_name>
</name>
<date>Aug 26th 2009</date>
<order>
<item>
<product>pens</product>
<quantity>50</quantity>
<price>5000</price>
</item>
</order>
</customer>
<customer>
<name>
<last_name>def</last_name>
<first_name>abc</first_name>
</name>
<date>Aug 27th 2009</date>
</customer>
51
Output:
52
Source code:
<!ELEMENT DOCUMENT (customer)*>
<!ELEMENT customer (name,date,order)>
<!ELEMENT name (last_name,first_name)>
<!ELEMENT last_name (#PCDATA)>
<!ELEMENT first_name (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT order (items)*>
<!ELEMENT item (product,quantity,price)>
<!ELEMENT product (#PCDATA)>
<!ELEMENT quantity (#PCDATA)>
<!ELEMENT price (#PCDATA)>
XML file:
<DOCUMENT>
<customer>
<name>
<last_name>def</last_name>
<first_name>abc</first_name>
</name>
<order>
<item>
<product>books</product>
53
<quantity>5</quantity>
<price>500</price>
</item>
</order>
</customer>
<customer>
<name>
<last_name>asdf</last_name>
<first_name>asde</first_name>
</name>
<order>
<item>
<product>pens</product>
<quantity>50</quantity>
<price>5000</price>
</item>
</order>
</customer>
<customer>
<name>
<last_name>def</last_name>
54
<first_name>abc</first_name>
</name>
<order>
<item>
<product>bags</product>
<quantity>15</quantity>
<price>2500</price>
</item>
</order></customer>
</DOCUMENT>
55
Output:
56
Source code:
<students>
<student>
<stuno>101</stuno>
<stuname>raghu</stuname>
<dept>cse</dept>
<marks>100</marks>
</student>
<student>
<stuno>102</stuno>
<stuname>dileep</stuname>
<dept>cse</dept>
<marks>99</marks>
</student>
<student>
<stuno>103</stuno>
<stuname>vijay</stuname>
<dept>cse</dept>
<marks>99</marks>
</student>
57
<student>
<stuno>104</stuno>
<stuname>pradeep</stuname>
<dept>cse</dept>
<marks>100</marks>
</student>
<student>
<stuno>105</stuno>
<stuname>pradeep</stuname>
<dept>cse</dept>
<marks>100</marks>
</student>
<student>
<stuno>106</stuno>
<stuname>shashi</stuname>
<dept>cse</dept>
<marks>100</marks>
</student>
<student>
<stuno>107</stuno>
<stuname>venky</stuname>
58
<dept>cse</dept>
<marks>100</marks>
</student>
<student>
<stuno>108</stuno>
<stuname>bharath</stuname>
<dept>cse</dept>
<marks>99</marks>
</student></students>
HTML file:
<html>
<head>
<title>
student record
</title>
<script language="javascript">
function fun_first()
{
p.recordset.moveFirst();
}
function fun_next()
{
p.recordset.moveNext();
if(p.recordset.EOF)
{
window.alert("it is last record");
}
}
59
function fun_last()
{
p.recordset.moveLast();
}
function fun_previous()
{
p.recordset.movePrevious();
if(p.recordset.BOF)
{
window.alert("it is frist record");
}
}
</script>
<body>
<form name="f">
<xml id="p" src="stud.xml">
</xml>
studentno:<input type="text" name="t1" datafld="stuno" datasrc="#p"><br>
studentname:<input type="text" name="t2" datafld="stuname" datasrc="#p"><br>
dept:<input type="text" name="t3" datafld="dept" datasrc="#p"><br>
studentmarks:<input type="text" name="t4" datafld="marks" datasrc="#p"><br>
<input type="button" value="first" name="first" onClick="fun_first()">
<input type="button" value="last" name="last" onClick="fun_last()">
<input type="button" value="previous" name="previous" onClick="fun_previous()">
<input type="button" value="next" name="next" onClick="fun_next()">
</form>
</body>
</html>
60
Output:
61
62
Source code:
name
{
font-family:"Times New Roman";
font-size="8pt";
color:"black";
}
date
{
font-family:"Verdana";
font-size="16 pt";
color:"blue";
}
orders
{
font-family:"Monotype Corsiva";
font-size="24 pt";
color:"green";
}
XML file:
<?xml version ="1.0" ?>
<?xml-stylesheets Type="text/css" href="styl.css"?>
<Document>
<customer>
<name><last_name>nadella</last_name><first_name>siddhartha</first_name></name>
<date>august 26th 2009</date>
<orders>
<items><product>books</product><quantity>5</quantity><prize>100</prize></items>
63
</orders>
</customer>
<customer>
<name><last_name>AVNK</last_name><first_name>Ravi teja</first_name></name>
<date>august 25th 2009</date>
<orders>
<items><product>books</product><quantity>2</quantity><prize>1000</prize></items>
</orders>
</customer>
</Document>
Output:
64
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema">
<xs:element name="student">
</xs:element>
</xs:schema>
Output:
65
Source Code:-
import java.sql.*;
public class cre
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
int a=st.executeUpdate("create table labwork(eno number,ename
varchar2(20),esal number)");
if(a<=0)
System.out.println("Table created");
else
System.out.println("Table not created");
}
}
OUTPUT:
CMD:
Source Code:-
import java.sql.*;
public class ins
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
Statement st=con.createStatement();
int a=st.executeUpdate("insert into labwork values(111,'aaa',4000)");
int b=st.executeUpdate("insert into labwork values(222,'bbb',6000)");
if(a==1 && b==1)
System.out.println("Error");
else
System.out.println("rows added");
}
}
OUTPUT:
CMD:
C:\student program>java ins
Rows added
SQL:
SQL> select * from labwork;
22.Aim: Jdbc application to select all the rows and all the columns form the
table
Source Code:-
import java.sql.*;
public class sel
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from labwork");
while(rs.next())
System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getInt(3));
}
}
OUTPUT:
CMD:
23.Aim: Jdbc application to update the table with a bonus amount of 200 for
those salaries less than 5000
Source Code:-
import java.sql.*;
public class update
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
Statement st=con.createStatement();
int a=st.executeUpdate("update labwork set esal=esal+200 where esal<5000");
if(a>0)
System.out.println("Table Updated");
else
System.out.println("Error");
}
}
OUTPUT:
CMD:
C:\student program>java update
Table Updated
SQL:
SQL> select * from labwork;
24.Aim: Jdbc application to insert the values into the table through keyboard
Source Code:-
import java.sql.*;
import java.io.*;
OUTPUT:
CMD:
25.Aim: Jdbc application to select all the rows and all the columns form the table through
the key board
Source Code:-
import java.sql.*;
import java.io.*;
public class sel_key
{
public static void main(String args[])throws Exception
{
int no;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the no");
no=Integer.parseInt(br.readLine());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from labwork where eno=”+no+”");
System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getInt(3));
}
}
OUTPUT:
CMD:
C:\student program>java sel_key
Enter the no
111
111 aaa 4000
72
Source Code:-
import java.sql.*;
import java.io.*;
public class del_key
{
public static void main(String args[])throws Exception
{
int no;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the no");
no=Integer.parseInt(br.readLine());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
Statement st=con.createStatement();
int a=st.executeUpdate("delete from labwork where eno="+no+"");
if(a<=0)
System.out.println("Error");
else
System.out.println("Deleted");
}
}
OUTPUT:
CMD:
C:\student program>java del_key
Enter the no
111
Deleted
SQL:
SQL> select * from labwork;
73
27.Aim: Jdbc application to delete the rows from the table using command line arguments
Source Code:-
import java.sql.*;
public class del_key
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
Statement st=con.createStatement();
int a=st.executeUpdate("delete from labwork where eno="+args[0]+"");
if(a<=0)
System.out.println("Error");
else
System.out.println("Deleted");
}
}
OUTPUT:
CMD:
C:\student program>java del_key
Enter the no
222
Deleted
SQL:
SQL> select * from labwork;
28.Aim: Jdbc application to insert the values into the table using prepared statement
Source Code:-
import java.sql.*;
import java.io.*;
public class ins_pre
{
public static void main(String args[])throws Exception
{
int no,sal;
String name;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
}
}
}
OUTPUT:
CMD:
29.Aim: Jdbc application to insert the values into the table using prepared statement
Source Code:-
import java.sql.*;
import java.io.*;
public class sel_pre
{
public static void main(String args[])throws Exception
{
int no;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
CMD:
30.Aim: Jdbc application to delete the rows from the table using prepared statement
Source Code:-
import java.sql.*;
import java.io.*;
public class del_pre
{
public static void main(String args[])throws Exception
{
int no;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
CMD:
C:\student program>java del_pre
Enter the no
79
333
Deleted
SQL:
SQL> select * from labwork;
Source Code:-
import java.sql.*;
import java.io.*;
public class upd_pre
{
public static void main(String args[])throws Exception
{
int no;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
OUTPUT:
CMD:
32.Aim: Jdbc application to insert into the table using callable statement
Source Code:-
import java.sql.*;
import java.io.*;
class ins_call
{
public static void main(String args[])throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
CallableStatement cst=con.prepareCall("{call profirst}");
cst.execute();
System.out.println("Row Added");
}
}
83
OUTPUT:
CMD:
Source Code:-
import java.sql.*;
import java.io.*;
class upd_call
{
public static void main(String args[])throws Exception
{
int no;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number");
no=Integer.parseInt(br.readLine());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
CallableStatement cst=con.prepareCall("{call pro_update(?,?)}");
cst.setInt(1,no);
cst.registerOutParameter(2,Types.INTEGER);
cst.execute();
System.out.println(cst.getInt(2));
}
}
85
OUTPUT:
CMD:
C:\student program>java upd_call
Enter a number
101
1834.5
SQL:
SQL> select * from labwork;
ENO ENAME ESAL
---------- -------------------- ----------
222 bbb 6000
444 ddd 9000
555 eee 4041
101 d 1834.5
86
34.Aim: Jdbc application to delete the form the table using callable statement
Source Code:-
import java.sql.*;
import java.io.*;
class del_call
{
public static void main(String args[])throws Exception
{
int no;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number");
no=Integer.parseInt(br.readLine());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:lab","scott","tiger");
CallableStatement cst=con.prepareCall("{call pro_del(?)}");
cst.setInt(1,no);
cst.execute();
System.out.println("row deleted");
}
}
87
OUTPUT:
CMD:
C:\student program>java del_call
Enter a number
101
row deleted
SQL:
SQL> select * from labwork;
Source Code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class First extends GenericServlet
{
public void service(ServletRequest req,ServletResponse res)throws
IOException,ServletException
{
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
pw.println("<html>");
pw.println("<head>");
pw.println("<title>TOMCAT SERVER</title>");
pw.println("<body>");
pw.println("<h1>Hello</h1>");
pw.println("</body></html>");
pw.close();
}
}
<web-app>
<servlet>
<servlet-name>ser</servlet-name>
<servlet-class>First</servlet-class>
</servlet>
<servlet-mapping>
89
<url-pattern>/ab</url-pattern>
<servlet-name>ser</servlet-name>
</servlet-mapping>
</web-app>
Save it in Deployment folder/WEB-INF.
Output:
90
Source Code:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class httpex extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res)throws
IOException,ServletException
{
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
String nam=req.getParameter("n");
String pas=req.getParameter("p");
pw.println("<html>");
pw.println("<head>");
pw.println("<title>TOMCAT SERVER</title>");
pw.println("<body>");
pw.println(nam);
pw.println(pas);
pw.println("</body>");
pw.close();
}
}
The Needed Xml File is:
<web-app>
<servlet>
<servlet-name>ser</servlet-name>
<servlet-class>httpex</servlet-class>
91
</servlet>
<servlet-mapping>
<url-pattern>/ab</url-pattern>
<servlet-name>ser</servlet-name>
</servlet-mapping>
</web-app>
Needed HTML file is :
<html>
<head>
<title>
Http Servlet
</title>
</head>
<body>
<form method="post" action="http://127.0.0.1:8000/servlet/ab">
username <input type="text" name="n" size=30>
password <input type="password" name ="p" size=30>
<input type="submit" value="submit" name ="p1">
<input type="reset" value="cancel" name ="p2">
</form>
</body>
</html>
92
Output:
93