SlideShare una empresa de Scribd logo
1 de 65
Ex.No:        HTML PAGES WITH FRAMES, LINKS, TABLES
Date :


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.
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>
    </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>
     <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>
OUTPUT:
RESULT:

     Thus the given program was coded and executed successfully.
Ex.No:02        HTML WITH INTERNAL AND EXTERNAL CSS
Date:


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 file
   4. 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
{
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
{
}
body
{
background-color:pink;
}
h1
{
color:red;
}
h2
{
color:red;
}
h3
{
color:red;
}

</style>
OUTPUT:




RESULT:

     Thus the given program was coded and executed successfully.
Ex.No: 3a
Date:

                  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);
}
        }

        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()">
<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">
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>
OUTPUT:




RESULT:

     Thus the given program was coded and executed successfully.
Ex.No: 3b
Date:

                     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;
                       }
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>
<form name="signup" onSubmit="return validate()">
             <font face="Verdana, Arial, Helvetica, sans-serif" color="#660000"
size="2">
                    <p>&nbsp;&nbsp;*First Name:<input type="text" name="fname"
size="20">
                    &nbsp;&nbsp;*Last Name:<input type="text" name="lname"
size="20"> </p>
                      <p style=" border:">&nbsp;&nbsp;*User Name:<input type="text"
name="uname" size="20">@smail.com</p>
                      <p style=" border:">&nbsp;&nbsp;*Password :&nbsp;<input
type="password" name="pword1">(min 6 characters)</p>
                      <p style=" border:">&nbsp;&nbsp;*Confirm Password:<input
type="password" name="pword2" size="20"></p>
                      <p>&nbsp;&nbsp;Gender :
                              <input type="radio" name="gen" value="male">Male
                              <input type="radio" name="gen" value="female">Female
                      </p>
                      <p>&nbsp;&nbsp;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>&nbsp;&nbsp;Language Known:<br/>
                              &nbsp;&nbsp;<input type="checkbox" name="lang"
value="tamil">Tamil<br/>
                              &nbsp;&nbsp;<input type="checkbox" name="lang"
value="english">English<br/>
                              &nbsp;&nbsp;<input type="checkbox" name="lang"
value="hindi">Hindi<br/>
                              &nbsp;&nbsp;<input type="checkbox" name="lang"
value="Malayalam">Malayalayam<br/>
                      </p>
                      <p style=" border:">&nbsp;&nbsp;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>
</font>
             </form>
       </td>
       <td colspan="2" width="15%">
       </td>
       </table>
       </body>
</html>
OUTPUT:




RESULT:

     Thus the given program was coded and executed successfully.
Ex.No:4
Date:


               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">
<inputtype="submit"value="ok"
  onClick="validate()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset"
  value="clear">
</form>
</body>
</html>

                                 Reg.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()">()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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()">()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset"
 value="clear">
 </form>
 </body>
 </html>
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”>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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”>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset"
    value="clear" name=”button2”>
    </form>
    </body>
    </html>

                                    Login.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”);
      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”);
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”);
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”>”);
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)
{
         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>”);%>
OUTPUT:
RESULT:

   Thus the given program was coded and executed successfully.
Ex.No:5
Date:

                               SIMPLE SERVLET PROGRAM
AIM:
       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.java
  4. Place the class file …Tomcat 5.5webappsROOTWEB-INFclasses 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.java
import 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"> -->
<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>
OUTPUT:




RESULT:

     Thus the given program was coded and executed successfully.
Ex.No:06
Date:


        STUDENT INFORMATION SYTEM USING JSP AND SERVLET

AIM:
        To develop the student webpage information using java servlet and
JDBC.

ALGORITHM :
  1. Start the program
  2. Create main HTML page for student database maintenance
  3. Select option to do the following operation
  4. 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><a
href="http://localhost:7001/student/register.html">REGISTER</a></TD></T
R>
<TR><TD><a
href="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><a
href="http://localhost:7001/student/delete2.html">DELETE</a></TD></TR>
<!--<TR><TD><a
href="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>
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>
</BODY>
</HTML>

                                      Second.java
import 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,HttpServletResponse
res)throws ServletException,IOException
{
loginform(res,false);
}//goGet()
private void loginform(HttpServletResponse res,boolean error)throws
ServletException,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 TRY
AGAIN!!!</H2>");
}
pr.println("<form method=post NAME=FORM>");
pr.println("<table><TR><TD><label> please enter your name
and password</label></TR></TD>");
pr.println("<TR><TD>Username:<input type=text
name=username> ");
pr.println("<TR><TD>Password:<input type=password
name=password><br></TR></TD><hr width=100%></TR></TD>");
pr.println("<TR><TD>Press:<input type=submit name=submit
value=Continue></TR></TD>");
pr.println("<TR><TD>clear:<input type=reset name =reset
value=Clear></TR></TD></TABLE>");
pr.println("</form></div></body></html>");
}//loginform()
public void doPost(HttpServletRequest req,HttpServletResponse
res)throws ServletException,IOException
{
String name=req.getParameter("username");
String pass=req.getParameter("password");
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");
Connection
con=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.*;
import java.lang.*;
public class register1 extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse
res)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><div
align=center>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:ss");
//pr.println("student information are successfully registered");
//pr.println("<a
href=http://localhost:7001/student/main.html>goto main page</a>");
PreparedStatement pst=con.prepareStatement("Insert into
studata 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("<a
href=http://localhost:7001/student/main.html>goto main page</a>");
pr.println("</html></body>");
con.commit();
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
catch(Exception e)
{
e.printStackTrace();
}
}
};
                                        Insert.java
import 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,HttpServletResponse
res)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><div
align=center>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:ss");
// pr.println("Get connection");
PreparedStatement pst=con.prepareStatement("Insert into
studata 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();
con.commit();
pr.println("student information are successfully registered");
pr.println("<a
href=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)throws
ServletException, IOException
{
res.setContentType("Text/html");
PrintWriter pr=res.getWriter();
pr.println("<html><body bgcolor=black text=green><div
align=center>");
pr.println("<form action=http://localhost:7001/student/find3
method=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=submit
value=search>");
pr.println("</form></div></body></html>");
}
public void doPost(HttpServletRequest req,HttpServletResponse
res)throws ServletException, IOException
{
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><div
align=center>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:ss");
//PreparedStatement pst=con.prepareStatement("select * from studata where
ID= '" + idno + "' ");
PreparedStatement pst=con.prepareStatement("select * from studata where
ID= ? ");
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.getSt
ring(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 main
page</a>");
pr.println("</html></body>");
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
catch(Exception e)
{
e.printStackTrace();
}
}
};
                                        Delete2.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.lang.*;
public class delete2 extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse
res)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 studata
where ID= '" + id + "' ");
PreparedStatement pst=con.prepareStatement("Delete from studata
where 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 main
page</a>");
pr.println("</html></body>");
con.commit();
}
catch(SQLException e)
{
System.out.println(e.getMessage());
}
catch(Exception e)
{
e.printStackTrace();
}
}
};
Output:

Studenttable.
RESULT :

     Thus student information java script program is successfully completed.
Ex.No:07
Date:

                   SIMPLE XML DOCUMENT FOR CD SHOP
AIM:
       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>
</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>
<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>
<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>
<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>
</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>
OUTPUT:




RESULT:

     Thus the given program was coded and executed successfully.
Ex.No:08
Date:

                     SIMPLE XML DOCUMENT WITH DTD
AIM:
       To write a DTD for a domain specific XML document to validate the XML file.

ALGORITHM:
  1. Start the program
  2. Open an XML file as note.xml, to create detail using
  3. Various xml attribute list
  4. Using user defined tags, we can create message.
  5. Using an external and internaldtd,we create elementlist as #PCDATA for retrieve
     the datafield
  6. Using attribute declaration ,use to retrieve the datafield as more than one time
  7. 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">
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>
OUTPUT:
RESULT:

     Thus the given program was coded and executed successfully.
Ex.No:09
Date:

          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 DOM
DomParserExample.java
a) Getting a document builder
private void parseXmlFile(){
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
XML file
dom = 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 all
employee 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);
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, String
qName,
Attributes attributes) throws SAXException
{
tempVal = "";
if(qName.equalsIgnoreCase("Employee"))
{
tempEmp = new Employee();
tempEmp.setType(attributes.getValue("type"));
}
}
public void characters(char[] ch, int start, int length) throws
SAXException {
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());
}
}
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.
Ex.No:10
Date:

            SAMPLE WEB APPLICATION DEVELOPMENT IN THE OPEN
              SOURCE ENVIRONMENT WITH DATABASE ACCESS

AIM:

       To create Sample web application development in the open source
environment.

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 name
set 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">
</form></html>


OUTPUT:




RESULT :

           Thus the Sample web application development in the open source nvironment
has been executed successfully executed.

Más contenido relacionado

La actualidad más candente

La actualidad más candente (7)

Enterprise workflow with Apps Script
Enterprise workflow with Apps ScriptEnterprise workflow with Apps Script
Enterprise workflow with Apps Script
 
lklklk
lklklklklklk
lklklk
 
Html cheat sheet
Html cheat sheetHtml cheat sheet
Html cheat sheet
 
Ôn tập KTTMDT
Ôn tập KTTMDTÔn tập KTTMDT
Ôn tập KTTMDT
 
Database scripts
Database scriptsDatabase scripts
Database scripts
 
Lab final
Lab finalLab final
Lab final
 
How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF
 

Destacado

Presentacion power point paola evers
Presentacion power point  paola eversPresentacion power point  paola evers
Presentacion power point paola eversPao_evers
 
Convertir la experiencia de compra en algo emocionante
Convertir la experiencia de compra en algo emocionanteConvertir la experiencia de compra en algo emocionante
Convertir la experiencia de compra en algo emocionantePayPerThink
 
Lucainena de las Torres
Lucainena de las TorresLucainena de las Torres
Lucainena de las Torresaniushka84
 
Professional Profile Claudio Mendizábal
Professional Profile Claudio MendizábalProfessional Profile Claudio Mendizábal
Professional Profile Claudio Mendizábalcm1959
 
Carta Escrita En El 2070
Carta Escrita En El 2070Carta Escrita En El 2070
Carta Escrita En El 2070Joaquín Mesa
 
Gestion Educacional Chilena
Gestion Educacional ChilenaGestion Educacional Chilena
Gestion Educacional ChilenaSebastian Muñoz
 
SHC Combined One Page Capability Document
SHC Combined  One Page Capability DocumentSHC Combined  One Page Capability Document
SHC Combined One Page Capability Documentgrahamfraser
 
Meta Products & Network Focused Design '12
Meta Products & Network Focused Design '12Meta Products & Network Focused Design '12
Meta Products & Network Focused Design '12Booreiland
 
Plan de emergencias
Plan de emergenciasPlan de emergencias
Plan de emergenciasLina Maria
 
The Role of 4G in Mobile Data Monetisation
The Role of 4G in Mobile Data MonetisationThe Role of 4G in Mobile Data Monetisation
The Role of 4G in Mobile Data Monetisationmy_ron2
 
Proceso irreversible nº2
Proceso irreversible nº2Proceso irreversible nº2
Proceso irreversible nº2Germán Tortosa
 
SERVICIO SOCIAL REDVOLUCION
SERVICIO SOCIAL REDVOLUCIONSERVICIO SOCIAL REDVOLUCION
SERVICIO SOCIAL REDVOLUCIONDiana Carolina
 
Mollo, n. 2011. el ranquel. una lengua que lucha por sobrevivir
Mollo, n. 2011. el ranquel. una lengua que lucha por sobrevivirMollo, n. 2011. el ranquel. una lengua que lucha por sobrevivir
Mollo, n. 2011. el ranquel. una lengua que lucha por sobrevivirNorberto Mollo
 
100114kadientpresentation 100118160817-phpapp02
100114kadientpresentation 100118160817-phpapp02100114kadientpresentation 100118160817-phpapp02
100114kadientpresentation 100118160817-phpapp02MassTLC
 

Destacado (20)

Presentacion power point paola evers
Presentacion power point  paola eversPresentacion power point  paola evers
Presentacion power point paola evers
 
Convertir la experiencia de compra en algo emocionante
Convertir la experiencia de compra en algo emocionanteConvertir la experiencia de compra en algo emocionante
Convertir la experiencia de compra en algo emocionante
 
Cuaderno caza 2012_2013
Cuaderno caza 2012_2013Cuaderno caza 2012_2013
Cuaderno caza 2012_2013
 
Lucainena de las Torres
Lucainena de las TorresLucainena de las Torres
Lucainena de las Torres
 
Laia p.
Laia p.Laia p.
Laia p.
 
Professional Profile Claudio Mendizábal
Professional Profile Claudio MendizábalProfessional Profile Claudio Mendizábal
Professional Profile Claudio Mendizábal
 
Carta Escrita En El 2070
Carta Escrita En El 2070Carta Escrita En El 2070
Carta Escrita En El 2070
 
Gestion Educacional Chilena
Gestion Educacional ChilenaGestion Educacional Chilena
Gestion Educacional Chilena
 
SHC Combined One Page Capability Document
SHC Combined  One Page Capability DocumentSHC Combined  One Page Capability Document
SHC Combined One Page Capability Document
 
Proiect
ProiectProiect
Proiect
 
Meta Products & Network Focused Design '12
Meta Products & Network Focused Design '12Meta Products & Network Focused Design '12
Meta Products & Network Focused Design '12
 
Cantarudo
CantarudoCantarudo
Cantarudo
 
Plan de emergencias
Plan de emergenciasPlan de emergencias
Plan de emergencias
 
The Role of 4G in Mobile Data Monetisation
The Role of 4G in Mobile Data MonetisationThe Role of 4G in Mobile Data Monetisation
The Role of 4G in Mobile Data Monetisation
 
160620 sole nomics v2
160620 sole nomics v2160620 sole nomics v2
160620 sole nomics v2
 
Proceso irreversible nº2
Proceso irreversible nº2Proceso irreversible nº2
Proceso irreversible nº2
 
SERVICIO SOCIAL REDVOLUCION
SERVICIO SOCIAL REDVOLUCIONSERVICIO SOCIAL REDVOLUCION
SERVICIO SOCIAL REDVOLUCION
 
Mollo, n. 2011. el ranquel. una lengua que lucha por sobrevivir
Mollo, n. 2011. el ranquel. una lengua que lucha por sobrevivirMollo, n. 2011. el ranquel. una lengua que lucha por sobrevivir
Mollo, n. 2011. el ranquel. una lengua que lucha por sobrevivir
 
Suplemento Publicidad - El Mundo
Suplemento Publicidad - El MundoSuplemento Publicidad - El Mundo
Suplemento Publicidad - El Mundo
 
100114kadientpresentation 100118160817-phpapp02
100114kadientpresentation 100118160817-phpapp02100114kadientpresentation 100118160817-phpapp02
100114kadientpresentation 100118160817-phpapp02
 

Similar a Webtechnology lab

HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and ImprovedTimothy Fisher
 
FYBSC IT Web Programming Unit III Core Javascript
FYBSC IT Web Programming Unit III  Core JavascriptFYBSC IT Web Programming Unit III  Core Javascript
FYBSC IT Web Programming Unit III Core JavascriptArti Parab Academics
 
Date difference[1]
Date difference[1]Date difference[1]
Date difference[1]shafiullas
 
QCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIQCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIOliver Häger
 
Caracteristicas Basicas De Htlm
Caracteristicas Basicas De HtlmCaracteristicas Basicas De Htlm
Caracteristicas Basicas De HtlmMaria S Rivera
 
Pengenalan AngularJS
Pengenalan AngularJSPengenalan AngularJS
Pengenalan AngularJSEdi Santoso
 
Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Hitesh Patel
 
Creating HTML Pages
Creating HTML PagesCreating HTML Pages
Creating HTML PagesMike Crabb
 
Creating web api and consuming part 2
Creating web api and consuming part 2Creating web api and consuming part 2
Creating web api and consuming part 2Dipendra Shekhawat
 
Ajax Performance Tuning and Best Practices
Ajax Performance Tuning and Best PracticesAjax Performance Tuning and Best Practices
Ajax Performance Tuning and Best PracticesDoris Chen
 
Angular directive filter and routing
Angular directive filter and routingAngular directive filter and routing
Angular directive filter and routingjagriti srivastava
 

Similar a Webtechnology lab (20)

Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
FYBSC IT Web Programming Unit III Core Javascript
FYBSC IT Web Programming Unit III  Core JavascriptFYBSC IT Web Programming Unit III  Core Javascript
FYBSC IT Web Programming Unit III Core Javascript
 
Date difference[1]
Date difference[1]Date difference[1]
Date difference[1]
 
QCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UIQCon 2015 - Thinking in components: A new paradigm for Web UI
QCon 2015 - Thinking in components: A new paradigm for Web UI
 
Caracteristicas Basicas De Htlm
Caracteristicas Basicas De HtlmCaracteristicas Basicas De Htlm
Caracteristicas Basicas De Htlm
 
1cst
1cst1cst
1cst
 
Pengenalan AngularJS
Pengenalan AngularJSPengenalan AngularJS
Pengenalan AngularJS
 
Why study java script
Why study java scriptWhy study java script
Why study java script
 
Practica n° 7
Practica n° 7Practica n° 7
Practica n° 7
 
Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12
 
Creating HTML Pages
Creating HTML PagesCreating HTML Pages
Creating HTML Pages
 
Html5 101
Html5 101Html5 101
Html5 101
 
2.java script dom
2.java script  dom2.java script  dom
2.java script dom
 
course js day 3
course js day 3course js day 3
course js day 3
 
Creating web api and consuming part 2
Creating web api and consuming part 2Creating web api and consuming part 2
Creating web api and consuming part 2
 
Ajax Performance Tuning and Best Practices
Ajax Performance Tuning and Best PracticesAjax Performance Tuning and Best Practices
Ajax Performance Tuning and Best Practices
 
JavaScript Training
JavaScript TrainingJavaScript Training
JavaScript Training
 
Angular directive filter and routing
Angular directive filter and routingAngular directive filter and routing
Angular directive filter and routing
 
Web Technology Record
Web Technology RecordWeb Technology Record
Web Technology Record
 

Último

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 

Último (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

Webtechnology lab

  • 1. Ex.No: HTML PAGES WITH FRAMES, LINKS, TABLES Date : 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.
  • 2. 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> </tr>
  • 3. <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> <ul> <li>COMPUTER SCIENCE</li>
  • 4. <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>
  • 6. RESULT: Thus the given program was coded and executed successfully.
  • 7. Ex.No:02 HTML WITH INTERNAL AND EXTERNAL CSS Date: 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 file 4. 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 {
  • 8. 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 {
  • 10. OUTPUT: RESULT: Thus the given program was coded and executed successfully.
  • 11. Ex.No: 3a Date: 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);
  • 12. } } 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()">
  • 13. <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">
  • 14. 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>
  • 15. OUTPUT: RESULT: Thus the given program was coded and executed successfully.
  • 16. Ex.No: 3b Date: 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; }
  • 17. 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>
  • 18. <form name="signup" onSubmit="return validate()"> <font face="Verdana, Arial, Helvetica, sans-serif" color="#660000" size="2"> <p>&nbsp;&nbsp;*First Name:<input type="text" name="fname" size="20"> &nbsp;&nbsp;*Last Name:<input type="text" name="lname" size="20"> </p> <p style=" border:">&nbsp;&nbsp;*User Name:<input type="text" name="uname" size="20">@smail.com</p> <p style=" border:">&nbsp;&nbsp;*Password :&nbsp;<input type="password" name="pword1">(min 6 characters)</p> <p style=" border:">&nbsp;&nbsp;*Confirm Password:<input type="password" name="pword2" size="20"></p> <p>&nbsp;&nbsp;Gender : <input type="radio" name="gen" value="male">Male <input type="radio" name="gen" value="female">Female </p> <p>&nbsp;&nbsp;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>&nbsp;&nbsp;Language Known:<br/> &nbsp;&nbsp;<input type="checkbox" name="lang" value="tamil">Tamil<br/> &nbsp;&nbsp;<input type="checkbox" name="lang" value="english">English<br/> &nbsp;&nbsp;<input type="checkbox" name="lang" value="hindi">Hindi<br/> &nbsp;&nbsp;<input type="checkbox" name="lang" value="Malayalam">Malayalayam<br/> </p> <p style=" border:">&nbsp;&nbsp;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>
  • 19. </font> </form> </td> <td colspan="2" width="15%"> </td> </table> </body> </html>
  • 20. OUTPUT: RESULT: Thus the given program was coded and executed successfully.
  • 21. Ex.No:4 Date: 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">
  • 22. <inputtype="submit"value="ok" onClick="validate()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="clear"> </form> </body> </html> Reg.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()">()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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()">()">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="clear"> </form> </body> </html>
  • 23. 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”>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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”>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="clear" name=”button2”> </form> </body> </html> Login.jsp %@page import=”java.sql.*”% %@page import=”java.io.*”% <%
  • 24. 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”);
  • 25. 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”);
  • 26. 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”>”);
  • 27. 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)
  • 28. { 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>”);%>
  • 30.
  • 31. RESULT: Thus the given program was coded and executed successfully.
  • 32. Ex.No:5 Date: SIMPLE SERVLET PROGRAM AIM: 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.java 4. Place the class file …Tomcat 5.5webappsROOTWEB-INFclasses 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.java import 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"> -->
  • 34. OUTPUT: RESULT: Thus the given program was coded and executed successfully.
  • 35. Ex.No:06 Date: STUDENT INFORMATION SYTEM USING JSP AND SERVLET AIM: To develop the student webpage information using java servlet and JDBC. ALGORITHM : 1. Start the program 2. Create main HTML page for student database maintenance 3. Select option to do the following operation 4. 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><a href="http://localhost:7001/student/register.html">REGISTER</a></TD></T R> <TR><TD><a href="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><a href="http://localhost:7001/student/delete2.html">DELETE</a></TD></TR> <!--<TR><TD><a href="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>
  • 36. 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>
  • 37. </BODY> </HTML> Second.java import 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,HttpServletResponse res)throws ServletException,IOException { loginform(res,false); }//goGet() private void loginform(HttpServletResponse res,boolean error)throws ServletException,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 TRY AGAIN!!!</H2>"); } pr.println("<form method=post NAME=FORM>"); pr.println("<table><TR><TD><label> please enter your name and password</label></TR></TD>"); pr.println("<TR><TD>Username:<input type=text name=username> "); pr.println("<TR><TD>Password:<input type=password name=password><br></TR></TD><hr width=100%></TR></TD>"); pr.println("<TR><TD>Press:<input type=submit name=submit value=Continue></TR></TD>"); pr.println("<TR><TD>clear:<input type=reset name =reset value=Clear></TR></TD></TABLE>"); pr.println("</form></div></body></html>"); }//loginform() public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException { String name=req.getParameter("username"); String pass=req.getParameter("password");
  • 38. 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"); Connection con=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.*;
  • 39. import java.lang.*; public class register1 extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res)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><div align=center>"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:ss"); //pr.println("student information are successfully registered"); //pr.println("<a href=http://localhost:7001/student/main.html>goto main page</a>"); PreparedStatement pst=con.prepareStatement("Insert into studata 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("<a href=http://localhost:7001/student/main.html>goto main page</a>"); pr.println("</html></body>"); con.commit(); } catch(SQLException e) { System.out.println(e.getMessage()); }
  • 40. catch(Exception e) { e.printStackTrace(); } } }; Insert.java import 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,HttpServletResponse res)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><div align=center>"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:ss"); // pr.println("Get connection"); PreparedStatement pst=con.prepareStatement("Insert into studata 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();
  • 41. con.commit(); pr.println("student information are successfully registered"); pr.println("<a href=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)throws ServletException, IOException { res.setContentType("Text/html"); PrintWriter pr=res.getWriter(); pr.println("<html><body bgcolor=black text=green><div align=center>"); pr.println("<form action=http://localhost:7001/student/find3 method=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=submit value=search>"); pr.println("</form></div></body></html>"); } public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException {
  • 42. 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><div align=center>"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:ss"); //PreparedStatement pst=con.prepareStatement("select * from studata where ID= '" + idno + "' "); PreparedStatement pst=con.prepareStatement("select * from studata where ID= ? "); 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.getSt ring(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 main page</a>"); pr.println("</html></body>"); } catch(SQLException e) { System.out.println(e.getMessage()); } catch(Exception e) { e.printStackTrace(); } } }; Delete2.java import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import java.sql.*; import java.lang.*; public class delete2 extends HttpServlet {
  • 43. public void doPost(HttpServletRequest req,HttpServletResponse res)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 studata where ID= '" + id + "' "); PreparedStatement pst=con.prepareStatement("Delete from studata where 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 main page</a>"); pr.println("</html></body>"); con.commit(); } catch(SQLException e) { System.out.println(e.getMessage()); } catch(Exception e) { e.printStackTrace(); } } };
  • 45.
  • 46.
  • 47. RESULT : Thus student information java script program is successfully completed.
  • 48. Ex.No:07 Date: SIMPLE XML DOCUMENT FOR CD SHOP AIM: 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>
  • 49. </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>
  • 50. <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>
  • 51. <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>
  • 52. <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>
  • 53. </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>
  • 54. OUTPUT: RESULT: Thus the given program was coded and executed successfully.
  • 55. Ex.No:08 Date: SIMPLE XML DOCUMENT WITH DTD AIM: To write a DTD for a domain specific XML document to validate the XML file. ALGORITHM: 1. Start the program 2. Open an XML file as note.xml, to create detail using 3. Various xml attribute list 4. Using user defined tags, we can create message. 5. Using an external and internaldtd,we create elementlist as #PCDATA for retrieve the datafield 6. Using attribute declaration ,use to retrieve the datafield as more than one time 7. 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">
  • 56. 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>
  • 58. RESULT: Thus the given program was coded and executed successfully.
  • 59. Ex.No:09 Date: 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 DOM DomParserExample.java
  • 60. a) Getting a document builder private void parseXmlFile(){ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder db = dbf.newDocumentBuilder(); XML file dom = 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 all employee 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);
  • 61. 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, String qName, Attributes attributes) throws SAXException { tempVal = ""; if(qName.equalsIgnoreCase("Employee"))
  • 62. { tempEmp = new Employee(); tempEmp.setType(attributes.getValue("type")); } } public void characters(char[] ch, int start, int length) throws SAXException { 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()); } }
  • 63. 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.
  • 64. Ex.No:10 Date: SAMPLE WEB APPLICATION DEVELOPMENT IN THE OPEN SOURCE ENVIRONMENT WITH DATABASE ACCESS AIM: To create Sample web application development in the open source environment. 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 name set 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">
  • 65. </form></html> OUTPUT: RESULT : Thus the Sample web application development in the open source nvironment has been executed successfully executed.