webtechnology lab
TRANSCRIPT
![Page 1: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/1.jpg)
Ex.No: HTML PAGES WITH FRAMES, LINKS, TABLESDate :
AIM:
To create a HTML pages with frames, links, tables and other tags.
ALGORITHM:
1. Create a HTML page using <table> tag which displays the content.2. Create another HTML page using <OL>,<UL> and <LI> tags which displays the
content in the list format.3. Create another HTML page with frames which combines more than one HTML
pages.4. Execute the frame page, feel as dynamic page having more than one page in a
single page.
![Page 2: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/2.jpg)
PROGRAM :
frame.html
<html><frameset cols="30%,80%">
<frame src="page1.html"> <frameset rows="45%,65%">
<frame src="page2.html"> <frameset cols="30%,30%"> <frame src="page3.html">
<frame src="page4.html"> </frameset>
</frameset> </frameset></html>
page1.html
<html> <body style="background-color:pink"> <font size="3" color="red"> <h><b>THE KAVERY COLLEGES:<b></h></br> <ul> <a href ="fr1.htm">THE KAVERY ENGINEERING COLLEGE</a></br> </ul> <ul> <h>THE KAVERY POLYTECH</h></br> </ul> <ul> <h>THE KAVERY TEACHER TRAINING</h> </ul><ul> <h>IMPORTANT DETAILS:</h></ul><table border="3" style="background-color:red;"> <tr> <td>CHAIRMAN</td> <td>ELENGOVAN</td> <td>9566754710</td> </tr> <tr> <td>PRINCIPAL</td> <td>VENKATACHALAM</td> <td>9566754710</td>
![Page 3: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/3.jpg)
</tr> <tr> <td>CSE HOD</td> <td>SATHISH</td> <td>9566754710</td> </tr> </table> </html>
page2.html
<html> <body style="background-color:pink;"> <font size="6" face="arial" color="red"> <h><center>THE KAVERY ENGINEERING COLLEGE<center></H> <marquee behaviour="style=" direction="right" scrollamount="10"> <h><center>MECHERI</center></h> </marquee> <h><center>AFFLICATED TO ANNA UNIVERSITY-CHENNAI<center></h> <ul> <h>SELECT<sub> KAVERY </sub>FOR <sub>BRIGHTFUTURE</sub></h> </ul> </body></html>
page3.html
<html> <body style="background-color:pink;"> <font size="3" color="green"> <h><b>THE KAVERY ENGINEERING COLLEGE:<b></H></br> <ul> <h><b><i>COURSE OFFERED:</i></b></H> </ul> <ul> <h><b>UG COURSE:<b></h> <ul> <li>CSE</li> <li>ECE</li> <li>EEE</li> </ul> </ul> <ul> <h><b>PG COURSE:</b></h>
![Page 4: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/4.jpg)
<ul> <li>COMPUTER SCIENCE</li> <li>POWER ELECTRONICS</li> <li>VLSI DESIGN</li> </ul> </ul></html>
Page4.html
<html> <body style="background-color:pink;"> <font size="3" color="green"> <h><b>KAVERY POLYTECH:</h> <ul> <h>COURSE OFFERED:</h> <ul> <li>CSE</li> <li>AUTOMOBILE</li> <li>CIVIL</li> </ul> </ul></html>
![Page 5: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/5.jpg)
OUTPUT:
![Page 6: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/6.jpg)
RESULT:
Thus the given program was coded and executed successfully.
![Page 7: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/7.jpg)
![Page 8: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/8.jpg)
Ex.No:02 HTML WITH INTERNAL AND EXTERNAL CSSDate:
AIM:
To create a HTML page using internal and external CSS
ALGORITHM:
1. Create a simple HTML page.2. Write internal CSS using <style> tag in the same page become internal CSS.3. Create another CSS file using <style> tag with extension .css file, which becomes
external CSS file4. Include the external CSS file in your file.5. Find the style changes on your page.
PROGRAM:
int_ext_css.html
<!--- Internal and External CSS Example---><html><head><link rel="stylesheet" type="text/css" href="exter.css" /><style>h1{ text-align:center;}h2{ font-size:30px; text-align:center;}h3{ font-size:30px; text-align:center;}a.three:link {color:#ff0000;}a.three:visited {color:#0000ff;}a.three:hover {background:#66ff66;}a.three{
![Page 9: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/9.jpg)
font-size:30px; text-align:center;}ul{ font-size:30px; color:red; list-style-type:circle;}h4{
font-size:30px; color:red;}ul.pg{ font-size:30px; color:red; list-style-type:square;}</style></head><body><h1>CMS COLLEGE OF ENGINEERING</h1><h2>NAMAKKAL</h2><h3>AFFLICATED TO ANNAUNIVERSITY</H3><P><a class="three" href="default.asp">UG COURSE:</a></p><ul> <li>COMPUTER SCIENCE</li> <li>CIVIL</li> <li>MECHANICAL</li></ul><h4>PG COURSE:</h4><ul class="pg"> <li>COMPUTER SCIENCE</li> <li>POWER ELECTRONICS</li> <li>VLSI DESIGN</li></ul></body></html>
exter.css<style>head{
![Page 10: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/10.jpg)
}body{background-color:pink;}h1{color:red;}h2{color:red;}h3{color:red;}
</style>
![Page 11: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/11.jpg)
OUTPUT:
RESULT:
Thus the given program was coded and executed successfully.
![Page 12: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/12.jpg)
Ex.No: 3aDate:
DATE COMPARISION USING JAVA SCRIPT
AIM:To create a HTML page using java script to find difference between two dates
ALGORITHM:1. Write a function using java script to set the date.2. Write a function using java script to set the month.3. Write a function using java script to find the difference between two dates.4. Write another function to display all the details in your page.5. Use appropriate tags to display the content on your page.s.
PROGRAM:
datediff.html
<HTML><HEAD><SCRIPT LANGUAGE=JavaScript>
function writeOptions(startNumber, endNumber){
var optionCounter;for (optionCounter = startNumber; optionCounter <= endNumber;
optionCounter++){
document.write('<OPTION value=' + optionCounter + '>' + optionCounter);
}}
function writeMonthOptions(){
var theMonth;var monthCounter;var theDate = new Date();
for (monthCounter = 0; monthCounter < 12; monthCounter++){
theDate.setMonth(monthCounter);theMonth = theDate.toString();theMonth = theMonth.substr(4,3);document.write('<OPTION value=' + theMonth + '>' + theMonth);
![Page 13: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/13.jpg)
}}
function recalcDateDiff() {
var myForm = document.form1;
var firstDay = myForm.firstDay.options[myForm.firstDay.selectedIndex].value;
var secondDay = myForm.secondDay.options[myForm.secondDay.selectedIndex].value;
var firstMonth = myForm.firstMonth.options[myForm.firstMonth.selectedIndex].value;
var secondMonth = myForm.secondMonth.options[myForm.secondMonth.selectedIndex].value;
var firstYear = myForm.firstYear.options[myForm.firstYear.selectedIndex].value;
var secondYear = myForm.secondYear.options[myForm.secondYear.selectedIndex].value;
var firstDate = new Date(firstDay + " " + firstMonth + " " + firstYear);var secondDate = new Date(secondDay + " " + secondMonth + " " +
secondYear);var daysDiff = (secondDate.valueOf() - firstDate.valueOf());daysDiff = Math.floor(Math.abs((((daysDiff / 1000) / 60) / 60) / 24));myForm.txtDays.value = daysDiff;var age=daysDiff/365;myForm.age1.value=Math.floor(age);return true;
}
function window_onload(){
var theForm = document.form1;var nowDate = new Date();theForm.firstDay.options[nowDate.getDate() - 1].selected = true;theForm.secondDay.options[nowDate.getDate() - 1].selected = true;theForm.firstMonth.options[nowDate.getMonth()].selected = true;theForm.secondMonth.options[nowDate.getMonth()].selected = true;theForm.firstYear.options[nowDate.getFullYear()- 1970].selected = true;theForm.secondYear.options[nowDate.getFullYear() - 1970].selected =
true;}
</SCRIPT></HEAD>
<BODY LANGUAGE="JavaScript" onload="return window_onload()">
![Page 14: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/14.jpg)
<FORM NAME="form1"><P>
Select your Date of Birth<BR>
<SELECT NAME="firstDay" SIZE="1" onchange="return recalcDateDiff()">
<SCRIPT LANGUAGE="JavaScript">writeOptions(1,31);
</SCRIPT></SELECT>
<SELECT NAME="firstMonth" SIZE="1" onchange="return recalcDateDiff()">
<SCRIPT LANGUAGE=JavaScript>writeMonthOptions();
</SCRIPT></SELECT>
<SELECT NAME="firstYear" SIZE="1" onchange="return recalcDateDiff()">
<SCRIPT LANGUAGE="JavaScript">writeOptions(1970,2010);
</SCRIPT></SELECT>
</P>
<P>Select End Date<BR>
<SELECT NAME="secondDay" SIZE="1" onchange="return recalcDateDiff()">
<SCRIPT LANGUAGE=JavaScript>writeOptions(1,31);
</SCRIPT></SELECT>
<SELECT NAME="secondMonth" SIZE="1" onchange="return recalcDateDiff()">
<SCRIPT LANGUAGE="JavaScript">writeMonthOptions();
</SCRIPT></SELECT>
<SELECT NAME="secondYear" SIZE="1" onchange="return recalcDateDiff()">
<SCRIPT LANGUAGE="JavaScript">
![Page 15: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/15.jpg)
writeOptions(1970,2010);</SCRIPT>
</SELECT></P>Total difference in days:<INPUT TYPE="text" NAME="txtDays" VALUE="0" size="3">
<p>Your Age is:<INPUT TYPE="text" NAME="age1" VALUE="0" size="2">
</p></FORM>
</BODY></HTML>
![Page 16: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/16.jpg)
OUTPUT:
RESULT:
Thus the given program was coded and executed successfully.
![Page 17: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/17.jpg)
Ex.No: 3bDate:
FORM VALIDATION USING JAVA SCRIPT
AIM: To write a program for form validation using java script.
ALGORITHM:1. Design a page for signup form with rich user interface.2. Write the java script function to validate all mandatory fields on your web page.3. Validation should be done after the submit operation.4. Use appropriate tags to display the contents.5. Make sure the page is working efficiently.
PROGRAM:
signup.html
<html><head>
<title>Student Registration Form</title><script type="text/javascript"><!--function validate(){
if(document.signup.fname.value==""){
alert("Please Enter First Name!");return false;
}if(document.signup.lname.value==""){
alert("Please Enter Last Name!");return false;
}if(document.signup.uname.value==""){
alert("Please Enter User Name!");return false;
}if(document.signup.pword1.value==""){
alert("Please Enter Password!");return false;
}
![Page 18: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/18.jpg)
if(document.signup.pword1.value.length<6){
alert("Please enter min 6 characters!");return false;
}if(document.signup.pword2.value==""){
alert("Please Enter Password again!");return false;
}if(document.signup.pword2.value!
=document.signup.pword1.value){
alert("Password is mismatch. Re-enter password!");return false;
}alert("Details Entered Successfully");display();
}function display(){
document.writeln('<h2>'+"Details Entered..."+'</h2>');document.writeln('<br/><font color="#0066FF">'+"First Name:
"+'</font>'+document.signup.fname.value);document.writeln('<br/><font color="#0066FF">'+"Last Name:
"+'</font>'+document.signup.lname.value);document.writeln('<br/><font color="#0066FF">'+"User Name:
"+'</font>'+document.signup.uname.value);document.writeln('<br/><font color="#0066FF">'+"Country:
"+'</font>'+document.signup.country.value);document.writeln('<br/><font color="#0066FF">'+"Alternate
Email: "+'</font>'+document.signup.aemail.value);}
--></script>
</head><body align="center" bgcolor="grey" ><table width="100%" height="100%"><td colspan="2" width="15%"></td><td colspan="1" bgcolor="#FFFFFF" width="70%" height="100%">
<h1 align="center"><font color="#0066FF">SMail</font></h1><h2 align="center"><font color="#0066FF">New User Signup
Form</font></h2>
![Page 19: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/19.jpg)
<form name="signup" onSubmit="return validate()"><font face="Verdana, Arial, Helvetica, sans-serif" color="#660000"
size="2"><p> *First Name:<input type="text" name="fname"
size="20"> *Last Name:<input type="text" name="lname"
size="20"> </p><p style=" border:"> *User Name:<input type="text"
name="uname" size="20">@smail.com</p><p style=" border:"> *Password : <input
type="password" name="pword1">(min 6 characters)</p><p style=" border:"> *Confirm Password:<input
type="password" name="pword2" size="20"></p><p> Gender :
<input type="radio" name="gen" value="male">Male<input type="radio" name="gen" value="female">Female
</p><p> Country:
<select name="country"><option selected>Select Country</option><option name="country"
value="india">India</option><option name="country"
value="russia">Russia</option><option name="country"
value="france">France</option><option name="country"
value="italy">Italy</option></select>
</p><p> Language Known:<br/>
<input type="checkbox" name="lang" value="tamil">Tamil<br/>
<input type="checkbox" name="lang" value="english">English<br/>
<input type="checkbox" name="lang" value="hindi">Hindi<br/>
<input type="checkbox" name="lang" value="Malayalam">Malayalayam<br/>
</p><p style=" border:"> Alternate Email:<input
type="text" name="aemail" size="20"></p><p align="center"><input type="checkbox" name="agree"
value="agree">I agree the terms and conditions</p><p align="center"><input type="submit" value="Submit"><input
type="Reset" value="Reset"></p>
![Page 20: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/20.jpg)
</font></form>
</td><td colspan="2" width="15%"></td></table></body>
</html>
![Page 21: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/21.jpg)
OUTPUT:
RESULT:
Thus the given program was coded and executed successfully.
![Page 22: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/22.jpg)
Ex.No:4Date:
ONLINE BOOK SHOPPING USING JSP OBJECTS
AIM:To write an online book shopping application using JSP objects.
ALGORITHM:1. Create home, login, registration, profile, catalog and order html pages.2. Create jsp pages which does all business works on the server.3. Use appropriate database to store the details of the books.4. Create tables to store login details and books details.5. Connect the database using odbc.jdbc driver.6. Make changes in the control settings to enable database on your local machine.
PROGRAM:
Main.html
<html><body bgcolor=”pink”><br><br><br><br><br><br><h1 align=”center”>>U>ONLINE BOOK STORAGE</u></h1><br><br><br><h2 align=”center”><PRE><b> Welcome to online book storage. Press LOGIN if you are having id Otherwise press REGISTRATION</b></PRE></h2><br><br><pre><div align=”center”><a href=”/tr/login.html”>LOGIN</a> href=”/tr/login.html”>REGISTRATION</a></div></pre> </body></html>
Login.html
<html> <body bgcolor=”pink”><br><br><br> <form name="myform" method="post" action=/tr1/login.jsp"> <div align="center"><pre> LOGIN ID : <input type="passwors" name="pwd"></pre><br><br> PASSWORD : <input type="password" name="pwd"></pre><br><br> </div> <br><br> <div align="center">
![Page 23: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/23.jpg)
<inputtype="submit"value="ok" onClick="validate()"> <input type="reset" value="clear">
</form> </body> </html>
Re g.html
<html> <body bgcolor="pink"><br><br> <form name="myform" method="post" action="/tr1/reg.jsp"> <div align="center"><pre> NAME :<input type="text" name="name"><br> ADDRESS :<input type="text" name="addr"><br> CONTACT NUMBER : <input type="text" name="phno"><br> LOGIN ID : <input type="text" name="id"><br> PASSWORD : <input type="password" name="pwd"></pre><br><br> </div> <br><br> <div align="center"> <inputtype="submit"value="ok"
onClick="validate()">()"> <input type="reset" value="clear">
</form> </body> </html>
Profile.html
<html> <body bgcolor="pink"><br><br> <form name="myform" method="post" action="/tr1/profile.jsp"> <div align="center"><pre> LOGIN ID : <input type="text" name="id"><br> </pre><br><br> </div> <br><br> <div align="center"> <inputtype="submit"value="ok"
onClick="validate()">()"> <input type="reset" value="clear">
</form> </body> </html>
![Page 24: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/24.jpg)
Catalog.html
<html> <body bgcolor="pink"><br><br><br> <form method="post" action="/tr1/catalog.jsp"> <div align="center"><pre> BOOK TITLE : <input type="text" name="title"><br> </pre><br><br> </div> <br><br> <div align="center"> <inputtype="submit"value="ok"
name=”button1”> <inputtype="reset"value="clear" name=”button2”>
</form> </body> </html>
Order.html
<html> <body bgcolor="pink"><br><br><br> <form method="post" action="/tr1/order.jsp"> <div align="center"><pre> LOGIN ID :<input type="text" name="id"><br> PASSWORD : <input type="password" name="pwd"><br> TITLE :<input type="text" name="title"><br> NO. OF BOOKS : <input type="text" name="no"><br> DATE : <input type="text" name="date"><br> CREDIT CARD NUMBER : <input type="password" name="cno"><br></pre><br><br> </div> <br><br> <div align="center"> <input type="submit" value="ok"
name=”button1”> <input type="reset" value="clear" name=”button2”>
</form> </body> </html>
Login.jsp %@page import=”java.sql.*”% %@page import=”java.io.*”% <%
![Page 25: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/25.jpg)
out.println(“<html><body bgcolor=\”pink\”>”); String id=request.getParameter(“id”); String pwd=request.getParameter(“pwd”); Driver d=new oracle.jdbc.driver.OracleDriver(); DriverManager.registerDriver(d);
Connection con=DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=con.createStatement(); String sqlstmt=”select id,password from login where id=”+id+” and password=”+pwd+””; ResultSet rs=stmt.executeQuery(sqlstmt); int flag=0; while(rs.next()) { flag=1; } if(flag==0) { out.println(“SORRY INVALID ID TRY AGAIN ID<br><br>”); out.println(“ <a href=\”/tr1/login.html\”>press LOGIN to RETRY</a>”); } else { out.println(“VALID LOGIN ID<br><br>”); out.println(“<h3><ul>”);
out.println(“<li><ahref=\”profile.html\”><fontcolor=\”black\”>USER PROFILE</font></a></li><br><br>”);
out.println(“<li><ahref=\”catalog.html\”><fontcolor=\”black\”>BOOKS CATALOG</font></a></li><br><br>”);
out.println(“<li><ahref=\”order.html\”><fontcolor=\”black\”>ORDER CONFIRMATION</font></a></li><br><br>”);
out.println(“</ul>”); } out.println(“<body></html>”); %> Reg.jsp
%@page import=”java.sql.*”% %@page import=”java.io.*”% <%
out.println(“<html><body bgcolor=\”pink\”>”); String name=request.getParameter(“name”);
![Page 26: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/26.jpg)
String addr=request.getParameter(“addr”); String phno=request.getParameter(“phno”); String id=request.getParameter(“id”); String pwd=request.getParameter(“pwd”); int no=Integer.parseInt(phno); Driver d=new oracle.jdbc.driver.OracleDriver(); DriverManager.registerDriver(d);
Connection con=DriverManager.getConnection
(“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”); Statement stmt=con.createStatement(); String sqlstmt=”select id from login”; ResultSet rs=stmt.executeQuery(sqlstmt); int flag=0;
while(rs.next()){ if(id.equals(rs.getString(1))) { flag=1; }}if(flag==1) { out.println(“SORRY LOGIN ID ALREADY EXISTS TRY AGAIN WITH NEW ID <br><br>”); out.println(“<a href=\”/tr1/reg.html\”>press REGISTER to RETRY</a>”); }else{ Statement stmt1=con.createStatement (); stmt1.executeUpdate (“insert into login values (“+name+”,”+addr+”,”+no+”,”+id+”,”+pwd+”)”); out.println (“YOU DETAILS ARE ENTERED <br><br>”); out.println (“<a href =\”/tr1/login.html\”>press LOGIN to login</a>”); } out.println (“</body></html>”);%>
Profile.jsp
<%@page import=”java.sql.*”%> <%@page import=”java.io.*”%> <% out.println (“<html><body bgcolor=\”pink\”>”); String id=request.getParameter(“id”);
![Page 27: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/27.jpg)
Driver d=new oracle.jdbc.driver.OracleDriver(); DriverManager.regiserDriver(d);
Connection con=DriverManager.getConnection
(“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”); Statement stmt=con.createStatement (); String sqlstmt=”select * from login where id=”+id+””; ResultSet rs=stmt.executeQuery (sqlstmt); int flag=0;
while(rs.next()) { out.println (“<div align=\”center\”>”); out.println (“NAME :”+rs.getString(1)+”<br>”); out.println (“ADDRESS :”+rs.getString(2)+”<br>”); out.println (“PHONE NO :”+rs.getString(3)+”<br>”); out.println (“</div>”); flag=1;}if(flag==0) { out.println(“SORRY INVALID ID TRY AGAIN ID <br><br>”); out.println(“<a href=\”/tr1/profile.html\”>press HERE to RETRY </a>”);}out.println (“</body></html>”);%>
Catalog.jsp
<%@page import=”java.sql.*”%> <%@page import=”java.io.*”%> <% out.println (“<html><body bgcolor=\”pink\”>”); String title=request.getParameter (“title”); Driver d=new oracle.jdbc.driver.OracleDriver (); DriverManager.regiserDriver (d); Connection con=
DriverManager.getConnection (“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=con.createStatement (); String sqlstmt=”select * from book where title=”+title+””; ResultSet rs=stmt.executeQuery (sqlstmt); int flag=0;
while(rs.next()) { out.println (“<div align=\”center\”>”);
![Page 28: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/28.jpg)
out.println (“TITLE :”+rs.getString(1)+”<br>”); out.println (“AUTHOR :”+rs.getString(2)+”<br>”); out.println (“VERSION:”+rs.getString(3)+”<br>”); out.println (“PUBLISHER :” +rs.getString(4)+”<br>”); out.println (“COST :” +rs.getString(5)+”<br>”); out.println (“</div>”); flag=1;}if(flag==0) { out.println(“SORRY INVALID ID TRY AGAIN ID <br><br>”); out.println(“<a href=\”/tr1/catalog.html\”>press HERE to RETRY </a>”);}out.println (“</body></html>”);%>
Order.jsp <%@page import=”java.sql.*”%> <%@page import=”java.io.*”%> <% out.println (“<html><body bgcolor=\”pink\”>”); String id=request.getParameter (“id”); String pwd=request.getParameter (“pwd”); String title=request.getParameter (“title”); String count1=request.getParameter (“no”); String date=request.getParameter (“date”); String cno=request.getParameter (“cno”); int count=Integer.parseInt(count1); Driver d=new oracle.jdbc.driver.OracleDriver (); DriverManager.regiserDriver (d); Connection con=
DriverManager.getConnection (“jdbc:oracle:thin:@localhost:1521:orcl”,”scott”,”tiger”);
Statement stmt=con.createStatement (); String sqlstmt=”select id, password from login”; ResultSet rs=stmt.executeQuery (sqlstmt); int flag=0,amount,x;
while(rs.next()) { if(id.equals(rs.getString(1))&& pwd.equals(rs.getString(2))) { flag=1; } }if(flag==0)
![Page 29: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/29.jpg)
{ out.println(“SORRY INVALID ID TRY AGAIN ID <br><br>”); out.println(“<a href=\”/tr1/order.html\”>press HERE to RETRY </a>”);} else{ Statement stmt2=con.createStatement(); String s=”select cost from book where title=”+title+””; ResultSet rs1=stmt2.executeQuery(s); int flag1=0; while(rs1.next()) { flag1=1; x=Integer.parseInt(rs1.getString(1)); amount=count*x; out.println(“AMOUNT :”+amount+”<br><br><br><br>”); Statement stmt1=con.createStatement (); stmt1.executeUpdate(“insert into details (“+id+”,”+title+”,”+amount+”,”+date+”,”+cno+”)”); out.println (“YOU ORDER HAS TAKEN<br>”);}if(flag1==0){ out.println(“SORRY INVALID BOOK TRY AGAIN <br><br>”); out.println(“<a href=\”/tr1/order.html\”>press HERE to RETRY </a>”); }} out.println (“</body></html>”);%>
![Page 30: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/30.jpg)
OUTPUT:
![Page 31: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/31.jpg)
![Page 32: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/32.jpg)
RESULT:
Thus the given program was coded and executed successfully.
![Page 33: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/33.jpg)
Ex.No:5Date:
SIMPLE SERVLET PROGRAMAIM:
To write a simple servlet program using HTTP in java.
ALGORITHM:1. Create a servlet program using http.2. Set classpath where servlet-api.jar file resides.3. Compile the servlet program using javac programname.java4. Place the class file …\Tomcat 5.5\webapps\ROOT\WEB-INF\classes\ folder.5. modify the web.xml file using your servletClassName.6. Invoke the class file using http://localhost:8080/servetClassName from your
browser
PROGRAM:
CmsHome.javaimport java.io.*;import javax.servlet.*;import javax.servlet.http.*;
public class mailamHome extends HttpServlet{ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException { response.setContentType("text/html"); PrintWriter pw = response.getWriter(); pw.println("<html>"); pw.println("<head><title>Hello World</title></title>"); pw.println("<body>"); pw.println("<h1>CMS COLLEGE OF ENGINEERING</h1>"); pw.println("<h2>An ISO 9001:2000 Certified Institution</h2>"); pw.println("<h3>Affliated to Anna University</h3>"); pw.println("</body></html>"); }}
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?><!--<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> -->
![Page 34: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/34.jpg)
<web-app> <servlet> <servlet-name>Mailam</servlet-name> <servlet-class>mailamHome</servlet-class> </servlet> <servlet-mapping> <servlet-name>Mailam</servlet-name> <url-pattern>/mailamHome</url-pattern> </servlet-mapping></web-app>
![Page 35: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/35.jpg)
OUTPUT:
RESULT:
Thus the given program was coded and executed successfully.
![Page 36: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/36.jpg)
Ex.No:06Date:
STUDENT INFORMATION SYTEM USING JSP AND SERVLET
AIM:To develop the student webpage information using java servlet and
JDBC.
ALGORITHM :1. Start the program2. Create main HTML page for student database maintenance3. Select option to do the following operation4. Insertion, search ,delete and modify or update the student recode
Main.html<html><body bgcolor=yellow text=red><div align=center><label><h2>Student database maintenance</h2> </label><TABLE><TR><TD><ahref="http://localhost:7001/student/register.html">REGISTER</a></TD></TR><TR><TD><ahref="http://localhost:7001/student/find3">SEARCH</a></TD></TR><TR><TD><a href="http://localhost:7001/student/viewall">VIEW ALL</a></TD></TR><TR><TD><ahref="http://localhost:7001/student/delete2.html">DELETE</a></TD></TR><!--<TR><TD><ahref="http://localhost:7001/student/update">UPDATE</a></TD></TR>--></table></div></body></html>
Register.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE> registration </TITLE></HEAD><BODY bgcolor=teak text=red><form action="http://localhost:7001/student/register1" method=post><pre>
![Page 37: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/37.jpg)
Enter Id : <input type=text name="id" size=4 ><br>Enter Name : <input type=text name="name" size=20 ><br>Enter Age : <input type=text name="age" size=4 ><br>Enter Branch: <input type=text name="branch" size=10 ><br>Enter Mark1 : <input type=text name="m1" size=4 ><br>Enter Mark2 : <input type=text name="m2" size=4 ><br>Enter Mark3 : <input type=text name="m3" size=4 ><br>Enter Grade : <input type=text name="grade" size=20 ><br>Click : <input type="submit" name="submit" value=register></pre></form></BODY></HTML>
Insert.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE> registration </TITLE></HEAD><BODY bgcolor=teak text=red><form action="http://localhost:7001/student/insert" method=post><pre><div align=center>Enter Id : <input type=text name="id" size=4 ><br>Enter Name : <input type=text name="name" size=20 ><br>Enter Age : <input type=text name="age" size=4 ><br>Enter Branch: <input type=text name="branch" size=10 ><br>Enter Mark1 : <input type=text name="m1" size=4 ><br>Enter Mark2 : <input type=text name="m2" size=4 ><br>Enter Mark3 : <input type=text name="m3" size=4 ><br>Enter Grade : <input type=text name="grade" size=4 ><br><input type="submit" name="submit" value=register></div></pre></form></BODY></HTML>
Delete.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE> DELETE STUDENT RECORD </TITLE></HEAD><BODY bgcolor=yellow text=cyan><form action="http://localhost:7001/student/delete2" method=post><pre>Enter the ID :<input type=text name="idno" size=4 ><br>Click :<input type="submit" name=submit value=delete></pre></form>
![Page 38: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/38.jpg)
</BODY></HTML>
Second.javaimport java.io.*;import javax.servlet.*;import javax.servlet.http.*;import java.sql.*;import java.lang.*;public class second extends HttpServlet{public void doGet(HttpServletRequest req,HttpServletResponseres)throws ServletException,IOException{loginform(res,false);}//goGet()private void loginform(HttpServletResponse res,boolean error)throwsServletException,IOException{res.setContentType("text/html");PrintWriter pr=res.getWriter();pr.println("<html><body bgcolor=blue text=red>");pr.println("<div align=center>");if(error){pr.println("<H2>LOGIN FAILED, PLEASE TRYAGAIN!!!</H2>");}pr.println("<form method=post NAME=FORM>");pr.println("<table><TR><TD><label> please enter your nameand password</label></TR></TD>");pr.println("<TR><TD>Username:<input type=textname=username> ");pr.println("<TR><TD>Password:<input type=passwordname=password><br></TR></TD><hr width=100%></TR></TD>");pr.println("<TR><TD>Press:<input type=submit name=submitvalue=Continue></TR></TD>");pr.println("<TR><TD>clear:<input type=reset name =resetvalue=Clear></TR></TD></TABLE>");pr.println("</form></div></body></html>");}//loginform()public void doPost(HttpServletRequest req,HttpServletResponseres)throws ServletException,IOException{String name=req.getParameter("username");String pass=req.getParameter("password");
![Page 39: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/39.jpg)
if(logindb(name,pass)){RequestDispatcher rd=req.getRequestDispatcher("/main.html");rd.forward(req,res);}else{loginform(res,true);}}//doPost()boolean logindb(String name, String pass){try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connectioncon=DriverManager.getConnection("jdbc:odbc:logindb");Statement s=con.createStatement();String sql="select * from stu where username= '" + name+ "' AND password= '" + pass + "' ";ResultSet rs=s.executeQuery(sql);if(rs.next()){return true;}con.close();}catch(SQLException s){s.printStackTrace();}catch(Exception e){e.printStackTrace();}return false;}//login()};
Register1.java/* INSERTING THE DATA */import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import java.util.*;import java.sql.*;
![Page 40: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/40.jpg)
import java.lang.*;public class register1 extends HttpServlet{public void doPost(HttpServletRequest req,HttpServletResponseres)throws ServletException, IOException{try{res.setContentType("Text/html");PrintWriter pr=res.getWriter();int id=Integer.parseInt(req.getParameter("id"));String name=req.getParameter("name");int age=Integer.parseInt(req.getParameter("age"));String branch=req.getParameter("branch");int m1=Integer.parseInt(req.getParameter("m1"));int m2=Integer.parseInt(req.getParameter("m2"));int m3=Integer.parseInt(req.getParameter("m3"));String grade=req.getParameter("grade");pr.println("<html><body bgcolor=yellow text=red><divalign=center>");Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection con=DriverManager.getConnection("jdbc:odbc:ss");//pr.println("student information are successfully registered");//pr.println("<ahref=http://localhost:7001/student/main.html>goto main page</a>");PreparedStatement pst=con.prepareStatement("Insert intostudata values(?,?,?,?,?,?,?,?) ");pst.setInt(1,id);pst.setString(2,name);pst.setInt(3,age);pst.setString(4,branch);pst.setInt(5,m1);pst.setInt(6,m2);pst.setInt(7,m3);pst.setString(8,grade);pst.executeQuery();pr.println("student information are successfully registered");pr.println("<ahref=http://localhost:7001/student/main.html>goto main page</a>");pr.println("</html></body>");con.commit();}catch(SQLException e){System.out.println(e.getMessage());}
![Page 41: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/41.jpg)
catch(Exception e){e.printStackTrace();}}};
Insert.javaimport javax.servlet.*;import javax.servlet.http.*;import java.io.*;import java.util.*;import java.sql.*;import java.lang.*;public class register extends HttpServlet{public void doPost(HttpServletRequest req,HttpServletResponseres)throws ServletException, IOException{try{res.setContentType("Text/html");PrintWriter pr=res.getWriter();int id=Integer.parseInt(req.getParameter("id"));String name=req.getParameter("name");int age=Integer.parseInt(req.getParameter("age"));String branch=req.getParameter("branch");int m1=Integer.parseInt(req.getParameter("m1"));int m2=Integer.parseInt(req.getParameter("m2"));int m3=Integer.parseInt(req.getParameter("m3"));String grade=req.getParameter("grade");pr.println("<html><body bgcolor=yellow text=red><divalign=center>");Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection con=DriverManager.getConnection("jdbc:odbc:ss");// pr.println("Get connection");PreparedStatement pst=con.prepareStatement("Insert intostudata values(?,?,?,?,?,?,?,?) ");pst.setInt(1,id);pst.setString(2,name);pst.setInt(3,age);pst.setString(4,branch);pst.setInt(5,m1);pst.setInt(6,m2);pst.setInt(7,m3);pst.setString(8,grade);pst.executeQuery();
![Page 42: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/42.jpg)
con.commit();pr.println("student information are successfully registered");pr.println("<ahref=http://localhost:7001/student/main.html>goto main page</a>");pr.println("</html></body>");con.close();}catch(SQLException e){System.out.println(e.getMessage());}catch(Exception e){e.printStackTrace();}}};
Find3.Java
/* SEARCH THE PARTICULAR RECORD */import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import java.util.*;import java.sql.*;import java.lang.*;public class find3 extends HttpServlet{public void doGet(HttpServletRequest req,HttpServletResponse res)throwsServletException, IOException{res.setContentType("Text/html");PrintWriter pr=res.getWriter();pr.println("<html><body bgcolor=black text=green><divalign=center>");pr.println("<form action=http://localhost:7001/student/find3method=post name=form1>");pr.println("<h4>Enter the student ID:</h4><input type=text name=id>");pr.println("<h4>click:</h4><input type=submit name=submitvalue=search>");pr.println("</form></div></body></html>");}public void doPost(HttpServletRequest req,HttpServletResponseres)throws ServletException, IOException{
![Page 43: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/43.jpg)
try{res.setContentType("Text/html");PrintWriter pr=res.getWriter();String id =req.getParameter("id");int idno=Integer.parseInt(id);pr.println("<html><body bgcolor=black text=green><divalign=center>");Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection con=DriverManager.getConnection("jdbc:odbc:ss");//PreparedStatement pst=con.prepareStatement("select * from studata whereID= '" + idno + "' ");PreparedStatement pst=con.prepareStatement("select * from studata whereID= ? ");pst.setInt(1,idno);ResultSet r=pst.executeQuery();while(r.next()){pr.println(r.getInt(1)+"\t"+r.getString(2)+"\t"+r.getInt(3)+"\t"+r.getString(4)+"\t"+r.getInt(5)+"\t"+r.getInt(6)+"\t"+r.getInt(7)+"\t"+r.getString(8));pr.println("<br>");}pr.println("<a href=http://localhost:7001/student/main.html>goto mainpage</a>");pr.println("</html></body>");}catch(SQLException e){System.out.println(e.getMessage());}catch(Exception e){e.printStackTrace();}}};
Delete2.javaimport javax.servlet.*;import javax.servlet.http.*;import java.io.*;import java.util.*;import java.sql.*;import java.lang.*;public class delete2 extends HttpServlet{
![Page 44: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/44.jpg)
public void doPost(HttpServletRequest req,HttpServletResponseres)throws ServletException, IOException{try{res.setContentType("Text/html");PrintWriter pr=res.getWriter();pr.println("<html><body bgcolor=black text=yellow>");String idno=req.getParameter("idno");int id=Integer.parseInt(idno);Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection con=DriverManager.getConnection("jdbc:odbc:ss");pr.println("get connected");//PreparedStatement pst=con.prepareStatement("Delete from studatawhere ID= '" + id + "' ");PreparedStatement pst=con.prepareStatement("Delete from studatawhere ID= ? ");pst.setInt(1,id);pst.executeUpdate();pr.println("<h2>student record is successfully deleted");pr.println("<a href=http://localhost:7001/student/main.html>goto mainpage</a>");pr.println("</html></body>");con.commit();}catch(SQLException e){System.out.println(e.getMessage());}catch(Exception e){e.printStackTrace();}}};
![Page 45: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/45.jpg)
Output:
Studenttable.
![Page 46: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/46.jpg)
![Page 47: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/47.jpg)
![Page 48: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/48.jpg)
RESULT :
Thus student information java script program is successfully completed.
![Page 49: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/49.jpg)
Ex.No:07Date:
SIMPLE XML DOCUMENT FOR CD SHOPAIM:
To create a XML document for the CD-Store.
ALGORITHM:1. Create the XML document using <?xml version="1.0" encoding="ISO-8859-1"?
> tag as the initial tab.2. Create another CSS document which displays the xml document details into
HTML format on the browser.3. Give appropriate style in the CSS document.4. Invoke xml file from your browser.
PROGRAM:
cd_catalog_css.xml
<?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited by XMLSpy® --><?xml-stylesheet type="text/css" href="cd_catalog.css"?><CATALOG>
<CD><TITLE>Empire Burlesque</TITLE><ARTIST>Bob Dylan</ARTIST><COUNTRY>USA</COUNTRY><COMPANY>Columbia</COMPANY><PRICE>10.90</PRICE><YEAR>1985</YEAR>
</CD><CD>
<TITLE>Hide your heart</TITLE><ARTIST>Bonnie Tyler</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>CBS Records</COMPANY><PRICE>9.90</PRICE><YEAR>1988</YEAR>
</CD><CD>
<TITLE>Greatest Hits</TITLE><ARTIST>Dolly Parton</ARTIST><COUNTRY>USA</COUNTRY><COMPANY>RCA</COMPANY><PRICE>9.90</PRICE><YEAR>1982</YEAR>
![Page 50: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/50.jpg)
</CD><CD>
<TITLE>Still got the blues</TITLE><ARTIST>Gary Moore</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Virgin records</COMPANY><PRICE>10.20</PRICE><YEAR>1990</YEAR>
</CD><CD>
<TITLE>Eros</TITLE><ARTIST>Eros Ramazzotti</ARTIST><COUNTRY>EU</COUNTRY><COMPANY>BMG</COMPANY><PRICE>9.90</PRICE><YEAR>1997</YEAR>
</CD><CD>
<TITLE>One night only</TITLE><ARTIST>Bee Gees</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Polydor</COMPANY><PRICE>10.90</PRICE><YEAR>1998</YEAR>
</CD><CD>
<TITLE>Sylvias Mother</TITLE><ARTIST>Dr.Hook</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>CBS</COMPANY><PRICE>8.10</PRICE><YEAR>1973</YEAR>
</CD><CD>
<TITLE>Maggie May</TITLE><ARTIST>Rod Stewart</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Pickwick</COMPANY><PRICE>8.50</PRICE><YEAR>1990</YEAR>
</CD><CD>
<TITLE>Romanza</TITLE><ARTIST>Andrea Bocelli</ARTIST><COUNTRY>EU</COUNTRY><COMPANY>Polydor</COMPANY>
![Page 51: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/51.jpg)
<PRICE>10.80</PRICE><YEAR>1996</YEAR>
</CD><CD>
<TITLE>When a man loves a woman</TITLE><ARTIST>Percy Sledge</ARTIST><COUNTRY>USA</COUNTRY><COMPANY>Atlantic</COMPANY><PRICE>8.70</PRICE><YEAR>1987</YEAR>
</CD><CD>
<TITLE>Black angel</TITLE><ARTIST>Savage Rose</ARTIST><COUNTRY>EU</COUNTRY><COMPANY>Mega</COMPANY><PRICE>10.90</PRICE><YEAR>1995</YEAR>
</CD><CD>
<TITLE>1999 Grammy Nominees</TITLE><ARTIST>Many</ARTIST><COUNTRY>USA</COUNTRY><COMPANY>Grammy</COMPANY><PRICE>10.20</PRICE><YEAR>1999</YEAR>
</CD><CD>
<TITLE>For the good times</TITLE><ARTIST>Kenny Rogers</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Mucik Master</COMPANY><PRICE>8.70</PRICE><YEAR>1995</YEAR>
</CD><CD>
<TITLE>Big Willie style</TITLE><ARTIST>Will Smith</ARTIST><COUNTRY>USA</COUNTRY><COMPANY>Columbia</COMPANY><PRICE>9.90</PRICE><YEAR>1997</YEAR>
</CD><CD>
<TITLE>Tupelo Honey</TITLE><ARTIST>Van Morrison</ARTIST>
![Page 52: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/52.jpg)
<COUNTRY>UK</COUNTRY><COMPANY>Polydor</COMPANY><PRICE>8.20</PRICE><YEAR>1971</YEAR>
</CD><CD>
<TITLE>Soulsville</TITLE><ARTIST>Jorn Hoel</ARTIST><COUNTRY>Norway</COUNTRY><COMPANY>WEA</COMPANY><PRICE>7.90</PRICE><YEAR>1996</YEAR>
</CD><CD>
<TITLE>The very best of</TITLE><ARTIST>Cat Stevens</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Island</COMPANY><PRICE>8.90</PRICE><YEAR>1990</YEAR>
</CD><CD>
<TITLE>Stop</TITLE><ARTIST>Sam Brown</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>A and M</COMPANY><PRICE>8.90</PRICE><YEAR>1988</YEAR>
</CD><CD>
<TITLE>Bridge of Spies</TITLE><ARTIST>T`Pau</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Siren</COMPANY><PRICE>7.90</PRICE><YEAR>1987</YEAR>
</CD><CD>
<TITLE>Private Dancer</TITLE><ARTIST>Tina Turner</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>Capitol</COMPANY><PRICE>8.90</PRICE><YEAR>1983</YEAR>
</CD><CD>
![Page 53: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/53.jpg)
<TITLE>Midt om natten</TITLE><ARTIST>Kim Larsen</ARTIST><COUNTRY>EU</COUNTRY><COMPANY>Medley</COMPANY><PRICE>7.80</PRICE><YEAR>1983</YEAR>
</CD><CD>
<TITLE>Pavarotti Gala Concert</TITLE><ARTIST>Luciano Pavarotti</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>DECCA</COMPANY><PRICE>9.90</PRICE><YEAR>1991</YEAR>
</CD><CD>
<TITLE>The dock of the bay</TITLE><ARTIST>Otis Redding</ARTIST><COUNTRY>USA</COUNTRY><COMPANY>Atlantic</COMPANY><PRICE>7.90</PRICE><YEAR>1987</YEAR>
</CD><CD>
<TITLE>Picture book</TITLE><ARTIST>Simply Red</ARTIST><COUNTRY>EU</COUNTRY><COMPANY>Elektra</COMPANY><PRICE>7.20</PRICE><YEAR>1985</YEAR>
</CD><CD>
<TITLE>Red</TITLE><ARTIST>The Communards</ARTIST><COUNTRY>UK</COUNTRY><COMPANY>London</COMPANY><PRICE>7.80</PRICE><YEAR>1987</YEAR>
</CD><CD>
<TITLE>Unchain my heart</TITLE><ARTIST>Joe Cocker</ARTIST><COUNTRY>USA</COUNTRY><COMPANY>EMI</COMPANY><PRICE>8.20</PRICE><YEAR>1987</YEAR>
![Page 54: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/54.jpg)
</CD></CATALOG>
cd_catalog.css<style>CATALOG{
background-color: #ffffff;width: 100%;
}CD{
display: block;margin-bottom: 30pt;margin-left: 0;
}TITLE{
color: #FF0000;font-size: 20pt;
}ARTIST{
color: #0000FF;font-size: 20pt;
}COUNTRY,PRICE,YEAR,COMPANY{
display: block;color: #000000;margin-left: 20pt;
}</style>
![Page 55: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/55.jpg)
OUTPUT:
RESULT:
Thus the given program was coded and executed successfully.
![Page 56: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/56.jpg)
Ex.No:08Date:
SIMPLE XML DOCUMENT WITH DTDAIM:
To write a DTD for a domain specific XML document to validate the XML file.
ALGORITHM:1. Start the program2. Open an XML file as note.xml, to create detail using3. Various xml attribute list4. Using user defined tags, we can create message.5. Using an external and internaldtd,we create elementlist as #PCDATA for retrieve
the datafield6. Using attribute declaration ,use to retrieve the datafield as more than one time7. Execute the program
PROGRAM:
note.xml
<?xml version="1.0" ?> <!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)>]><note><to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <message>Don't forget me this weekend!</message> </note>
dom.xml
<html><body><h1>Mailam Engineering Collge</h1><p><b>To:</b> <span id="to"></span><br /><b>From:</b> <span id="from"></span><br /><b>Message:</b> <span id="message"></span></p><script type="text/javascript">
![Page 57: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/57.jpg)
if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest() }else { xhttp=new ActiveXObject("Microsoft.XMLHTTP") }xhttp.open("GET","note.xml",false);xhttp.send("");xmlDoc=xhttp.responseXML;
document.getElementById("to").innerHTML=xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;document.getElementById("from").innerHTML=xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;document.getElementById("message").innerHTML=xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;</script>
</body></html>
![Page 58: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/58.jpg)
OUTPUT:
![Page 59: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/59.jpg)
RESULT:
Thus the given program was coded and executed successfully.
![Page 60: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/60.jpg)
Ex.No:09Date:
PARSING AN XML DOCUMENT USING DOM AND SAX PARSERS.
AIM: To Parsing an XML document using DOM and SAX Parsers.
ALGORITHM :Using Dom: 1. Get a document builder using document builder factory and parse the xml file to create a DOM object 2. Get a list of employee elements from the DOM 3. For each employee element get the id, name, age and type. Create an employee value object and add it to the list. 4. At the end iterate through the list and print the employees to verify we parsed it right.
Using Sax: 1. Create a Sax parser and parse the xml 2. In the event handler create the employee object 3. Print out the data
PROGRAM: employees.xml
<?xml version="1.0" encoding="UTF-8"?><Personnel><Employee type="permanent"><Name>Seagull</Name><Id>3674</Id><Age>34</Age></Employee><Employee type="contract"><Name>Robin</Name><Id>3675</Id><Age>25</Age></Employee><Employee type="permanent"><Name>Crow</Name><Id>3676</Id><Age>28</Age></Employee></Personnel>
Using DOMDomParserExample.java
![Page 61: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/61.jpg)
a) Getting a document builderprivate void parseXmlFile(){DocumentBuilderFactory dbf =DocumentBuilderFactory.newInstance();try {DocumentBuilder db = dbf.newDocumentBuilder();XML filedom = db.parse("employees.xml");}catch(ParserConfigurationException pce) {pce.printStackTrace();}catch(SAXException se) {se.printStackTrace();}catch(IOException ioe) {ioe.printStackTrace();}}
b) Get a list of employee elements
Get the rootElement from the DOM object.From the root element get allemployee elements. Iterate through each employee element to load the data.private void parseDocument(){Element docEle = dom.getDocumentElement();NodeList nl = docEle.getElementsByTagName("Employee");if(nl != null && nl.getLength() > 0) {for(int i = 0 ; i < nl.getLength();i++) {Element el = (Element)nl.item(i);Employee e = getEmployee(el);myEmpls.add(e);}}}
c) Reading in data from each employee.
private Employee getEmployee(Element empEl) {String name = getTextValue(empEl,"Name");int id = getIntValue(empEl,"Id");int age = getIntValue(empEl,"Age");String type = empEl.getAttribute("type");Employee e = new Employee(name,id,age,type);return e;}private String getTextValue(Element ele, String tagName) {String textVal = null;NodeList nl = ele.getElementsByTagName(tagName);
![Page 62: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/62.jpg)
if(nl != null && nl.getLength() > 0) {Element el = (Element)nl.item(0);textVal = el.getFirstChild().getNodeValue();}return textVal;}private int getIntValue(Element ele, String tagName) {return Integer.parseInt(getTextValue(ele,tagName));}d) Iterating and printing.private void printData(){System.out.println("No of Employees '" + myEmpls.size() +"'.");Iterator it = myEmpls.iterator();while(it.hasNext()) {System.out.println(it.next().toString());}}
Using Sax:SAXParserExample.java
a) Create a Sax Parser and parse the xml
private void parseDocument() {SAXParserFactory spf = SAXParserFactory.newInstance();try {SAXParser sp = spf.newSAXParser();sp.parse("employees.xml", this);}catch(SAXException se) {se.printStackTrace();}catch(ParserConfigurationException pce) {pce.printStackTrace();}catch (IOException ie) {ie.printStackTrace();}}
b) In the event handlers create the Employee object and call the corresponding setter methods.
public void startElement(String uri, String localName, StringqName,Attributes attributes) throws SAXException {tempVal = "";if(qName.equalsIgnoreCase("Employee"))
![Page 63: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/63.jpg)
{tempEmp = new Employee();tempEmp.setType(attributes.getValue("type"));}}public void characters(char[] ch, int start, int length) throwsSAXException {tempVal = new String(ch,start,length);}public void endElement(String uri, String localName,String qName) throws SAXException {if(qName.equalsIgnoreCase("Employee")) {myEmpls.add(tempEmp);}else if (qName.equalsIgnoreCase("Name")) {tempEmp.setName(tempVal);}else if (qName.equalsIgnoreCase("Id")) {tempEmp.setId(Integer.parseInt(tempVal));}else if (qName.equalsIgnoreCase("Age")) {tempEmp.setAge(Integer.parseInt(tempVal));}}
c) Iterating and printing.
private void printData(){System.out.println("No of Employees '" + myEmpls.size() +"'.");Iterator it = myEmpls.iterator();while(it.hasNext()) {System.out.println(it.next().toString());}}
![Page 64: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/64.jpg)
OUTPUT:
Employee Details - Name:Seagull, Type:permanent, Id:3674, Age:34.Employee Details - Name:Robin, Type:contract, Id:3675, Age:25.Employee Details - Name:Crow, Type:permanent, Id:3676, Age:28.
RESULT:
Thus the Parsing an XML document using DOM and SAX Parsers is been done and executed successfully.
![Page 65: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/65.jpg)
Ex.No:10Date:
SAMPLE WEB APPLICATION DEVELOPMENT IN THE OPEN SOURCE ENVIRONMENT WITH DATABASE ACCESS
AIM:
To create Sample web application development in the open sourceenvironment.
ALGORITHM : 1. start the program 2. Inside the asp definiton tag include the html contents 3. include the code for the database connectivity using the ado object 4. select all the datas form the student table 5. Traverse all the tuples in the table 6. Print the datas 7. close the connection 8. stop the program
PROGRAM: access.asp
<% Option Explicit %><html><% DIM nameset con=Server.CreateObject("ADODB.Connection">con.open "dsn=cse;"set rs=Server.Createobject("ADODB.RecordSet")set rs=con.Execute("select * from student where name="&name&")%><table border="," width="50"%><% while NOT rs.EOF %><tr><% for t=0 to 6 %><td><% Response.write(rs(i)) %><% NEXT %></td></tr><% Move Next wend %></table><%con.close%></html> stuaccess.html
<html><form action="access.asp" method="post">Name<input type="text" name="Name"><br><br><input type="submit"><input type="reset">
![Page 66: Webtechnology lab](https://reader037.vdocuments.mx/reader037/viewer/2022102901/554f53e6b4c905423f8b53db/html5/thumbnails/66.jpg)
</form></html>
OUTPUT:
RESULT :
Thus the Sample web application development in the open source nvironment has been executed successfully executed.