Web Technologies Lab Manual
Web Technologies Lab Manual
(Approved by AICTE and Affiliated to JNTU-ANATAUR) C.Ramauram (V), Ramachandrauram(M), Chittoor Dist-517 561 (2013-2014)
Nageswara Rao
Objective : To create a fully functional website with mvc architecture. To Develop an online Book store using we can sell books (Ex amazon .com). Hardware and Software required : 1. 2. 3. 4. 5. 6. 7. A working computer system with either Windows or Linux A web browser either IE or firefox Tomcat web server and Apache web server XML editor like Altova Xml-spy [www.Altova.com/XMLSpy free ] , Stylusstudio , etc., A database either Mysql or Oracle JVM(Java virtual machine) must be installed on your system BDK(Bean development kit) must be also be installed
Week-1
Date: 23-06-08
-----------------------------------------------------------------------------------------------------------AIM: Design the static web pages required for an online book store web site.
1) HOME PAGE
DESCRIPTION: The static home page must contain three frames. Top frame : Logo and the college name and links to Home page, Login page, Registration page, 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 Books should be displayed in the Right frame. Right frame: The pages to the links in the left frame must be loaded here. Initially this page contains description of the web site.
Nageswara Rao
<frame src="topframe.html"name="f1"> <frameset cols="20%,*"> <frame src="leftframe.html"name="f2"> <frame src="rightframe.html"name="f3"> </frameset> </frameset> </head>
OUTPUT:
Nageswara Rao
Top frame: <html> <body> <p> <img src="C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg" align=left width=100 height=100"> <h1 align=center>Online book store</h1> </p> <br> <p> <h2> nbsp; <a href="homepage.html" target=_parent> Home </a> <a href="login.html" target="f3"> login </a> <a href="registration.html" target="f3"> registration </a> nbsp; Nageswara Rao
<a href="catalogue.html" target="f3"> Catalogue </a> <a href="cart.html" target="f3"> Cart </a> </h2> </p> </body> </html>
Nageswara Rao
OUTPUT:
Leftframe: <html> <body> <a href=cse.html target="f3"><h3>CSE</h3> </a><br><br><br><br><br> <a href=ece.html target="f3"><h3>ECE</h3></a><br><br><br><br><br> <a href=eee.html target="f3"><h3>EEE</h3></a><br><br><br><br><br> <a href=civil.html target="f3"><h3>Civil</h3></a> </body> </html>
Nageswara Rao
OUTPUT:
Nageswara Rao
<h2 align="center"> <font face="times new roman" color="green" >Online book store information </font> </h2>
<h3> <font face="monotype corsiva" color=blue> This is the online book store developed by students of pvpsit.It contains book catalogue of various branches like cse,ece,eee,civil </font></h3> </p> </body> </html>
OUTPUT:
2) LOGIN PAGE
Nageswara Rao
DESCRIPTION: The login page contains the user name and the password of the user to authenticate. PROGRAM: <html> <head> <p style= "background:yellow; top:100px; left:250px; position:absolute; "> </head> <body background=E:\1.jpg> <form action="index.jsp" method="get"> <label> <font face="comic sans ms" color="green" size="5">Login </font> </label> <input type="text" size="20" maxlength="20" value=' '><br><br><br> <label> <font face="comic sans ms" color="green" size="5">Password </font> </label>
<input type="password" size="20" maxlength="20"> <br><br><br> <input type="submit" value="submit"> <input type="reset"> </form> </body> </html> OUTPUT: Nageswara Rao
3) CATOLOGUE PAGE
DESCRIPTION: The catalogue page should contain the details of all the books available in the web site in a table. The details should contain the following:
1. Snap shot of Cover Page. 2. Author Name. 3. Publisher. 4. Price. 5. Add to cart button. Nageswara Rao
PROGRAM: <html> <body> <center> <table border=1> <tr> <th> Book Preview </th> <th> Book Details </th> <th> Price </th> <th> Payment </th> </tr> <tr> <td> <img src="C:\Documents and Settings\All users\My Documents\My Pictures\xml.bmp" width=100 height=50> </img> </td> <td> <pre> <font face="comic sans ms" size=4 color="green" > book:XML Bible Author:winston Publisher:Wiesley
Nageswara Rao
</font> </pre> </td> <td> $40 </td> <td> <a href="cart.html" target="_blank"> <img src="C:\Documents and Settings\All users\My Documents\My Pictures\cart.bmp" width="150"
height="100"></img> </a> </td> </tr> <tr> <td> <img src="C:\Documents and Settings\All users\My Documents\My Pictures\java.bmp" width=100 height=50> </img> </td> <td> <pre> <font face="comic sans ms" size=4 color="green" > book:Java 2 Author:Watson Publisher:BPB publications </font> </pre> </td> Nageswara Rao
<td> $40 </td> <td> <a href="cart.html" target="_blank"> <img src="C:\Documents and Settings\All users\My Documents\My Pictures\cart.bmp" width="150"
height="100"></img> </a> </td> </tr> </table> </center> </body> </html> OUTPUT:
Nageswara Rao
Nageswara Rao
RESULT: Thus the home page, login page, catalogue page for the online book store are created successfully
Week-2
-----------------------------------------------------------------------------------------------------------AIM: Design of the cart page and the registration page required for online book store.
4) CART PAGE
Nageswara Rao
DESCRIPTION: The cart page contains the details about the books which are added to the cart.
PROGRAM: <html> <body> <center><br><br><br> <img src=E:\aa.jpg> <table border=1 cellpadding=center> <thead> <tr> <th>Book name</th> <th>price</th> <th>quantity</th> <th>amount</th> </tr> </thead> <tr> <td>java 2</td> <td>$45</td> <td>2</td>
Nageswara Rao
<td>$70</td> </tr> <tr> <td> XML bible</td> <td> $20</td> <td> 5</td> <td> $40</td> </tr> <th colspan=4>total amount=$110> </th> </tr> </table> </center> </body> </html>
OUTPUT:
Nageswara Rao
5) REGISTRATION PAGE
DESCRIPTION: Create a registration form with the following fields 1)Name(Textfield) 2) Password (password field) 3) E-mail id (text field)
Nageswara Rao
4) Phone number (text field) 5) Sex (radio button) 6) Date of birth (3 select boxes) 7) Languages known (check boxes English, Telugu, Hindi, Tamil) 8) Address (text area) PROGRAM: <html> <body> <center> <img src=E:\aaa.jpg align=left> <form> <label>name</label> <input type="text" size="20"><br><br> <br> <label>password</label> <input type="password" size="20" maxsize="28"><br> <br> <br> <label>email</label> <input type="text" size="30"><br> <br> <br> <label>phone no</label> <input type="text" size="2"> <input type="text" size="6"> <input type="text" size="10"><br> <br> <br> <label>Sex</label>
Nageswara Rao
<input type="radio" name="sex">m <input type="radio" name="sex">f <br> <br> <br> <label> date of birth</label> <select> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> <select> <option>jan</option> <option>feb</option> <option>mar</option> <option>apr</option> </select> <select> <option>1980</option> <option>1981</option> <option>1982</option> <option>1983</option> </select> <br> <br> <br>
Nageswara Rao
<label> Languages Known </label> <input type="checkbox"> English <input type="checkbox"> Telugu <input type="checkbox"> Hindi <input type="checkbox"> Tamil <br> <br> <br> <label> Address </label> <textarea rows=5 cols=20 scrolling="yes"> </textarea> </center> </body> </html>
OUTPUT:
Nageswara Rao
RESULT: Thus the registration and cart pages for online book store pages are created successfully Week-3 Date: 14-07-08
-----------------------------------------------------------------------------------------------------------AIM: Write JavaScript to validate the following fields of the above registration page. 1. Name (Name should contains alphabets and the length should not be less than 6 characters). 2. Password (Password should not be less than 6 characters length). 3. E-mail id (should not contain any invalid and must follow the standard pattern [email protected]) Nageswara Rao
JavaScript is a simple scripting language invented specifically for use in web browsers to make websites more dynamic. On its own, HTML is capable of outputting more-or-less static pages. Once you load them up your view doesn't change much until you click a link to go to a new page. Adding JavaScript to your code allows you to change how the document looks completely, from changing text, to changing colors, to changing the options available in a dropdown list. JavaScript is a client-side language. JavaScripts are integrated into the browsing environment, which means they can get information about the browser and HTML page, and modify this information, thus changing how things are presented on your screen. This access to information gives JavaScript great power to modify the browsing experience. They can also react to events, such as when the user clicks their mouse, or points to a certain page element. This is also a very powerful ability.
Regular Expressions:
One of the most common situations that come up is having an HTML form for users to enter data. Normally, we might be interested in the visitors name, phone number and email address, and so forth. However, even if we are very careful about putting some hints next to each required field, some visitors are going to get it wrong, either accidentally or for malicious purposes. Heres where regular expressions come in handy. A regular expression is a way of describing a pattern in a piece of text. In fact, its an easy way of matching a string to a pattern. We could write a simple regular expression and use it to check, quickly, whether or not any given string is a properly formatted user input. This saves us from difficulties and allows us to write clean and tight code. A regular expression is a JavaScript object. There are multiple ways of creating them. They can be created statically when the script is first parsed or dynamically at run time. A static regular expression is created as follows: regx=/fish|fow1/;
Dynamic patterns are created using the keyword to create an instance of the RegExp class: regx=new RegExp(fish|fow1);
Nageswara Rao
Functions: test(string)- Tests a string for pattern matches. This method returns a Boolean that indicates whether or not the specified pattern exists within the searched string. This is the most commonly used method for validation. It updates some of the properties of the parent RegExp object following a successful search. exec(string)- Executes a search for a pattern within a string. If the pattern is not found, exec() returns a null value. If it finds one or more matches it returns an array of the match results. It also updates some of the properties of the parent RegExp object
var userv=document.forms[0].user.value; var pwdv=document.forms[0].pwd.value; var emailv=document.forms[0].email.value; var phv=document.forms[0].ph.value; var userreg=new RegExp("^[a-zA-Z][a-zA-Z0-9]*$"); var emailreg=new RegExp("^[a-zA-Z][a-zA-Z0-9_.]*@[a-zA-Z][a-zA-Z0-9_.]*.[a-zA-Z][a-zA-Z09_.]{2}.[a-zA-Z][a-zA-Z0-9_.]{2}$|^[a-zA-Z][a-zA-Z0-9_.]*@[a-zA-Z][a-zA-Z0-9_.]*.[a-zA-Z][a-zA-Z09_.]{3}$"); var phreg=new RegExp("^[0-9]{10}$"); var ruser=userreg.exec(userv); var remail=emailreg.exec(emailv); var rph=phreg.exec(phv);
Nageswara Rao
if(ruser && remail && rph && (pwdv.length > 6)) { alert("All values are valid"); return true; } else { if(!ruser) { alert("username invalid");document.forms[0].user.focus();} if(!remail) { alert("password invalid");document.forms[0].user.focus();} if(!rph) { alert("phone number invalid");document.forms[0].ph.focus();} if(pwdv.length < 6) { alert("password invalid");document.forms[0].pwd.focus();} return false; }
} Register.html <html> <body> <center> <fieldset> <legend>Registration</legend> <form action="Database" method="get" onSubmit="return fun()"> <pre> Name :<input type="text" name="user" size="10"><br>
Nageswara Rao
Password E-mail
Phone Number :<input type="text" name="ph" size="10"><br> <input type="submit" value="Register"> </pre> </form> </body> <script src="valid.js"></script> </html>
OUTPUT:
Nageswara Rao
Nageswara Rao
RESULT: Thus the home page, login page, catalogue page for the online book store are created successfully
Nageswara Rao
Week-4
Date: 21-07-08
-----------------------------------------------------------------------------------------------------------AIM:
Design a web page using CSS (Cascading Style Sheets) which includes the following: 1) Use different font, styles: In the style definition you define how each selector should work .Then, in the body of your pages, you refer to these selectors to activate the styles. 2) Set a background image for both the page and single elements on the page. 3) Control the repetition of the image with the background-repeat property
DESCRIPTION:
Cascading Style Sheets (CSS) is a stylesheet language used to describe the presentation of a document written in a markup language. Its most common application is to style web pages written in HTML and XHTML, but the language can be applied to any kind of XML document. In CSS, selectors are used to declare which elements a style applies to, a kind of match expression. Selectors may apply to all elements of a specific type, or only those elements which match a certain attribute; elements may be matched depending on how they are placed relative to each other in the markup code, or on how they are nested within the document object model A style sheet consists of a list of rules. Each rule or rule-set consists of one or more selectors and a declaration block. A declaration-block consists of a list of semicolon-separated declarations in braces. Each declaration itself consists of a property, a colon (:), a value, then a semi-colon (;)
Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules: 1. External style sheet 2. Internal style sheet (inside the <head> tag) 3. Inline style (inside an HTML element) An inline style (inside an HTML element) has the highest priority, which means that it will override a style declared inside the <head> tag, in an external style sheet, or in a browser (a default value). Nageswara Rao
Syntax The CSS syntax is made up of three parts: a selector, a property and a value: selector {property: value} The selector is normally the HTML element/tag you wish to define, the property is the attribute you wish to change, and each property can take a value. The property and value are separated by a colon, and surrounded by curly braces: body {color: black} External Style Sheet An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section:
<head> <link rel="stylesheet" type="text/css" href="mystyle.css" /> </head> The browser will read the style definitions from the file mystyle.css, and format the document according to it.
Internal Style Sheet An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section by using the <style> tag, <head> <style> selector {property:value; property:value;..} </style> </head>
Nageswara Rao
Inline Styles An inline style loses many of the advantages of style sheets by mixing content with presentation. Use this method sparingly, such as when a style is to be applied to a single occurrence of an element. To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property.
<p style="color: sienna; margin-left: 20px"> This is a paragraph </p>
1) Use different font, styles:In the style definition you define how each selector should work (font, color etc.). Then, in the body of your pages, you refer to these selectors to activate the styles.
<html> <head> <title> week no-4.1 exp web technologies </title> <STYLE TYPE="TEXT/CSS"> H1 { COLOR:rgb(50,100,150); TEXT-ALIGN:right; FONT-FAMILY:Times new roman; } H6 { COLOR:green; TEXT-ALIGN:CENTER; FONT-FAMILY:Verdana; } </STYLE> </HEAD> <body> <H1>WELCOME TO CSE</H1> <H6>WELCOME TO INTERNAL CSS</H2> </BODY>
Nageswara Rao
</HTML>
Output:
2)
Set a background image for both the page and single elements on the page.You can define the background image for the page
Program:
<html> <head> <title>Image</title> <style> body { background-image:url("Sunset.jpg" ); background-repeat:no-repeat; } h1 { background-image:url("Winter.jpg "); } </style> </head>
Nageswara Rao
3) 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 HTML.
Program: <html> <head> <title>Image</title> <style> body { background-image:url("a.jpg"); background-repeat:repeat-Y; } </style> </head> <body>HAPPY BIRTHDAY
Nageswara Rao
4) Define styles for links as A:link A:visited A:active A:hover Program: <html> <head> <style type="text/css"> a:link {color:"orange";} /* unvisited link */ a:visited {color:"red";} /* visited link */ a:hover {color:green;} /* mouse over link */ a:active {color:yellow;} /* selected link */
Nageswara Rao
</style> </head> <body> <p><b><a href="css4.html">This is a link</a></b></p> <p><b>Note:</b> a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective.</p> <p><b>Note:</b> a:active MUST come after a:hover in the CSS definition in order to be effective.</p> </body> </html> Output:
Nageswara Rao
<body> <div style="position:static;Border-style:solid;color:red;top:100px; right:150px;">CSE </div><br> <div style="position:static;Border-style:dashed;color:blue;">IT </div> <div align="right"> sdasdadadadasdasd </div> </body> </html> Output:
<p>Mouse over the words to change the cursor.</p> <span style="cursor:auto">auto</span><br /> <span style="cursor:crosshair">crosshair</span><br /> <span style="cursor:default">default</span><br /> <span style="cursor:e-resize">e-resize</span><br /> <span style="cursor:help">help</span><br /> <span style="cursor:move">move</span><br /> <span style="cursor:n-resize">n-resize</span><br /> <span style="cursor:ne-resize">ne-resize</span><br /> <span style="cursor:nw-resize">nw-resize</span><br /> <span style="cursor:pointer">pointer</span><br /> <span style="cursor:progress">progress</span><br /> <span style="cursor:s-resize">s-resize</span><br /> <span style="cursor:se-resize">se-resize</span><br /> <span style="cursor:sw-resize">sw-resize</span><br /> <span style="cursor:text">text</span><br /> <span style="cursor:w-resize">w-resize</span><br /> <span style="cursor:wait">wait</span><br /> </body> </html> otuput:
Nageswara Rao
Week-5 ----------------------------------------------------------------------------------------------------------------------------------AIM: Write an XML file which will display the Book information. It includes the following: 1) Title of the book 2) Author Name 3) ISBN number 4) Publisher name 5) Edition 6) Price Write a Document Type Definition (DTD) to validate the above XML file. Display the XML file as follows. The contents should be displayed in a table. The header of the table should be in color GREY. And the Author names column should be displayed in one color and should be capitalized and in bold. Use your own colors for remaining columns. Use XML schemas XSL and CSS for the above purpose.
Nageswara Rao
DESCRIPTION:
DTD vs XML Schema The DTD provides a basic grammar for defining an XML Document in terms of the metadata that comprise the shape of the document. An XML Schema provides this, plus a detailed way to define what the data can and cannot contain. It provides far more control for the developer over what is legal, and it provides an Object Oriented approach, with all the benefits this entails. Many systems interfaces are already defined as a DTD. They are mature definitions, rich and complex. The effort in re-writing the definition may not be worthwhile. DTD is also established, and examples of common objects defined in a DTD abound on the Internet -- freely available for re-use. A developer may be able to use these to define a DTD more quickly than they would be able to accomplish a complete re-development of the core elements as a new schema. Finally, you must also consider the fact that the XML Schema is an XML document. It has an XML Namespace to refer to, and an XML DTD to define it. This is all overhead. When a parser examines the document, it may have to link this all in, interpret the DTD for the Schema, load the namespace, and validate the schema, etc., all before it can parse the actual XML document in question. If you're using XML as a protocol between two systems that are in heavy use, and need a quick response, then this overhead may seriously degrade performance.
PROGRAM:
Nageswara Rao
<author>chrisbates</author> <ISBN>123-456-789</ISBN> <publisher>wiley</publisher> <edition>3</edition> <price>350</price> </book> <book> <title>internet worldwideweb</title> <author>ditel&ditel</author> <ISBN>123-456-781</ISBN> <publisher>person</publisher> <edition>3</edition> <price>450</price> </book> </bookstore>
<?xml version="1.0" encoding="UTF-8"?> <!ELEMENT bookstore (book+)> <!ELEMENT book (title,author,ISBN,publisher,edition,price)> <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <!ELEMENT ISBN (#PCDATA)>
Nageswara Rao
Bookstore.xml <!DOCTYPE bookstore SYSTEM "C:\Documents and Settings\Administrator\My Documents\bookstore.dtd"> <bookstore> <book> <title>web programming</title> <author>chrisbates</author> <ISBN>123-456-789</ISBN> <publisher>wiley</publisher> <edition>3</edition> <price>350</price> </book> <book> <title>internet worldwideweb</title> <author>ditel&ditel</author> <ISBN>123-456-781</ISBN> <publisher>person</publisher> <edition>3</edition> <price>450</price> </book> Nageswara Rao
</bookstore>
<?xml version="1.0" encoding="UTF-8"?> <xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="bookstore"> <xs:complexType> <xs:sequence> <xs:element name="book" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="title" <xs:element name="author" <xs:element name="ISBN" type="xs:string"></xs:element> type="xs:string"></xs:element> type="xs:string"></xs:element>
<xs:element name="publisher" type="xs:string"></xs:element> <xs:element name="edition" <xs:element name="price" </xs:sequence> </xs:complexType> type="xs:int"></xs:element> type="xs:decimal"></xs:element>
Nageswara Rao
</xs:element>
</xs:sequence> </xs:complexType>
</xs:element> </xs:schema>
Bookstore.xml <bookstore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Documents and Settings\Administrator\My Documents\bookstore.xsd"> <book> <title>web programming</title> <author>chrisbates</author> <ISBN>123-456-789</ISBN> <publisher>wiley</publisher> <edition>3</edition> <price>350</price> </book> <book> <title>internet worldwideweb</title> <author>ditel&ditel</author> <ISBN>123-456-781</ISBN> <publisher>person</publisher> <edition>3</edition>
Nageswara Rao
PROGRAM: XML:
<bookstore> <book> <title>Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book>
Nageswara Rao
<book> <title>Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore> XSL: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2> My Books collection</h2> <table border="1"> <tr bgcolor="red"> <th align="left">title</th> <th align="left">author</th> </tr> <xsl:for-each select="bookstore/book"> <tr> <td><xsl:value-of select="title"/></td> <xsl:choose>
Nageswara Rao
<xsl:when test="price > 30"> <td bgcolor="yellow"><xsl:value-of select="author"/></td> </xsl:when> <xsl:when test="price > 10"> <td bgcolor="magneta"><xsl:value-of select="author"/></td> </xsl:when> <xsl:otherwise> <td><xsl:value-of select="author"/></td> </xsl:otherwise> </xsl:choose> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> OUTPUT:
Nageswara Rao
RESULT: Thus the XML stylesheets are successfully used to display the content in a table format.
Nageswara Rao