SlideShare a Scribd company logo
1 of 29
JNTU WEB TECHNOLOGIES RECORD MANUAL FOR ENGINEERING STUDENTS
Week-1

Aim: To design the following static web pages required for an online book store website.

        HOME PAGE
        The static home page must contain three frames.
        Top frame: Logo and the college name and links to home page, login page, registration page.
        Catalogue page and Cart page (the description of these pages will be given below).
        Left frame: At least four links for navigation, which will display the catalogue of respective links.
        For e.g. when you click the link “CSE” the catalogue for CSE book should be displayed in the
        Right Frame.
        Right frame: The page to the link in the left frame must be loaded here. Initially this page
        contains description of the website.

        Program:
        frame1.html
        <html>
        <head>
        <title>frame</title>
        </head>
        <frameset rows=”25,*”>
        <frame src=”topframe.html” scrolling=”no”>
        <frameset cols=”10 %,*”>
        <frame src=”leftframe.html”>
        <frame src=”rightframe.html” name=”xyz”>
        </frameset>
        </frameset>
        </html>

        topframe.html
        <html>
        <head>
        <title>topframe</title>
        </head>
        <body bgcolor=”grenn”>
        <table width=”100%” align=”center” cellspacing=”0”>
        <tr>
        <th><img width=”100” height=100 src=”c:.......image url……….paste……></th>
        <th colspan=5><h1 font color=”skyblue”>……….COLLEGE NAME………..</font></h1>
        <tr>
<th> <a href=”home.html”target=”xyz”><h3>HOME </a></h3>
<th> <a href=”login.html”target=”xyz”><h2> </a>LOGIN</h2>
<th> <a href=”registration.html”target=”xyz”><h2>REGISTRATION</a></h2>
<th> <a href=”catalogue.html”target=”xyz”><h2>CATALOGUE </a></h2>
<th> <a href=”cart.html”target=”xyz”><h2> CART</a></h2>
</tr
</table>
</body>
</html>

rightframe.html
<html>
<head>
<title>rightframe</title>
<body bgcolor=”mediumorchid”>
<p><i><font color=”white” width=”5”>
……………..Just you have to write about your college in this area……………..
</body>
</html>

leftframe.html
<html>
<head>
<title>leftframe</title>
<body bgcolor=”red”>
<a href=”cse.html”target=”xyz”><font color=”white” width=”3”>CSE</a><br><br>
<a href=”ece.html”target=”xyz”><font color=”white” width=”3”>ECE</a><br><br>
<a href=”civil.html”target=”xyz”><font color=”white” width=”3”>CIVIL</a><br><br>
<a href=”eee.html”target=”xyz”><font color=”white” width=”3”>EEE</a><br><br>
</head>
</body>
<html>

cse.html
<html>
<head>
<title>cse</title>
</head>
<body>
<p>
……………….Write the content about CSE……………………….
</p>
</body>
</html>

ece.html
<html>
<head>
<title>ece</title>
</head>
<body>
<p>
……………….Write the content about ECE……………………….
</p>
</body>
</html>

civil.html
<html>
<head>
<title>civil</title>
</head>
<body>
<p>
……………….Write the content about CIVIL……………………….
</p>
</body>
</html>

eee.html
<html>
<head>
<title>eee</title>
</head>
<body>
<p>
……………….Write the content about EEE……………………….
</p>
</body>
</html>

LOGIN
AIM: To design the following static webpage to display login page.
Program:
<html>
<head>
<title> New Document</title>
</head>
<body leftmargin=”300”>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<pre>
Name        :<input type=”text” value=”” size=”20”><br>
Password :<input type=”password” value=”” size=”20”><br>
         <input type=”submit” value=”submit” size=”20”><br>
         <input type=”reset” value=”reset” size=”20”>
</pre>
</body>
</html>



CATALOGUE PAGE
The catalogue page should contain the details of all the books available in the website in a table.
The details should contain the following:
    1. Snapshot of cover page
    2. Author name
    3. Publisher
    4. Price
    5. Add to cart button

Program:
catalogue.html
<html>
<head>
<title>catalogue</title>
</head>
<body bgcolor=”lightgreen”>
<table colspan=”4” width=”100%” align=”center”>
<tr>
<td><img width=”50” src=”………….paste the image url………….”>
<td>book: …..Name…….<br>
            Author:…Name…<br>
            Publication:…Name….
         <td>$...price…<input typr=”reset” value=”add to cart”>
         </tr>
         <tr>
         <td><img width=”50” src=”………….paste the image url………….”>
         <td>book: …..Name…….<br>
            Author:…Name…<br>
            Publication:…Name….
         <td>$...price…<input typr=”reset” value=”add to cart”>
         </tr>
         <tr>
         <td><img width=”50” src=”………….paste the image url………….”>
         <td>book: …..Name…….<br>
            Author:…Name…<br>
            Publication:…Name….
         <td>$...price…<input typr=”reset” value=”add to cart”>
         </tr>
         <tr>
         <td><img width=”50” src=”………….paste the image url………….”>
         <td>book: …..Name…….<br>
            Author:…Name…<br>
            Publication:…Name….
         <td>$...price…<input typr=”reset” value=”add to cart”>
         </tr>
         </table>
         </html>

WEEK-2

         CART PAGE
         Aim: To write a program to display the cartpage contains the details about the book which are
         added to cart.

         Program:
         cart.html
         <html>
         <head>
         <title>cart</title>
         </head>
         <body>
<table>
<tr>
<td>
<tr>
<td>…Book Name…<th>$...Book Price…<td>$...Total Price…></tr>
<tr>
<td>…Book Name…<th>$... Book Price…<td>$...Total Price …></tr>
<tr>
<td>…Book Name…<th>$... Book Price…<td>$...Total Price …></tr>
<tr>
<td>…Book Name…<th>$... Book Price…<td>$...Total Price …></tr>
<tr>
<td><td><td>Total Amount<td>…………..------…………..</tr><br>
</table>
</body>
</html>

Registration Page
Aim: To create a Registration page with the following fields
     1. Name(text field)
     2. Password(password field)
     3. E=mail(text field)
     4. Phone number(text field)
     5. Sex(radio button)
     6. Date of birth(3 select boxes)
     7. Languages known(check-boxes)
     8. Address(text area)
Program:
registration.html
<html>
<head>
<title>registration</title>
</head>
<body bgcolor=”lightblue”>
,table width=”90%”>
<tr>
<td><pre> Name               :<input type=”text” value=” ” size=”20”><tr></pre>
<tr>
<td><pre>E-mail             :<input type=”text” value=” ” size=”30”><tr></pre>
<tr>
<td><pre>Password           :<input type=”password” value=” ” size=”10”><tr></pre>
<tr>
<td><pre>Gender          :<input type=”radio” name=”r1”>Male<input type=”radio”
name”r1”>Female<tr></pre>
</tr>
<tr>
<td><pre>Languages Known: <input type=”checkbox” name=”Telugu”>Telugu<input
type=”checkbox” name=”HIndi”>HIndi<input type=”checkbox” name=”English”>English<input
type=”checkbox” name=”Tamil”>Tamil<input type=”checkbox” name=”Other
Languages”><tr></pre>
<tr>
<td><pre> D.O.B <select>
<option>1
<option>2
<option>3
<option>4
<option>5
<option>6
<option>7
<option>8
<option>9
<option>10
<option>11
<option>12
<option>13
<option>14
<option>15
<option>16
<option>17
<option>18
<option>19
<option>20
<option>21
<option>22
<option>23
<option>24
<option>25
<option>26
<option>27
<option>28
<option>29
<option>30
<option>31
</select> <select>
<option>Jan
<option>Feb
<option>Mar
<option>Apr
<option>May
<option>Jun
<option>Jul
<option>Aug
<option>Set
<option>Oct
<option>Nov
<option>Dec
</select> <select>
<option>1975
<option>1976
<option>1977
<option>1978
<option>1979
<option>1980
<option>1981
<option>1982
<option>1983
<option>1984
<option>1985
<option>1986
<option>1987
<option>1988
<option>1989
<option>1990
<option>1991
<option>1992
<option>1993
<option>1994
<option>1995
<option>1996
<option>1997
<option>1998
<option>1999
<option>2000
<option>2001
<option>2002
<option>2003
<option>2004
         <option>2005
         <option>2006
         <option>2007
         <option>2008
         <option>2009
         <option>2010
         <option>2011
         <option>2012
         </select>
         </tr></pre>
         <tr>
         <td><pre>Address           :<textarea value=”” rows=”3” cols”10”></textarea>
                                        <pre><input type=”submit” value=”submit” size=”20”>
         <input type=”reset” value=”reset” size=”20”>
         </pre>
         </tr></pre>
         <table>
         </body>
         </html>


WEEK-3

         VALIDATION: Registration Page
         Aim: To write a java Script to validation the following fields of registration page.
             1. Name(name should contain alphabets and the length should be less than 6 characters)
             2. Password(Password should contain alphabet and the symbol not less than 6)
             3. E-mail id(should not contain any invalid and must follow the standard pattern)
             4. Phone number(should contain 10 digits only)
         Program:
         Valreg.html
         <html>
         <head>
         <script language=”javascript”>
         Function validation()
         {
                  var s1=f1.t1.value;
                  var s2=f1.t2.value;
                  var s3=f1.t3.value;
                  var s4=f1.t4.value;
                  var ex1=new RegExp(“^ *i a-z++$”);
var ex2=new RegExp(“^ *i A-Z0-9 + ,6-+$”);
        var ex3=new RegExp(“^ *0-9+ ,10-$”);
        var ex4=new RegExp(“^ *A-Z a-z].+[A-Z a-z 0-9] +.@[a-z]+.[a-z]{3}$”);
        if(ex1.exec(s1)){}
        else,alert(”invalid name”);-
        if(ex2.exec(s2)){}
        else,alert(“invalid password”);-
        if(ex3.exec(s3)){}
        else,alert(“invalid phone number”);-
        if(ex4.exec(s4)){}
        else,alert(“invalid e-mail id”);-
}
</script>
<body>
<form action=”ex.html name=”f1” method=”post” onsubmit=”validation()”>
 Name            :<input type=”text” size=”10 ” name=”t1”><br>
Password        :<input type=”password” name=”t2 ”><br>
Phone number :<input type=”text” size=”10” name=”t3”><br>
E-mail          :<input type=”text” size=”20 ”name=”t4”><tr><br>
<pre><input type=”submit” value=”submit” size=”20”>
<input type=”reset value=”reset” size=”20”></pre>
</form>
</body>
</html>

VALIDATION: Login Page
Aim: To write a java script to validate the following fields of login page.
   1. User name(should contain alphabet, no less than 6)
   2. Password(should not be less than 6 characters)

Program:
login.html
<html>
<head>
<script language=”javascript”>
function login()
{
         var s1=f1.t1.value;
         var s2=f1.t2.value;
         var ex1=new RegExp(“^ *i a-z++$”);
         var ex2=new RegExp(“^ *i A-Z0-9 + ,6-+$”);
         if(ex1.exec(s1)){}
else,alert(”invalid name”);-
                 if(ex2.exec(s2)){}
                 else,alert(“invalid password”);-
         }
         </script>
         <body>
         <form action=”ex.html name=”f1” method=”post” onsubmit=”validation()”>
          Name            :<input type=”text” size=”10 ” name=”t1”><br>
         Password        :<input type=”password” name=”t2 ”><br>
         <pre><input type=”submit” value=”submit” size=”20”>
         <input type=”reset value=”reset” size=”20”></pre>
         </form>
         </body>
         </html>


WEEK-4

         Cascading Style Sheets
         Aim:
         To design a webpage using CSS(cascading style sheet) which includes the following
         Use different font, style
         In the style definition you define how each selector should work (font, clor, etc). Then in the
         body of your pages, you refer to these selectors to activate the styles.
         To design a page includes
             Set a background image for both the page and single element on the page.
             We can define the background image for the page like
             BODY{background-image : Url (my image.gif);}
         To design a page includes
             Control the repetition of the image with the background repeat property. As background
         repeat:repeat. Tiles the image until the entire page is filled, just like an ordinary background
         image in plain HMTL.
         To design a page includes
              Define styles for links as
                     A:link
                     A:visited
                    A:active
                    A:hover
         To design a page that includes work with layers.
         To design a page includes
              Add a customized cursor
              Selector{cursor:value}
Program:
<html>
<head>
<title>stylesheet</title>
<style type=”text/css”>
B.headline {
                  color:red;
                  font-size:22px;
                  font-family:arial;
                  text-decoration:underline;
             }
.xlink {cursor:crosshair;}
.hlink {cursor:help;}
body {background-image:url (“C:Documents and settingsPcMy Documents123.jpg”);
background-repeat:repeat;
}
a:link{text-decoration:none;}
a:visited{text-decoration:pink;}
a:active{text-decoration:blue;}
a:hover{ text-decoration:underline;color:red;}
</style>
</head>
<body>
<B>This is WT lab<B></br>
<a href=”MBA.html” class=”xlink”>crosslink</a>
<a href=”M.Tech.html” class=”hlink”>helpline</a>
<B class=”Headline”>Displaying Web Page</B>
Layer1 on <div
Style=”position:absolute”;font-size:50px;top:30;z-index:2>layer1
</div><br>
Layer2 on <div
Style=”position:absolute”;font-size:50px;color:red;left:5;top:25;z-index:2>layer2
</div>
</body>
</html>
Week -5

     XML FILE
     AIM:
       To write an XML file which will display the book information which includes the following
   1. Title of the book
   2. Author Name
   3. ISBN Number
   4. Publisher Name
   5. Edition Name
   6. Price

   Write a documenttype definition (DTD) to validate the above XML file
   Program:
   book.dtd

     <!--Program:book.dtd-->
     <?xml version=”1.0” encoding=”UTF-8”?>
     <!ELEMENT booklist (book)*>
     <!ELEMENT book (title,author,isbn,publisher,edition,price)>
     <!ELEMENT title (#PCDATA)>
     <!ELEMENT author (#PCDATA)>
     <!ELEMENT isbn (#PCDATA)>
     <!ELEMENT publisher (#PCDATA)>
     <!ELEMENT edition (#PCDATA)>
     <!ELEMENT price (#PCDATA)>
   Program:
   bookdtd.xml

       <!--program:bookdtd.xml-->
       <?xml version=”1.0”?>
       <!DOCTYPE booklist SYSTEM “book:dtd”>
       <booklist>
       <book>
       <title>xml bible</title>
       <author>Winston</author>
       <isbn>87499</isbn>
       <publisher>wiely</publisher>
       <edition>fifth edition</edition>
       <price>$63</price>
       </book>
       <book>
       <title>ai</title>
       <author>s.Russel</author>
       <isbn>87494</isbn>
       <publisher>pinceton hall</publisher>
       <edition>sixth edition</edition>
       <price>$63</price>
</book>
       <book>
       <title>java2</title>
       <author>Watson</author>
       <isbn>87432</isbn>
       <publisher>bpb publications</publisher>
       <edition>third edition</edition>
       <price>$63</price>
       </book>
       <book>
       <title>Html in 24 hours</title>
       <author>sam peter</author>
       <isbn>87492</isbn>
       <publisher>sam publications</publisher>
       <edition>fifth edition</edition>
       <price>$50</price>
       </book >
       </booklist>

Write an XML schema to validate the above XML file.
Program:
book.xsd
<!--program:book.xsd-->
<?xml version=”1.0”?>
<xs:schema xmlns=http://www.w3.org/2011/XTML Schema>
<xs:element name=”booklist”>
<xs:complextype>
<xs:sequence>
<xs:element name=”title” type=”xs:string”/>
< xs:element name=”author” type=”xs:string”/>
< xs:element name=”isbn” type=”xs:string”/>
< xs:element name=”publisher” type=”xs:string”/>
< xs:element name=”edition” type=”xs:string”/>
< xs:element name=”price” type=”xs:integer”/>
</xs:sequence>
</xs:complextype>
</xs:element>
</xs:sequence>
</xs:complextype>
</xs:element>
</xs:schema>

Program:
bookxsd.xml
        <?xml version=”1.0”?>
        <booklist xmlns:xsi=”http”//www.w3.org/2001/xml schema-instance”
xsi:noNameSpaceschemaLocation=”book.xsd”>
        <book>
<title>xml bible</title>
       <author>Winston</author>
       <isbn>87499</isbn>
       <publisher>wiely</publisher>
       <edition>fifth edition</edition>
       <price>$63</price>
       </book>
       <book>
       <title>ai</title>
       <author>s.Russel</author>
       <isbn>87494</isbn>
       <publisher>pinceton hall</publisher>
       <edition>sixth edition</edition>
       <price>$63</price>
       </book>
       <book>
       <title>java2</title>
       <author>Watson</author>
       <isbn>87432</isbn>
       <publisher>bpb publications</publisher>
       <edition>third edition</edition>
       <price>$63</price>
       </book>
       <book>
       <title>Html in 24 hours</title>
       <author>sam peter</author>
       <isbn>87492</isbn>
       <publisher>sam publications</publisher>
       <edition>fifth edition</edition>
       <price>$50</price>
       </book >
       </booklist>

Display the XML file as follows( XML Using XSL)
Program:
book.xsl
<!—program:book.xsl-->
<?xsl:stylesheet version=”1.0”xmlns:xsl=”http://www.w3.0rg/1999/XSL/Transform’
<xsl:template match=”/”>
<html>
<body>
<center>
<h2><font color=”#7788ee”>BOOKS INFORMATION</font></h2>
<table border=”1”>
<thead bgcolor=”#446677”>
<tr>
<th>title</th>
<th>author</th>
<th>isbn</th>
<th>publisher</th>
<th>edition</th>
<th>price</th>
</tr>
</thead>
<xsl:for-each select=”booklist/book”>
<tr>
<td><font color=”blue”><xsl:value-of select=”title”/></font></td>
<td><font color=”RED”><B><xsl:value-of select=”translate(author,’abcdefghijklmn)
<td><font color=”blue”><xsl:value-of select=”isbn”/></font></td>
<td><font color=”blue”><xsl:value-of select=”publisher”/></font></td>
<td><font color=”blue”><xsl:value-of select=”edition”/></font></td>
<td><font color=”blue”><xsl:value-of select=”price”/></font></td>
</tr>
</xsl:for-each>
</table>
</center>
</body>
</html>
<xsl:template>
</xsl:stylesheet>

Program:
book.xml
<!--program:book.xml-->
<?xml version=”1.0”?>
<?XML-Stylesheet type=”text/xsl”href=”book.xsl”?>
<booklist>
<book>
<title>xml bible</title>
<author>Winston</author>
<isbn>87499</isbn>
<publisher>wiely</publisher>
<edition>fifth edition</edition>
<price>$40.5</price>
</book>
<book>
<title>ai</title>
<author>s.Russel</author>
<isbn>87494</isbn>
<publisher>priceton hall</publisher>
<edition>sixth edition</edition>
<price>$63</price>
</book>
<book>
<title>java2</title>
<author>Watson</author>
Isbn>87422</isbn>
<publisher>bpb publications</publisher>
<edition>third edition</edition>
<price>$63</price>
</book>
<book>
<title>Html in 24 hours</title>
<author>sam peter</author>
<isbn>87492</isbn>
<publisher>sam publications</publisher>
<edition>fifth edition</edition>
<price>$50</price>
</book >
</booklist>

Week-6
Creating a New Bean:
        To create a simple visual bean with area filled with a color.
        The shape of the area depends on the property shape. If it isset to true then the shape of the
        area is square and it is circle if it is false.
        The color of the area should be changed dynamically for every mouse click. The color should
        also be changed if we change the color in the property window.

Program:
Colors.java
package sunw.demo.colors;
import java.awt.*;
import java.awt.event*;
public class Colors extends Canwas
{
         transient private Color color;
         private boolean rectangular;
         public Colors()
         {
                 addMouseListener(new MouseAdapter()
                 {
                          public void mousePressed(MouseEvent me)
                          {
                                  change();
                          }
                 });
                 rectangular=false;
                 setSize(200,100);
                 change();
         }
         public boolean getRectangulat()
         {
                 return rectangular;
}
       public void setRectangular(boolean flag)
       {
               this.rectangular=flag;
               repaint();
       }
       public void change()
       {
               color=randomColor();
               repaint();
       }
       private Color randomColor()
       {
               int r=(int)(255*Math.random());
               int g=(int)(255*Math.random());
               int b=(int)(255*Math.random());
               return new Color(r,g,b);
       }
       public void paint(Grapics g)
       {
               Dimention d=getSize();
               int h=d.height;
               int w=d.width;
               g.setColor(color);
               if(rectangular)
               {
                        g.fillRect(0,0,w-l,h-l);
               }
               else
               {
                        g.fillOval(0,0,w-1,h-1);
               }
       }
}


WEEK-7
Installation Of Tomcat
Aim:
     To write the installation procedure for Tomcat web server and APACHE and while installing use the
port number as 8080.
Week-8
User Authentication
AIM:
       Assume four users user1, user2, user3 and users having passwords pwd1, pwd2, pwd3&pwd4
       respectively. Write a servlet for doing the following:
           1. Create a cookie and add these four user ids and passwords to this cookie.
           2. Read the user id and passwords entered in the login form and authenticate with the
               values (user id and passwords) available in the cookies.
                   If be is a valid user (i.e., username and password match) you should Welcome him
               by name (user-name) else you should display “you are not an authenticated user.

Program:
cookies.html
<html>
<head>
</head>
<body bgcolor=”pink”>
<from action=”./cc” method=”get”>
<center><br><h3>WELCOME TO COOKIES WROLD!</h3><br>
Uname&ndsp&ndsp&ndsp&ndsp&ndsp:<input type=”text” name=”t1”<br><br><br>
Password:<input type=”password” name=”t2”><br><br><br>
<input type=”submit” value=”AddCookies”><br><br>
</form>
<form action=”./ch” method=”get”>
<center><br><h3>!@ Login Page @!<?h3><br>
Uname&ndsp&ndsp&ndsp&ndsp&ndsp:<input type=”text” name=”user”<br><br>
Password:<input type=”password” name=”pwd”><br><br>
<input type=”submit” value=”Login”><br><br>
</form>
</center>
</body>
<html>

Program:
AddCookie.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class AddCookie extends HttpServlet
{
         Public void doGet(HttpServletRequest req,HttpServletResponse res)throws
         IOException,ServletException
{
               res.setContentType(“text/html”);
               String name=req.getParameter(“t1”);
               String value=req.getParameter(“t2”);
               PrintWriter out=res.getWriter();
               If((!value.equals(“”))&&(!name.equals(“”)))
               {
                        Cookie c=new Cookie(name.value);
                        res.addCookie(c);
                        out.println(“<body bgcolor=cyan><p align=center>Cookie is Added:”);
                        out.println(“<a href=”./cc.html>To Add A New Cookie</a></p>”);
                        out.println(“<p align=center><a href=./view>View<?a><?p></body>”);
               }
               else
               {
                        out.println(“Cookie is Not Executed”);
                        out.println(“<a href=./cc.html>Click Here to Add Cookie</a>”);
               }
       }
}

Program:
ValidCooki.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ValidCookie extends HttpServlet
{
         Public void doGet(HttpServletRequest req,HttpServletResponse res)throws
         IOException,ServletException
         {
                 res.setContentType(“text/html”);
                 String name1=req.getParameter(“user”);
                 String value1=req.getParameter(“pwd”);
                 PrintWriter out=res.getWriter();
                 Cookie c[]=req.getCookie();
                 if(c!=null)
                 {
                          for(int j=0;j<c.length;j++)
                          {
                                   if((c[j].getName()).equals(name1))
                                   {
if((c[j].getValue()).equals(value))
                                       {
                                                 out.println(“Authorised User”);
                                                 out.println(“Welcime”+name1+”to Cookies”);
                                       }
                                       else
                                       out.println(“<font color=red> Invalid Password</font>”);
                               }
                               else
                               out.println(font color=gray>Unauthorised User</font>”);
                       }
               }
               else
               out.println(“No cookies are added”);
               out.close();
       }
}

Program:
View.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class View extends HttpServlet
{
         Public void doGet(HttpServletRequest req,HttpServletResponse res)throws
         IOException,ServletException
         {
                 PrintWriter out=res.getWriter();
                 Cookie c[]=req.getCookie();
                 if(c!=null)
                 {
                          out.println(“<html><body bgcolor=cyan>”);
                          out.println(“<h2 align=center>The Cookies added are</h2>”);
                          out.println(“<table border=1 align=center><tr><ht>name</th> <th>value</th>
</tr>”);
                          for(int i=0;i<c.length;i++)
                          {
                                   out.println(“<tr><td>”+c*i+.getName()+”</td>”);
                                   out.println(“<td>”+c*i+.getValue()+”</td></tr>”);
                          }
                 }
out.println(“</table></body></html>”);
                out.close();
        }
}

Program:
Web.xml
<web-app>
<servlet>
<servlet-name>c</servlet-name>
<servlet-class>AddCookies</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>c</servlet-name>
<url-pattern>/cc</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ch</servlet-name>
<servlet-class>ValidCookies</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ch</servlet-name>
<url-pattern>/ch</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>views</servlet-name>
<servlet-class>View</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>views</servlet-name>
<url-pattern>/view</url-pattern>
</servlet-mapping>
<web-app>

        INIT Parameters
        Aim: Use init parameters to the following:
        Store the username and password in the web.xml and access them in the servlet by using the
        following getInit Parameter ()
        Initialization parameters are set in the deployment descriptor. To supply the data to the servlet
        at the runtime of initialization of the servlet. We use initialization parameters. So, the servlet
        can access this data during the runtime.
Program:
Web.xml
<web-app>
<servlet>
<servlet-name>init</servlet-name>
<servlet-class>initParameters</servlet-class>
<init-param>
<param-name>ul</param-name>
<param-value>anil</param-value>
</init-param>
</init-param>
<param-name>u3</param-name>
<param-value>giri</param-value>
</init-param>
<init-param>
<param-name>u4</param-name>
<param-value>nag</param-value>
</init-param>
<init-param>
<param-name>u5</param-name>
<param-value>suneel</param-value>
</init-param>
<init-param>
<param-name>u6</param-name>
<param-value>laitha</param-value>
</init-param>
</servlet>
<servlet_mapping>
<servlet-name>init</servlet-name>
<url-pattern>/init</url-pattern>
</servlet-mapping>
</web-app>

Program:
InitParameters.Java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class initParameters extends HttpServlet
{
         public void doGet (HttpServletRequest req, HttpServletResponse res) throws IOException,
         ServletException
{
                res.setContentType(“text/html):
                PrintWriter out=res.getWriter();
                out.println(“initParameters are”);
                ServletConfig sc=getServletConfig();
                Enumeration e=sc.getInitParameterNames();
                out.println(“html><body bgcolon=cyan>”);
                out.println(“<h1>welcome to init parameters</h1>”);
                //out.println(“<form action=./init name=f1”);
                //out.println(“<input type=”submit” value= to view init parametersclick>”);
                out.println(“<boby><html>”);
                While(e.hasMoreElements())
                {
                        String name=(string)e.nextElement();
                        Out.println(“<br>”+sc.getinitParameter(name));
                }
        }
}

WEEK 9
   Inserting values into Registration page
       AIM: Install a database (my sql or oracle)
       Create a table which should contain at least the following field:
       Name, password, email_id, phone number. Practice “JDBC” connectivity. Write a java program
       [servlet] jsp to connect to that database and extract data from the tables and display them.
       Experiments with value various sql queries. Insert the details of the uses who register with the
       website, wherever a new user click the submit button in the registration page.

Program:
Reg.html
<html>
<head>
<title>validation</title>
</head>
<form action=”./reg” method=”post”>
<body bgcolor=”magenta”>
<h1 align=”center”>registration form</h1>
<table border=”0”>
<tr>
<td>name:</td>
<td>input type=”test” name=”user” minlength=”6”>
</td>
</tr>
<tr>
<td>password:</td>
<td><input type=”text” name=”ph”</td>
</tr>
<tr>
<td>email id:</td>
<td>input type=”text” name=”email”></td>
</tr>
<tr><td><input type=”submit” value=”submit”></td></tr>
</table>
</form>
</body>
</html>

Program:
Reg.servlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class RegServlet extends HttpServlet
{
         public void doGet(HttpServletRequest req,HttpServletResponse res)throws
         IOException,ServletException
         {
                 PrintWriter out=res.getWriter();
                 try
                 {
                         String u=req.getParameter (“user”);
                         String p=req.getParameter (“pwd”);
                         String ph=req.getParameter(“ph”);
                         String e=req.getParameter(“email”);
                         res.setContentType(“text/html”);
                         Class.fornName(“sun.jdbc.odbc.jdbcOdbcDriver”)
                         Connection con =DriverManager.getConnection(“jdbc:odbc:rsr”,””,””);
                         Statement st=con.createStatement();
                         String str=(“insert into reg values(‘“+u+”’,’”+p+”’,’”+ph+”’,’”+e+”’)”);
                         int x=st.executeUpdate(str);
                         out.println(“<html><body>inserted successfully</body><html>”);
                 }
                 catch(Exception e)
                 {
out.println(e);
                }
        }
}

Program:
web.xml
<web-app>
<servlet>
<servlet-name>insert</servlet-name>
<servlet-class>RegServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>insert</servlet-name>
<url-pattern>/reg</url-pattern>
</servlet-mapping>
</web-app>



WEEK10
      JSP Authentication
      AIM: Write a Jsp which does the following job:
      Insert the details of the 3 or 4 uses who register with the website (week9) by using registration
      form. Authernticate the user when he submits the login form using the user name and password
      from the database(similar to week8 instead of cookies).

Program
regis.jsp
<%@page import “java.io.*.java.sql.*”%>
<%
response.setContentType (“text/html”);
String name=request.getParameter (“name”);
String password=request.getParameter(“pass”);
String email=request.getParameter(“email”);
String phoneno=request.getParameter(‘phone”);
Class.forName(“sun.jdbc.odbc.jdbcodbcDriver”);
Connection con=DriverManager.getConnection(“jdbc:odbc:student”,””,””);
Statement st=con.createStatement();
String str=”insert into reg values(‘”+name+”’,’”+password+’”,’”+email+”’,’”+phoneneo+”’)”;
St.executeUpdate(str);
String str1=”insert into login values(‘”+name+”’,’”+password+”’)”;
st.executeUpdate(str1);
out.println(“Insert Sucessfully”);
st.close();
con.close();
%>

Program:
Regi.html
<html><head>
<title>Registration</title>
</head>
<body bgcolor=”cyan”>
<form name=”f1” action=”./regis.jsp” align=center”>
<h2 align=”center”>Registration page</h2>
<fieldset>8
<legend>Registration</legend>
<table align=”center”>
<tr>
<td>Name</td>
<td><input type=”text” name=”name” size=”10”/></td>
</tr>
<tr>
<td>Password</td>
<td><input type=”password” name=”pass” size=”10”/></td>
</tr>
<tr>
<td>e-mail</td>
<td><input type=”text” anme=”email” size=”10”/></td>
</tr>
<tr>
<td>phone no</td>
<td><input type=”text” name=”phone” size=”10”/></td>
</tr>
<tr>
<td colspan=2 align=”center><input type=”submit” name=”submit” value+”Registration”/></td>
</tr>
</table>
</fieldset>
</from>
</body>
</html>
Program:
Login.jsp
<%@page import “java.io.*.java.sql.*”%>
<%
response.setContentType(“text/html”);
String name=request.getParameter(“name”);
String password=request.getParameter(“pass”);
Class.forName(“sun.jdbc.odbc.jdbcodbcDriver”);
Connection con=DriverManager.getConnection(“jdbc:odbc:student”,””,””);
preparedStatement ps=con.prepareStatement(“select password from login where name=?”);
ps.setString(1,name);
ResultSet rs=ps.executeQuery();
if(rs.next())
{
         if(rs.getString(1).equals(password))
                  ouot.println(“welcome to”+name);
         else
                  outprintln(“Invalid Password”);
}
else
out.println(“<font color=red>”+name+”UnAuthorised</font>”);
ps.close();
con.close();
%>

Program:
Login.html
<html>
<head>
<title>Login Page</title>
</head>
<body bgcolor=”magenta”>
<h2 align=”center”>Login Page</h2>
<form name=+login” action=”./login.jsp”>
<fieldset>
<legend>Login</legend>
<table align=”center”>
<tr>
<td>Name</td>
<td><input type=”text” name=”name” size”10”/></td>
</tr>
<tr>
<td>Password</td>
<td><input type=”password” name=”pas” size”10”/></td>
</tr>
<tr>
<td colspan=”2” align=”center”><input type=”submit” name=”submit” value=”Login”/></td>
</tr>
</table>
</form>
</fieldset>
</body>
</html>

More Related Content

Recently uploaded

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Recently uploaded (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Featured

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Jntu web technologies record manual for engineering students

  • 1. JNTU WEB TECHNOLOGIES RECORD MANUAL FOR ENGINEERING STUDENTS Week-1 Aim: To design the following static web pages required for an online book store website. HOME PAGE The static home page must contain three frames. Top frame: Logo and the college name and links to home page, login page, registration page. Catalogue page and Cart page (the description of these pages will be given below). Left frame: At least four links for navigation, which will display the catalogue of respective links. For e.g. when you click the link “CSE” the catalogue for CSE book should be displayed in the Right Frame. Right frame: The page to the link in the left frame must be loaded here. Initially this page contains description of the website. Program: frame1.html <html> <head> <title>frame</title> </head> <frameset rows=”25,*”> <frame src=”topframe.html” scrolling=”no”> <frameset cols=”10 %,*”> <frame src=”leftframe.html”> <frame src=”rightframe.html” name=”xyz”> </frameset> </frameset> </html> topframe.html <html> <head> <title>topframe</title> </head> <body bgcolor=”grenn”> <table width=”100%” align=”center” cellspacing=”0”> <tr> <th><img width=”100” height=100 src=”c:.......image url……….paste……></th> <th colspan=5><h1 font color=”skyblue”>……….COLLEGE NAME………..</font></h1> <tr>
  • 2. <th> <a href=”home.html”target=”xyz”><h3>HOME </a></h3> <th> <a href=”login.html”target=”xyz”><h2> </a>LOGIN</h2> <th> <a href=”registration.html”target=”xyz”><h2>REGISTRATION</a></h2> <th> <a href=”catalogue.html”target=”xyz”><h2>CATALOGUE </a></h2> <th> <a href=”cart.html”target=”xyz”><h2> CART</a></h2> </tr </table> </body> </html> rightframe.html <html> <head> <title>rightframe</title> <body bgcolor=”mediumorchid”> <p><i><font color=”white” width=”5”> ……………..Just you have to write about your college in this area…………….. </body> </html> leftframe.html <html> <head> <title>leftframe</title> <body bgcolor=”red”> <a href=”cse.html”target=”xyz”><font color=”white” width=”3”>CSE</a><br><br> <a href=”ece.html”target=”xyz”><font color=”white” width=”3”>ECE</a><br><br> <a href=”civil.html”target=”xyz”><font color=”white” width=”3”>CIVIL</a><br><br> <a href=”eee.html”target=”xyz”><font color=”white” width=”3”>EEE</a><br><br> </head> </body> <html> cse.html <html> <head> <title>cse</title> </head> <body> <p> ……………….Write the content about CSE………………………. </p>
  • 3. </body> </html> ece.html <html> <head> <title>ece</title> </head> <body> <p> ……………….Write the content about ECE………………………. </p> </body> </html> civil.html <html> <head> <title>civil</title> </head> <body> <p> ……………….Write the content about CIVIL………………………. </p> </body> </html> eee.html <html> <head> <title>eee</title> </head> <body> <p> ……………….Write the content about EEE………………………. </p> </body> </html> LOGIN AIM: To design the following static webpage to display login page.
  • 4. Program: <html> <head> <title> New Document</title> </head> <body leftmargin=”300”> <br> <br> <br> <br> <br> <br> <br> <pre> Name :<input type=”text” value=”” size=”20”><br> Password :<input type=”password” value=”” size=”20”><br> <input type=”submit” value=”submit” size=”20”><br> <input type=”reset” value=”reset” size=”20”> </pre> </body> </html> CATALOGUE PAGE The catalogue page should contain the details of all the books available in the website in a table. The details should contain the following: 1. Snapshot of cover page 2. Author name 3. Publisher 4. Price 5. Add to cart button Program: catalogue.html <html> <head> <title>catalogue</title> </head> <body bgcolor=”lightgreen”> <table colspan=”4” width=”100%” align=”center”> <tr> <td><img width=”50” src=”………….paste the image url………….”>
  • 5. <td>book: …..Name…….<br> Author:…Name…<br> Publication:…Name…. <td>$...price…<input typr=”reset” value=”add to cart”> </tr> <tr> <td><img width=”50” src=”………….paste the image url………….”> <td>book: …..Name…….<br> Author:…Name…<br> Publication:…Name…. <td>$...price…<input typr=”reset” value=”add to cart”> </tr> <tr> <td><img width=”50” src=”………….paste the image url………….”> <td>book: …..Name…….<br> Author:…Name…<br> Publication:…Name…. <td>$...price…<input typr=”reset” value=”add to cart”> </tr> <tr> <td><img width=”50” src=”………….paste the image url………….”> <td>book: …..Name…….<br> Author:…Name…<br> Publication:…Name…. <td>$...price…<input typr=”reset” value=”add to cart”> </tr> </table> </html> WEEK-2 CART PAGE Aim: To write a program to display the cartpage contains the details about the book which are added to cart. Program: cart.html <html> <head> <title>cart</title> </head> <body>
  • 6. <table> <tr> <td> <tr> <td>…Book Name…<th>$...Book Price…<td>$...Total Price…></tr> <tr> <td>…Book Name…<th>$... Book Price…<td>$...Total Price …></tr> <tr> <td>…Book Name…<th>$... Book Price…<td>$...Total Price …></tr> <tr> <td>…Book Name…<th>$... Book Price…<td>$...Total Price …></tr> <tr> <td><td><td>Total Amount<td>…………..------…………..</tr><br> </table> </body> </html> Registration Page Aim: To create a Registration page with the following fields 1. Name(text field) 2. Password(password field) 3. E=mail(text field) 4. Phone number(text field) 5. Sex(radio button) 6. Date of birth(3 select boxes) 7. Languages known(check-boxes) 8. Address(text area) Program: registration.html <html> <head> <title>registration</title> </head> <body bgcolor=”lightblue”> ,table width=”90%”> <tr> <td><pre> Name :<input type=”text” value=” ” size=”20”><tr></pre> <tr> <td><pre>E-mail :<input type=”text” value=” ” size=”30”><tr></pre> <tr> <td><pre>Password :<input type=”password” value=” ” size=”10”><tr></pre> <tr>
  • 7. <td><pre>Gender :<input type=”radio” name=”r1”>Male<input type=”radio” name”r1”>Female<tr></pre> </tr> <tr> <td><pre>Languages Known: <input type=”checkbox” name=”Telugu”>Telugu<input type=”checkbox” name=”HIndi”>HIndi<input type=”checkbox” name=”English”>English<input type=”checkbox” name=”Tamil”>Tamil<input type=”checkbox” name=”Other Languages”><tr></pre> <tr> <td><pre> D.O.B <select> <option>1 <option>2 <option>3 <option>4 <option>5 <option>6 <option>7 <option>8 <option>9 <option>10 <option>11 <option>12 <option>13 <option>14 <option>15 <option>16 <option>17 <option>18 <option>19 <option>20 <option>21 <option>22 <option>23 <option>24 <option>25 <option>26 <option>27 <option>28 <option>29 <option>30 <option>31 </select> <select>
  • 9. <option>2004 <option>2005 <option>2006 <option>2007 <option>2008 <option>2009 <option>2010 <option>2011 <option>2012 </select> </tr></pre> <tr> <td><pre>Address :<textarea value=”” rows=”3” cols”10”></textarea> <pre><input type=”submit” value=”submit” size=”20”> <input type=”reset” value=”reset” size=”20”> </pre> </tr></pre> <table> </body> </html> WEEK-3 VALIDATION: Registration Page Aim: To write a java Script to validation the following fields of registration page. 1. Name(name should contain alphabets and the length should be less than 6 characters) 2. Password(Password should contain alphabet and the symbol not less than 6) 3. E-mail id(should not contain any invalid and must follow the standard pattern) 4. Phone number(should contain 10 digits only) Program: Valreg.html <html> <head> <script language=”javascript”> Function validation() { var s1=f1.t1.value; var s2=f1.t2.value; var s3=f1.t3.value; var s4=f1.t4.value; var ex1=new RegExp(“^ *i a-z++$”);
  • 10. var ex2=new RegExp(“^ *i A-Z0-9 + ,6-+$”); var ex3=new RegExp(“^ *0-9+ ,10-$”); var ex4=new RegExp(“^ *A-Z a-z].+[A-Z a-z 0-9] +.@[a-z]+.[a-z]{3}$”); if(ex1.exec(s1)){} else,alert(”invalid name”);- if(ex2.exec(s2)){} else,alert(“invalid password”);- if(ex3.exec(s3)){} else,alert(“invalid phone number”);- if(ex4.exec(s4)){} else,alert(“invalid e-mail id”);- } </script> <body> <form action=”ex.html name=”f1” method=”post” onsubmit=”validation()”> Name :<input type=”text” size=”10 ” name=”t1”><br> Password :<input type=”password” name=”t2 ”><br> Phone number :<input type=”text” size=”10” name=”t3”><br> E-mail :<input type=”text” size=”20 ”name=”t4”><tr><br> <pre><input type=”submit” value=”submit” size=”20”> <input type=”reset value=”reset” size=”20”></pre> </form> </body> </html> VALIDATION: Login Page Aim: To write a java script to validate the following fields of login page. 1. User name(should contain alphabet, no less than 6) 2. Password(should not be less than 6 characters) Program: login.html <html> <head> <script language=”javascript”> function login() { var s1=f1.t1.value; var s2=f1.t2.value; var ex1=new RegExp(“^ *i a-z++$”); var ex2=new RegExp(“^ *i A-Z0-9 + ,6-+$”); if(ex1.exec(s1)){}
  • 11. else,alert(”invalid name”);- if(ex2.exec(s2)){} else,alert(“invalid password”);- } </script> <body> <form action=”ex.html name=”f1” method=”post” onsubmit=”validation()”> Name :<input type=”text” size=”10 ” name=”t1”><br> Password :<input type=”password” name=”t2 ”><br> <pre><input type=”submit” value=”submit” size=”20”> <input type=”reset value=”reset” size=”20”></pre> </form> </body> </html> WEEK-4 Cascading Style Sheets Aim: To design a webpage using CSS(cascading style sheet) which includes the following Use different font, style In the style definition you define how each selector should work (font, clor, etc). Then in the body of your pages, you refer to these selectors to activate the styles. To design a page includes Set a background image for both the page and single element on the page. We can define the background image for the page like BODY{background-image : Url (my image.gif);} To design a page includes Control the repetition of the image with the background repeat property. As background repeat:repeat. Tiles the image until the entire page is filled, just like an ordinary background image in plain HMTL. To design a page includes Define styles for links as A:link A:visited A:active A:hover To design a page that includes work with layers. To design a page includes Add a customized cursor Selector{cursor:value}
  • 12. Program: <html> <head> <title>stylesheet</title> <style type=”text/css”> B.headline { color:red; font-size:22px; font-family:arial; text-decoration:underline; } .xlink {cursor:crosshair;} .hlink {cursor:help;} body {background-image:url (“C:Documents and settingsPcMy Documents123.jpg”); background-repeat:repeat; } a:link{text-decoration:none;} a:visited{text-decoration:pink;} a:active{text-decoration:blue;} a:hover{ text-decoration:underline;color:red;} </style> </head> <body> <B>This is WT lab<B></br> <a href=”MBA.html” class=”xlink”>crosslink</a> <a href=”M.Tech.html” class=”hlink”>helpline</a> <B class=”Headline”>Displaying Web Page</B> Layer1 on <div Style=”position:absolute”;font-size:50px;top:30;z-index:2>layer1 </div><br> Layer2 on <div Style=”position:absolute”;font-size:50px;color:red;left:5;top:25;z-index:2>layer2 </div> </body> </html>
  • 13. Week -5 XML FILE AIM: To write an XML file which will display the book information which includes the following 1. Title of the book 2. Author Name 3. ISBN Number 4. Publisher Name 5. Edition Name 6. Price Write a documenttype definition (DTD) to validate the above XML file Program: book.dtd <!--Program:book.dtd--> <?xml version=”1.0” encoding=”UTF-8”?> <!ELEMENT booklist (book)*> <!ELEMENT book (title,author,isbn,publisher,edition,price)> <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT isbn (#PCDATA)> <!ELEMENT publisher (#PCDATA)> <!ELEMENT edition (#PCDATA)> <!ELEMENT price (#PCDATA)> Program: bookdtd.xml <!--program:bookdtd.xml--> <?xml version=”1.0”?> <!DOCTYPE booklist SYSTEM “book:dtd”> <booklist> <book> <title>xml bible</title> <author>Winston</author> <isbn>87499</isbn> <publisher>wiely</publisher> <edition>fifth edition</edition> <price>$63</price> </book> <book> <title>ai</title> <author>s.Russel</author> <isbn>87494</isbn> <publisher>pinceton hall</publisher> <edition>sixth edition</edition> <price>$63</price>
  • 14. </book> <book> <title>java2</title> <author>Watson</author> <isbn>87432</isbn> <publisher>bpb publications</publisher> <edition>third edition</edition> <price>$63</price> </book> <book> <title>Html in 24 hours</title> <author>sam peter</author> <isbn>87492</isbn> <publisher>sam publications</publisher> <edition>fifth edition</edition> <price>$50</price> </book > </booklist> Write an XML schema to validate the above XML file. Program: book.xsd <!--program:book.xsd--> <?xml version=”1.0”?> <xs:schema xmlns=http://www.w3.org/2011/XTML Schema> <xs:element name=”booklist”> <xs:complextype> <xs:sequence> <xs:element name=”title” type=”xs:string”/> < xs:element name=”author” type=”xs:string”/> < xs:element name=”isbn” type=”xs:string”/> < xs:element name=”publisher” type=”xs:string”/> < xs:element name=”edition” type=”xs:string”/> < xs:element name=”price” type=”xs:integer”/> </xs:sequence> </xs:complextype> </xs:element> </xs:sequence> </xs:complextype> </xs:element> </xs:schema> Program: bookxsd.xml <?xml version=”1.0”?> <booklist xmlns:xsi=”http”//www.w3.org/2001/xml schema-instance” xsi:noNameSpaceschemaLocation=”book.xsd”> <book>
  • 15. <title>xml bible</title> <author>Winston</author> <isbn>87499</isbn> <publisher>wiely</publisher> <edition>fifth edition</edition> <price>$63</price> </book> <book> <title>ai</title> <author>s.Russel</author> <isbn>87494</isbn> <publisher>pinceton hall</publisher> <edition>sixth edition</edition> <price>$63</price> </book> <book> <title>java2</title> <author>Watson</author> <isbn>87432</isbn> <publisher>bpb publications</publisher> <edition>third edition</edition> <price>$63</price> </book> <book> <title>Html in 24 hours</title> <author>sam peter</author> <isbn>87492</isbn> <publisher>sam publications</publisher> <edition>fifth edition</edition> <price>$50</price> </book > </booklist> Display the XML file as follows( XML Using XSL) Program: book.xsl <!—program:book.xsl--> <?xsl:stylesheet version=”1.0”xmlns:xsl=”http://www.w3.0rg/1999/XSL/Transform’ <xsl:template match=”/”> <html> <body> <center> <h2><font color=”#7788ee”>BOOKS INFORMATION</font></h2> <table border=”1”> <thead bgcolor=”#446677”> <tr> <th>title</th> <th>author</th>
  • 16. <th>isbn</th> <th>publisher</th> <th>edition</th> <th>price</th> </tr> </thead> <xsl:for-each select=”booklist/book”> <tr> <td><font color=”blue”><xsl:value-of select=”title”/></font></td> <td><font color=”RED”><B><xsl:value-of select=”translate(author,’abcdefghijklmn) <td><font color=”blue”><xsl:value-of select=”isbn”/></font></td> <td><font color=”blue”><xsl:value-of select=”publisher”/></font></td> <td><font color=”blue”><xsl:value-of select=”edition”/></font></td> <td><font color=”blue”><xsl:value-of select=”price”/></font></td> </tr> </xsl:for-each> </table> </center> </body> </html> <xsl:template> </xsl:stylesheet> Program: book.xml <!--program:book.xml--> <?xml version=”1.0”?> <?XML-Stylesheet type=”text/xsl”href=”book.xsl”?> <booklist> <book> <title>xml bible</title> <author>Winston</author> <isbn>87499</isbn> <publisher>wiely</publisher> <edition>fifth edition</edition> <price>$40.5</price> </book> <book> <title>ai</title> <author>s.Russel</author> <isbn>87494</isbn> <publisher>priceton hall</publisher> <edition>sixth edition</edition> <price>$63</price> </book> <book> <title>java2</title> <author>Watson</author>
  • 17. Isbn>87422</isbn> <publisher>bpb publications</publisher> <edition>third edition</edition> <price>$63</price> </book> <book> <title>Html in 24 hours</title> <author>sam peter</author> <isbn>87492</isbn> <publisher>sam publications</publisher> <edition>fifth edition</edition> <price>$50</price> </book > </booklist> Week-6 Creating a New Bean: To create a simple visual bean with area filled with a color. The shape of the area depends on the property shape. If it isset to true then the shape of the area is square and it is circle if it is false. The color of the area should be changed dynamically for every mouse click. The color should also be changed if we change the color in the property window. Program: Colors.java package sunw.demo.colors; import java.awt.*; import java.awt.event*; public class Colors extends Canwas { transient private Color color; private boolean rectangular; public Colors() { addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { change(); } }); rectangular=false; setSize(200,100); change(); } public boolean getRectangulat() { return rectangular;
  • 18. } public void setRectangular(boolean flag) { this.rectangular=flag; repaint(); } public void change() { color=randomColor(); repaint(); } private Color randomColor() { int r=(int)(255*Math.random()); int g=(int)(255*Math.random()); int b=(int)(255*Math.random()); return new Color(r,g,b); } public void paint(Grapics g) { Dimention d=getSize(); int h=d.height; int w=d.width; g.setColor(color); if(rectangular) { g.fillRect(0,0,w-l,h-l); } else { g.fillOval(0,0,w-1,h-1); } } } WEEK-7 Installation Of Tomcat Aim: To write the installation procedure for Tomcat web server and APACHE and while installing use the port number as 8080.
  • 19. Week-8 User Authentication AIM: Assume four users user1, user2, user3 and users having passwords pwd1, pwd2, pwd3&pwd4 respectively. Write a servlet for doing the following: 1. Create a cookie and add these four user ids and passwords to this cookie. 2. Read the user id and passwords entered in the login form and authenticate with the values (user id and passwords) available in the cookies. If be is a valid user (i.e., username and password match) you should Welcome him by name (user-name) else you should display “you are not an authenticated user. Program: cookies.html <html> <head> </head> <body bgcolor=”pink”> <from action=”./cc” method=”get”> <center><br><h3>WELCOME TO COOKIES WROLD!</h3><br> Uname&ndsp&ndsp&ndsp&ndsp&ndsp:<input type=”text” name=”t1”<br><br><br> Password:<input type=”password” name=”t2”><br><br><br> <input type=”submit” value=”AddCookies”><br><br> </form> <form action=”./ch” method=”get”> <center><br><h3>!@ Login Page @!<?h3><br> Uname&ndsp&ndsp&ndsp&ndsp&ndsp:<input type=”text” name=”user”<br><br> Password:<input type=”password” name=”pwd”><br><br> <input type=”submit” value=”Login”><br><br> </form> </center> </body> <html> Program: AddCookie.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class AddCookie extends HttpServlet { Public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException
  • 20. { res.setContentType(“text/html”); String name=req.getParameter(“t1”); String value=req.getParameter(“t2”); PrintWriter out=res.getWriter(); If((!value.equals(“”))&&(!name.equals(“”))) { Cookie c=new Cookie(name.value); res.addCookie(c); out.println(“<body bgcolor=cyan><p align=center>Cookie is Added:”); out.println(“<a href=”./cc.html>To Add A New Cookie</a></p>”); out.println(“<p align=center><a href=./view>View<?a><?p></body>”); } else { out.println(“Cookie is Not Executed”); out.println(“<a href=./cc.html>Click Here to Add Cookie</a>”); } } } Program: ValidCooki.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class ValidCookie extends HttpServlet { Public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException { res.setContentType(“text/html”); String name1=req.getParameter(“user”); String value1=req.getParameter(“pwd”); PrintWriter out=res.getWriter(); Cookie c[]=req.getCookie(); if(c!=null) { for(int j=0;j<c.length;j++) { if((c[j].getName()).equals(name1)) {
  • 21. if((c[j].getValue()).equals(value)) { out.println(“Authorised User”); out.println(“Welcime”+name1+”to Cookies”); } else out.println(“<font color=red> Invalid Password</font>”); } else out.println(font color=gray>Unauthorised User</font>”); } } else out.println(“No cookies are added”); out.close(); } } Program: View.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class View extends HttpServlet { Public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException { PrintWriter out=res.getWriter(); Cookie c[]=req.getCookie(); if(c!=null) { out.println(“<html><body bgcolor=cyan>”); out.println(“<h2 align=center>The Cookies added are</h2>”); out.println(“<table border=1 align=center><tr><ht>name</th> <th>value</th> </tr>”); for(int i=0;i<c.length;i++) { out.println(“<tr><td>”+c*i+.getName()+”</td>”); out.println(“<td>”+c*i+.getValue()+”</td></tr>”); } }
  • 22. out.println(“</table></body></html>”); out.close(); } } Program: Web.xml <web-app> <servlet> <servlet-name>c</servlet-name> <servlet-class>AddCookies</servlet-class> </servlet> <servlet-mapping> <servlet-name>c</servlet-name> <url-pattern>/cc</url-pattern> </servlet-mapping> <servlet> <servlet-name>ch</servlet-name> <servlet-class>ValidCookies</servlet-class> </servlet> <servlet-mapping> <servlet-name>ch</servlet-name> <url-pattern>/ch</url-pattern> </servlet-mapping> <servlet> <servlet-name>views</servlet-name> <servlet-class>View</servlet-class> </servlet> <servlet-mapping> <servlet-name>views</servlet-name> <url-pattern>/view</url-pattern> </servlet-mapping> <web-app> INIT Parameters Aim: Use init parameters to the following: Store the username and password in the web.xml and access them in the servlet by using the following getInit Parameter () Initialization parameters are set in the deployment descriptor. To supply the data to the servlet at the runtime of initialization of the servlet. We use initialization parameters. So, the servlet can access this data during the runtime.
  • 23. Program: Web.xml <web-app> <servlet> <servlet-name>init</servlet-name> <servlet-class>initParameters</servlet-class> <init-param> <param-name>ul</param-name> <param-value>anil</param-value> </init-param> </init-param> <param-name>u3</param-name> <param-value>giri</param-value> </init-param> <init-param> <param-name>u4</param-name> <param-value>nag</param-value> </init-param> <init-param> <param-name>u5</param-name> <param-value>suneel</param-value> </init-param> <init-param> <param-name>u6</param-name> <param-value>laitha</param-value> </init-param> </servlet> <servlet_mapping> <servlet-name>init</servlet-name> <url-pattern>/init</url-pattern> </servlet-mapping> </web-app> Program: InitParameters.Java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class initParameters extends HttpServlet { public void doGet (HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
  • 24. { res.setContentType(“text/html): PrintWriter out=res.getWriter(); out.println(“initParameters are”); ServletConfig sc=getServletConfig(); Enumeration e=sc.getInitParameterNames(); out.println(“html><body bgcolon=cyan>”); out.println(“<h1>welcome to init parameters</h1>”); //out.println(“<form action=./init name=f1”); //out.println(“<input type=”submit” value= to view init parametersclick>”); out.println(“<boby><html>”); While(e.hasMoreElements()) { String name=(string)e.nextElement(); Out.println(“<br>”+sc.getinitParameter(name)); } } } WEEK 9 Inserting values into Registration page AIM: Install a database (my sql or oracle) Create a table which should contain at least the following field: Name, password, email_id, phone number. Practice “JDBC” connectivity. Write a java program [servlet] jsp to connect to that database and extract data from the tables and display them. Experiments with value various sql queries. Insert the details of the uses who register with the website, wherever a new user click the submit button in the registration page. Program: Reg.html <html> <head> <title>validation</title> </head> <form action=”./reg” method=”post”> <body bgcolor=”magenta”> <h1 align=”center”>registration form</h1> <table border=”0”> <tr> <td>name:</td> <td>input type=”test” name=”user” minlength=”6”> </td>
  • 25. </tr> <tr> <td>password:</td> <td><input type=”text” name=”ph”</td> </tr> <tr> <td>email id:</td> <td>input type=”text” name=”email”></td> </tr> <tr><td><input type=”submit” value=”submit”></td></tr> </table> </form> </body> </html> Program: Reg.servlet.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class RegServlet extends HttpServlet { public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException { PrintWriter out=res.getWriter(); try { String u=req.getParameter (“user”); String p=req.getParameter (“pwd”); String ph=req.getParameter(“ph”); String e=req.getParameter(“email”); res.setContentType(“text/html”); Class.fornName(“sun.jdbc.odbc.jdbcOdbcDriver”) Connection con =DriverManager.getConnection(“jdbc:odbc:rsr”,””,””); Statement st=con.createStatement(); String str=(“insert into reg values(‘“+u+”’,’”+p+”’,’”+ph+”’,’”+e+”’)”); int x=st.executeUpdate(str); out.println(“<html><body>inserted successfully</body><html>”); } catch(Exception e) {
  • 26. out.println(e); } } } Program: web.xml <web-app> <servlet> <servlet-name>insert</servlet-name> <servlet-class>RegServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>insert</servlet-name> <url-pattern>/reg</url-pattern> </servlet-mapping> </web-app> WEEK10 JSP Authentication AIM: Write a Jsp which does the following job: Insert the details of the 3 or 4 uses who register with the website (week9) by using registration form. Authernticate the user when he submits the login form using the user name and password from the database(similar to week8 instead of cookies). Program regis.jsp <%@page import “java.io.*.java.sql.*”%> <% response.setContentType (“text/html”); String name=request.getParameter (“name”); String password=request.getParameter(“pass”); String email=request.getParameter(“email”); String phoneno=request.getParameter(‘phone”); Class.forName(“sun.jdbc.odbc.jdbcodbcDriver”); Connection con=DriverManager.getConnection(“jdbc:odbc:student”,””,””); Statement st=con.createStatement(); String str=”insert into reg values(‘”+name+”’,’”+password+’”,’”+email+”’,’”+phoneneo+”’)”; St.executeUpdate(str); String str1=”insert into login values(‘”+name+”’,’”+password+”’)”; st.executeUpdate(str1);
  • 27. out.println(“Insert Sucessfully”); st.close(); con.close(); %> Program: Regi.html <html><head> <title>Registration</title> </head> <body bgcolor=”cyan”> <form name=”f1” action=”./regis.jsp” align=center”> <h2 align=”center”>Registration page</h2> <fieldset>8 <legend>Registration</legend> <table align=”center”> <tr> <td>Name</td> <td><input type=”text” name=”name” size=”10”/></td> </tr> <tr> <td>Password</td> <td><input type=”password” name=”pass” size=”10”/></td> </tr> <tr> <td>e-mail</td> <td><input type=”text” anme=”email” size=”10”/></td> </tr> <tr> <td>phone no</td> <td><input type=”text” name=”phone” size=”10”/></td> </tr> <tr> <td colspan=2 align=”center><input type=”submit” name=”submit” value+”Registration”/></td> </tr> </table> </fieldset> </from> </body> </html>
  • 28. Program: Login.jsp <%@page import “java.io.*.java.sql.*”%> <% response.setContentType(“text/html”); String name=request.getParameter(“name”); String password=request.getParameter(“pass”); Class.forName(“sun.jdbc.odbc.jdbcodbcDriver”); Connection con=DriverManager.getConnection(“jdbc:odbc:student”,””,””); preparedStatement ps=con.prepareStatement(“select password from login where name=?”); ps.setString(1,name); ResultSet rs=ps.executeQuery(); if(rs.next()) { if(rs.getString(1).equals(password)) ouot.println(“welcome to”+name); else outprintln(“Invalid Password”); } else out.println(“<font color=red>”+name+”UnAuthorised</font>”); ps.close(); con.close(); %> Program: Login.html <html> <head> <title>Login Page</title> </head> <body bgcolor=”magenta”> <h2 align=”center”>Login Page</h2> <form name=+login” action=”./login.jsp”> <fieldset> <legend>Login</legend> <table align=”center”> <tr> <td>Name</td> <td><input type=”text” name=”name” size”10”/></td> </tr> <tr>
  • 29. <td>Password</td> <td><input type=”password” name=”pas” size”10”/></td> </tr> <tr> <td colspan=”2” align=”center”><input type=”submit” name=”submit” value=”Login”/></td> </tr> </table> </form> </fieldset> </body> </html>