You are on page 1of 49

WEB TECHNOLOGIES

LAB MANUAL

IV YEAR B.Tech.CSE-1 Semester
2009

Department of Computer Science

GRIET

Objectives
This course introduces the technologies behind today's web-based
applications. A student completing this course should have acquired a good
understanding of the basic design principles of the web model of computing.
Students should have designed and implemented a web application using
current software development technologies and methodologies. He should
have learned in detail some cutting-edge technologies. The student should
have learned how to work in a group with strict delivery deadlines. The
student should have learned how to prepare reading material, bibliography
search, and make presentations to a class.

Course structure
The course will be mostly driven by active student participation. Students are
expected to research specific technologies and present them in the class. An
important part of the course are programming assignments. There will be
regular programming assignments that help students understand and
implement the concepts taught in the class.

How to use /read this manual

 This manual is divided into sections with different problems.
 Each section corresponds to different programs in the lab, the different lab
sessions and programs will be available in the manual.
 Each session contains theory that you will need for proper understanding
during the lab sessions.
 Get clear idea of different concepts that you will have to manage while
executing the lab tasks.

CONTENTS
1.

LAB SYLLABUS

2.

INTRODUCTION

3.

PROGRAMS DESCRIPTION

4.

PROGRAMS EXPLANATION WITH
 Definition
 Code

5.

ASSIGNMENT

6.

REFERENCES

7.

CONTENT BEYOND SYLLABUS.

JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY
HYDERABAD
IV B.Tech (I-SEM)
T
P
0
3
WEB TECHNOLOGIES LAB

C
2

1. Develop static pages (using Only HTML) of an online Book store. The pages should
resemble: www.amazon.com The website should consist the following pages.






Home page
Registration and user Login
User Profile Page
Books catalog
Shopping Cart
Payment By credit card
Order Conformation

2. Validate the Registration, user login, user profile and payment by credit card
pages using JavaScript.
3. Create and save an XML document at the server, which contains 10 users
information. Write a program, which takes User Id as an input and returns the user
details by taking the user information from the XML document.
4. Create a JavaBean which gives the exchange value of INR (Indian Rupees) into equivalent
American/Canadian/Australian Dollar value.
5. Create a simple Bean with a label - which is the count of number of clicks. Then
create a BeanInfo class such that only the “count” property is visible in the
Property Window.
6. Create two Beans Traffic Light(Implemented as a Label with only three
Background colours-Red,Green,Yellow) and Automobile(Implemented as a
TextBox which states its state/movement). The state of the Automobile should
depend on the following Light Transition Table.
Light Transition
Red ---> Yellow
Yellow ---> Green
Green --> Red

Automobile State
Ready
Move
Stopped

7. Convert the static web pages online library into dynamic web pages using servlets
and cookies.

html"><FONT COLOR="black"><ITALIC>USER PROFILE</FONT></ITALIC><BR> <BR><BR><A HREF="user login.html"><BR><BR> <FONT COLOR="black"><ITALIC>REGISTRATION FORM</FONT></ITALIC><BR><BR> <BR><BR><A HREF="user profile .*"> <FRAME NAME="A2" SCROLLING="YES" SRC="head.html"><FONT COLOR="black"><ITALIC>USER LOGIN</FONT></ITALIC><BR> <BR><BR><A HREF="book catalog.html"> </FRAMESET><H1 ALIGN="CENTER"><U><FONT COLOR="PURPLE">WELCOME TO ONLINE BOOK SHOPPING<ITALIC></ITALIC> </U></FONT></H1> <H2> <FONT COLOR="WHITE"></FONT></H2> <H3 ALIGN="CENTER"><A HREF="reg.HTML"><FONT COLOR="black"><ITALIC>BOOKS CART</FONT></ITALIC><BR> .PROGRAM: Source Code for home page <html> <head> <title> ONLINE BOOK STORES</title> </head> <body bgcolor="pink"> <FRAMESET ROWS="20%.html"><FONT COLOR="black"><ITALIC>BOOKS CATALOG</FONT></ITALIC><BR> <BR><BR><A HREF="confim.

HTML"><FONT COLOR="black"><ITALIC>PAYMENT</H3></FONT></ITALIC><BR> </BODY> </HTML> OUTPUT SCREEN: .<BR><BR><A HREF="payment.

Source Code for Registration and user Login <html> <head> <center><u><h1>Registration Form</h1></u></center> </head> <body> <fieldset width=300><legend class=heading>Registration Form</legend> <form actions="http://localhost:8080//servletexamples//KiranUserProfile"> <pre class="reg"> First Name : <input type="text" size=30> Last Name : <input type="text" size=30> Age : <input type="text" size=30 onFocus="kirandisp()"> Email Id : <input type="email" size=30> Alternate Email Id : <input type="email" size=30> Address : <textarea cols=50 rows=3></textarea> Phone Occupation : <input type="text" size=30> : <input type="text" size=30> .

<input type="radio" name="agree" value="i agree">I Agree Terms & conditions <input type="radio" name="agree" value="i disagree">I DisAgree <input type="submit" value=submit> type="Reset" value=" reset "> </form> </fieldset> </body> </html> <input .

OUTPUT SCREEN FOR REGISTRATION FORM .

.

.sourcecode for Userlogin <html> <head><center> <font size="6" color="Black" ><h1><u>User login...</u><h1></font></center> </head> <form method="POST" ACTION="http://localhost:8080//servletexamples//KiranPass"> <body bgcolor="0x1ff0f2"> <pre> Enter Name : <input type="text" name="name" size=15 > <br> Enter Password : <input type="password" name="pwd" size=15><br> <input type= Submit name=sbmt value="Login"> </pre> </form></body> </html> ..

OUTPUT SCREEN FOR USERLOGIN .

gif" width=80></td><td><b>Visual Basics</b> <ul><pre><li><font color=blue>Author :Kiran</font> <li><font color=blue>edition :2007</font> <li><font color=blue>price :950</font> <li><font color=blue>Publicher :gangii publishers</pre></font></pre> </ul> <td><pre><b>add to cart</b> <img src="click.gif" width=80></td><td><b>Web Technology & Designing</b> <ul><pre><li><font color=blue>Author :Kiran-Gangadhar</font> <li><font color=blue>edition :2007</font> <li><font color=blue>price :5950</font> <li><font color=blue>Publicher :jyothi publishers</pre></font></pre> </ul> <td><pre><b>add to cart</b> <img src="click.gif"></pre></td> </tr> <tr> <td><img src="web tech.gif"></pre></td> </tr> <tr> <td><img src="quick.Source code for books catalog <html> <head> </head> <body> <center><font color="red" size=7 face="Vivaldi"><b><i>Book Catlog</i></font></center></b> <table> <td><img src=java.gif"></pre></td> </td> <tr> <td><img src="vbnet.jpg width=100></td><td><b>Java Complete <br>references</b> <ul><pre><li><font color=blue>Author :Gangadhar</font> <li><font color=blue>edition :2007</font> <li><font color=blue>price :450</font> <li><font color=blue>Publicher :Ideal publishers</pre></font></pre> </ul> <td><pre><b>add to cart</b> <img src="click.gif" width=80></td><td><b>Web Technology & Designing</b> <ul><pre><li><font color=blue>Author :Kiran-Gangadhar</font> <li><font color=blue>edition :2007</font> .

<li><font color=blue>price :5950</font> <li><font color=blue>Publicher :jyothi publishers</pre></font></pre> </ul> <td><pre><b>add to cart</b> <img src="click.jpg" width=80></td><td><b>Harry reference to java</b> <ul><pre><li><font color=blue>Author :Harry Potter</font> <li><font color=blue>edition :2007</font> <li><font color=blue>price :950</font> <li><font color=blue>Publicher :jyothi publishers</pre></font></pre> </ul> <td><pre><b>add to cart</b> <img src="click.gif"></pre></td> </tr> </table> </body> </html> .gif"></pre></td> </tr> <tr> <td><img src="harry.

OUTPUT SCREEN FOR BOOKCATLOG .

.

and . but JavaScript is a scripting language with a very simple syntax! Almost anyone can put small "snippets" of code into their HTML pages  JavaScript can put dynamic text into an HTML page .A JavaScript can be used to detect the visitor's browser.A JavaScript can read and change the content of an HTML element  JavaScript can be used to validate data . In this case the browser will write Hello World! to the page . like when a page has finished loading or when a user clicks on an HTML element  JavaScript can read and write HTML elements .write("Hello World!"). we use the <script> tag.A JavaScript can be used to store and retrieve information on the visitor's computer To insert a JavaScript into an HTML page.load another page specifically designed for that browser  JavaScript can be used to create cookies .write command between the <script> and </script> tags.HTML authors are normally not programmers. Inside the <script> tag we use the type attribute to define the scripting language. So.depending on the browser .write command is a standard JavaScript command for writing output to a page.A JavaScript can be set to execute when something happens.A JavaScript can be used to validate form data before it is submitted to a server.What is JavaScript?  JavaScript was designed to add interactivity to HTML pages  JavaScript is a scripting language  A scripting language is a lightweight programming language  JavaScript is usually embedded directly into HTML pages  JavaScript is an interpreted language (means that scripts execute without preliminary compilation) What can a JavaScript do?  JavaScript gives HTML designers a programming tool .A JavaScript statement like this: document. the browser will recognize it as a JavaScript command and execute the code line. the <script type="text/javascript"> and </script> tells where the JavaScript starts and ends: The example below shows how to use JavaSript to write text on a web page: <html> <body> <script type="text/javascript"> document. </script> </body> </html> The document.write("<h1>" + name + "</h1>") can write a variable text into an HTML page  JavaScript can react to events . This saves the server from extra processing  JavaScript can be used to detect the visitor's browser . By entering the document.

if(username1.value. Aim: To validate the Registration.length<6) { return_value=false. window. var username1=form1.value="". form1.value.length < 8) { return_value=false.value="".alert(" pwd should be > 6 char's ").txtpassword2. user login and payment by credit card pages using JavaScript. form1. var username2=form1.EXPERIMENT-2  Validate the Registration.txtpassword2. Program: Registration <html> <head><title> register</title> <SCRIPT LANGUAGE="JAVASCRIPT"> function essentials_of_validation(form1) { var return_value=true. var password2=form1.txtusername2. } if(username1==username2) { return_value=false.value.txtpassword1. user login and payment by credit card pages using Javascript.alert("both ids are same").txtpassword2. var password1=form1. } return return_value. window.txtusername1. } if(password1!=password2) { return_ value=false. window. } if(password1.value. form1.value="". form1.txtusername2.alert("user name less than 8 chars").alert("ur password mismatched ").value="".txtpassword1. } </script> </head> <body BGCOLOR="YELLOW"> <CENTER><u> <marquee><font name="mistral" size="+1">REGISTRATION FORM</font></marquee> </u></center> . window.txtpassword1. form1.value="".

txtusername.html">Home</A> <A Href="E:\cs540\user. var username=form1.<form name="form1" onSubmit="essentials_of_validation(this)"> Name:<input name="name" type="text" size="10"> <br> Age:<input type="text" size="3"> <br> Sex:<br> <input name ="gen" type="radio" value="male">male <input name="gen" type="radio" value="female">female <br> Address:<textarea name="address" rows="3" cols="3"></textarea> <br> Enter e-mail id u want :<sup>*</sup> <input type="text" name="txtusername1" size="15"> <br> Password:<sup>*</sup> <input type="Password" name="txtpassword1" size="15">(password should exceed 6 characters) <br> Confirm password:<input type="password" name="txtpassword2" size=20> <br> Alternate mail:<sup>*</sup> <input type="text" name="txtusername2" size="15"> <br> Known This Site Through <br> <input name="things" type="checkbox" value="srts"> internet <input name="things" type="checkbox" value="sp">newspapers <input name="things" type="checkbox" value="spor"> friends <br> Rate ur site <select name="rating"> <option selected>good <option>average <option>bad <option>no rating </select><br> Enter the code<input name="code" type="text" size="5"> <table border="1" width="10%" height="10%"> <thead><tr><th> 1123</th></tr> </thead> </table> <br> <input type="submit" value="submit "> <input type ="reset" value="clear ur entries"> </form> <font size="+1"> <A Href="E:\cs540\online.value. .html">Login</A> </font> </body> </html> User Login <html> <head> <SCRIPT LANGUAGE="JAVASCRIPT"> function essentials_of_validation(form1) { var return_value=true.

alert("Not a valid account number").length < 8) { return_value=false.alert(" pwd should be > 6 char's ").value.dd.alert("ur password mismatched "). form1.yyyy.value.value. } return return_value. if(isNaN(username)) { window.value.txtpassword1.txtpassword2.txtpassword1.getFullYear()) { if(c>current. } if(password1. } if(a<32 && b<13&& c>=current. window. var b=form1. var username=form1.length<6) { return_value=false. var c=form1.txtpassword1. var password2=form1.value.txtusername. window.value="".alert("user name less thn 8 chars").value. form1. form1. var a=form1. } </script> </head> <body bgcolor="skyblue"> <marquee><b><u><font face="comic sans ms" color="light blue">login here</font></u></b></marquee> <form name="form1" onSubmit="essentials_of_validation(this)"> Username <input type="text" name="txtusername" size=20> <br>Password: <input type="password" name="txtpassword1" size=20> <br>Confirm password:<input type="password" name="txtpassword2" size=20> <br><br> <input type="submit" value="submit"> <input type="reset" value="reset"> </form> </body> </html> Payment by credit card <html> <head><title> payment</title> <SCRIPT LANGUAGE="JAVASCRIPT"> function essentials_of_validation(form1) { var current=new Date().txtpassword2.var password1=form1.txtpassword2.value="".getFullYear()) { .txtpassword1. if(username.value="".value="".value. var password1=form1. var return_value=true. } if(password1!=password2) { return_value=false. form1. window.mm.

alert(" card has expired"). } } </script> </head> <body bgcolor="pink"> <marquee><strong>Enjoy the Shopping with special Offers</strong></marquee> <form name="form1" onSubmit="essentials_of_validation(this)"> <font size="+2"> Payment Through <br> <input name="pay" type="radio" >Credit card <input name="pay" type="radio" >Debit card <br> Bank <select name="bank"> <option selected>sbi <option>HSBC <option>ICICI <option>others </select> <br> Account/Card number: <input name="txtusername" type="textbox"> <br> Net banking id/Password<input name="txtpassword1" type="password"> <br> Enter date of expiryof account/card<input name="dd" type="text" size=2>(dd) <input name="mm" type="text" size=2>(mm) <input name="yyyy" type="text" size=4>(yyyy) <br> <input type="submit" value="Accept"> <input type="reset" value="Reject"> </form> <A Href="e:\cs540\online.alert("you are validated").getMonth()) { if(a>current.html">back</A> </body> </html> .getDate()) { window. } else if(b=current.alert(" you are validated").alert("Your card has expired").getMonth()) { window.window.getFullYear()) { if(b>current. } } } else { window.alert(" you are validated").html">Home</A> <br><A Href="e:\cs540\shop. } } else { window. } else if(c=current.

Output screens for validations .

.

.

Many applications have been written to convert existing documents into the XML standard. Each of these receiving platforms can then convert the XML into a structure the platform uses normally.XML XML is a markup language. as XML stands for eXtensible Markup Language. An example is a PDF to XML converter.  . It is because of this hard work that the tools exist to do these conversion from whatever platform into standardized XML data or convert XML into a format used by that platform. programming.  VoiceXML . and even to play sounds!  File Converters . convert it into XML.XML data is sent to some cell phones. mobile phones and more. and presto! You have just communicated between two platforms which are potentially very different! What makes XML truly powerful is the international acceptance it has received. Many individuals and corporations have put forth their hard work to make XML interfaces for databases. The mighty ones who created this acronym cheated a little. then share that XML with a slough of other programs and platforms. The data is then formatted by the specification of the cell phone software designer to display text or images.Converts XML documents into an audio format so that you can listen to an XML document. office application. XML is nothing by itself. The XML standard was created by W3C to provide an easy to use and standardized way to store self-describing data (self-describing data is data that describes both its content and its structure). XML Applications: Although there are countless numbers of applications that use XML. The main benefit of XML is that you can use it to take data from a program like MSSQL (Microsoft SQL). XML was released in the late 90's and has since received a great amount of hype. here are a few examples of the current platforms and applications that are making use of this technology: Cell Phones . XML is more of a "common ground" standard.

which takes user id as input and displays the user details by taking the user information from the XML document. Write a program. Program: User Information <?xml version="1. which takes user id as input and returns the user details by taking the user information from the XML document.EXPERIMENT-3  Create and save an XML document at the server .which contains 10 users information.0"?> <userdata> <user1> <jntuno>561</jntuno> <name> chandu</name> <phno>9989891510</phno> <address>srikakulam</address> </user1> <user2> <jntuno>540</jntuno> <name> karteek</name> <phno>9701443556</phno> <address>srikakulam1</address> </user2> <user3> <jntuno>525</jntuno> <name> giri</name> <phno>9897895301</phno> <address>rajam</address> </user3> <user4> <jntuno>526</jntuno> <name>gopi</name> <phno>9999789540</phno> <address>parlakimidi</address> </user4> <user5> <jntuno>513</jntuno> <name> manoj</name> <phno>9989233331</phno> <address>hyderabad</address> </user5> <user6> <jntuno>514</jntuno> <name> balaji</name> <phno>9999789560</phno> <address>vizag</address> </user6> <user7> <jntuno>567</jntuno> <name>kiran </name> <phno>9999178957</phno> <address>vijayanagaram</address> </user7> . Aim: To write a program.

} </script> </body> </html> .childNodes.1).childNodes.item(i).<user8> <jntuno>518</jntuno> <name> sekhar</name> <phno>789580</phno> <address>bobili</address> </user8> <user9> <jntuno>517</jntuno> <name>chaitu</name> <phno>789590</phno> <address>sallur</address> </user9> <user10> <jntuno>595</jntuno> <name> sravan</name> <phno>9000789500</phno> <address>sklm</address> </user10> </userdata> Information Retrival <html> <!--DOM with javascript> <head> <title>user profile example</title> </head> <body> <script type="text/JavaScript"> var xmldoc=new ActiveXObject("Microsoft.prompt("eneter user num".write("<h2>"+child.i<node.nodeName+":"+val.xml").nodeValue).XMLDOM").i++) { var child=node. document.childNodes. var node=ele.item(y-1). var y=window. xmldoc.firstChild. var val=child.documentElement.length. var ele=xmldoc.load("data. for(var i=0.

Output screens for XML document .

Example and explanation of a simple bean program import java. setForeground( Color. Bound – A bean property for which a change to the property results in a notification being sent to some other bean. Hidden – A bean property that can be changed. SimpleBean also implements the java. setOpaque( true ). The other bean may reject the change if it is not appropriate.Serializable interface. platform-independent component model written in the Java programming language. import javax. Your bean may implement either the Serializable or the Externalizable interface. Indexed – A bean property that supports a range of values instead of a single value.beans. public class SimpleBean extends JLabel implements Serializable { public SimpleBean() { setText( "Hello world!" ). setVerticalAlignment( CENTER ).Color. With the JavaBeans API you can create reuseable. or composite components. you can combine these components into applets.JLabel. Using JavaBeans-compliant application builder tools.io. Through the design mode of a builder tool. The JavaBeans™ specification defines the following types of bean properties: Simple – A bean property with a single value whose changes are independent of changes in any other property.YELLOW ). Bean properties can also be classified as follows: Writable – A bean property that can be changed Standard Expert Preferred Read Only – A bean property that cannot be changed. JavaBean components are known as beans.XMLDecoder.swing.RED ). However.Serializable. import java. The JavaBeans architecture was built through a collaborative industry effort and enables developers to write reusable components in the Java programming language. platform-independent components.JLabel graphic component and inherits its properties. these properties are not disclosed with the BeanInfo class .awt. you use the property sheet or bean customizer to customize the bean and then save (persist) your customized beans.JavaBeans is a portable. } } SimpleBean extends the javax.swing. Constrained – A bean property for which a change to the property results in validation by another bean. setHorizontalAlignment( CENTER ).io. setBackground( Color. import java. Beans are dynamic in that they can be changed or customized. which makes the SimpleBean a visual component. applications.

22)). } }). Candiandollar=(Rupee*40. repaint().drawString("Candian Dollar :"+Candiandollar.drawString("Aus Dollar :"+Ausdollar.50.4852). } public void paint(Graphics g) { double Ausdollar. int h=d.width.awt. int w=d. g.awt.*. } } . Ausdollar=(Rupee*34. Usadollar=(Rupee*39. Dimension d=getSize().EXPERIMENT-4 .72). import java. g. g.*. Create a JavaBean which gives the exchange value of INR(Indian Rupees) into equivalent American/Canadian/Australian Dollar value. } public double getRupee() { return Rupee.Usadollar.150). import java.200).50).Font.event.300). public class KiranRupee extends Canvas { private double Rupee.8941).KiranRupee.PLAIN. public KiranRupee() { addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { repaint().50. setSize(300.height. Program: package sunw. } public void setRupee(double r) { Rupee=r. g.50.Candiandollar. Aim: To create a JavaBean so that it converts value of INR(Indian Rupees) into equivalent American/Canadian/Australian Dollar value.drawString("Indian Rupee :"+Rupee.setFont(new Font("SansSerif".demo.

Output screen for javabean .

}} .awt. public class KiranCount extends Canvas { private int count. Aim: To create a simple Bean with a label . public KiranCount() { addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { count++.22)).Font.setFont(new Font("SansSerif". g. } }).PLAIN.drawString("Count :"+count. } public void paint(Graphics g) { Dimension d=getSize().event.which is the count of number of clicks.which is the count of number of clicks and a BeanInfo class such that only the “count” property is visible in the Property Window. int h=d. setSize(200. int w=d.150. import java.height.KiranCount.*.width.*.EXPERIMENT-5  Create a simple Bean with a label . g. Program: package sunw. import java.demo.awt. repaint(). Then create a BeanInfo class such that only the “count” property is visible in the Property Window.300).150).

Outputscreen for Using bean info class: .

public class Colors extends Canvas { transient private Color color.Colors.EXPERIMENT-6 .awt. Create two Beans Traffic Light(Implemented as a Label with only three background colours-Red. The state of the Automobile should depend on the following Light Transition Table.event. rectangular=false. Program: package sunw.random()). change(). private boolean rectangular.*.*. } }).demo. } public boolean getRectangular() { return rectangular.Yellow and Automobile which is implemented as a TextBox which states its state/movement with above stated conditions. import java. } private Color randomColor() { int r=(int) (255*Math. repaint(). public Colors() { addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { change(). } public void change() { color=randomColor(). setSize(200. . } public void setRectangular(boolean flag) { this.awt. Light Transition Red ---> Yellow Yellow ---> Green Green --> Red Automobile State Ready Move Stopped Aim: To create two Beans Traffic Light which implemented as a Label with only three background colours-Red.Green.100). import java.rectangular=flag.Yellow) and Automobile(Implemented as a TextBox which states its state/movement). repaint().Green.

height. h-1).random()). w-1.setColor(color). } else { g. h-1). int w=d. 0.random()). if(rectangular) { g. } } } Output screens . int b=(int) (255*Math. return new Color(r.fillOval(0.width. g.fillRect(0.int g=(int) (255*Math. } public void paint(Graphics g) { Dimension d=getSize(). b). w-1. g. int h=d. 0.

Dynamic web page Classical hypertext navigation. Using server-side scripting to change the supplied page source between pages. There are two ways to create this kind of interactivity: 1. adjusting the sequence or reload of the web pages or web content supplied to the browser. from all contexts. Disadvantages    Difficult to maintain when a site gets large. the type of browser being used. meaning that the user requests a web page and simply views the page and the information on that page. . Advantages    Quick and easy to put together. Contrast with Dynamic web page.  Can create the illusion of being updated regularly using time and date sensitive routines (or even randomisers) to display pre-written text. or a database or server state. form fields. Ideal for demonstrating how a site will look. parameters in the URL. web navigation can also provide an "interactive experience" that is termed "dynamic". with HTML or XHTML alone. Advantages  Offers highly personalized and customised visitor options. However. Using client-side scripting to change interface behaviors within a specific web page.  Scripts need more consideration when uploading and installing. etc. providing the classical hypertext. 2. It displays the same information for all users. in response to mouse or keyboard actions or at specified timing events. and both may be used simultaneously.) on a web page can change. where navigation is performed through "static" documents.A static web page is a web page that always comprises the same information in response to all download requests from all users. Server responses may be determined by such conditions as data in a posted HTML form. Disadvantages  Personalized pages are not very cache friendly. In this case the dynamic behavior occurs within the presentation. provides "static" content. Difficult to keep consistent and up to date.  Database access improves the personalized experience (as opposed to using just client side cookies)  Scripts can read in data sources and display it differently depending on how it is run. Content (text. images. the passage of time.  Requires a basic minimum knowledge of the language being used. in response to different contexts or conditions. Cache friendly. particularly to *unix servers. The result of either technique is described as a dynamic web page. Offers little visitor personalization (all would have to be client side). even by someone who doesn't have much experience. one copy can be shown to many people.

init(ServletConfig) Initializes the servlet. getServletConfig() Returns a servlet config object. according to task type or organizational boundaries. Servlets can forward requests to other servers and servlets. A servlet can handle multiple requests concurrently. and perhaps an on-line payment system. they can synchronize requests to support systems such as on-line conferencing. This allows them to be used to balance load among several servers that mirror the same content. ServletResponse) Carries out a single request from the client. more commonly. such as its author. being Java based they are more platform independent. such as Java-enabled web servers. Servlet Architecture Overview The central abstraction in the Servlet API is the Servlet interface. and copyright. All servlets implement this interface.Servlets are modules that run inside request/response-oriented servers. getServletInfo() Returns a string containing information about the servlet. version. Functionally they operate in a very similar way to CGI scripts. service(ServletRequest. . either directly or. Some Example Applications A few of the many applications for servlets include. The inheritance hierarchy looks as follows. It also allows them to be used to partition a single logical service over several servers.    Processing data POSTed over HTTPS using an HTML form. which contains any initialization parameters and startup configuration for this servlet. Run once before any requests can be serviced. working with product and inventory databases. including purchase order or credit card data. A servlet like this could be part of an order-entry and processing system. The Servlet interface provides the following methods that manage the servlet and its communications with clients. Allowing collaboration between people. by extending a class that implements it such as HttpServlet. however.      destroy() Cleans up whatever resources are being held and makes sure that any persistent state is synchronized with the servlet's current in-memory state. Forwarding requests.

then continues shopping. when the user selects a new item for his cart. the site can provide visitors with a number of conveniences:  Identifying a user during an e-commerce session. In fact. a search site can charge much more for an ad for a servlet development environment than an ad for an on-line travel agent. if the search had been "Bali Hotels". On the other hand. if you do a search on "Java Servlets". a cookie is sent with a unique user ID.  Customizing a site. Many large sites require you to register in order to use their services. They use cookies to remember what you wanted.Cookies are small bits of textual information that a Web server sends to a browser and that the browser returns unchanged when visiting the same Web site or domain later. the situation would be reversed. that's the person who was searching for such and such previously" and display an appropriate (read "high priced") ad instead of a random (read "cheap") one. That is. The search engines charge their customers much more for displaying "directed" ads than "random" ads. and doesn't require an explicit username and password. and servlet authors don't need to manipulate cookies directly to make use of it  Avoiding username and password. When a user registers. When the client reconnects at a later date. determines it belongs to a registered user.  Focusing advertising. adds it to his shopping cart. how does the store know that he is the same user that put the previous item in his cart? Cookies are a good way of accomplishing this. Cookies let them remember "Oh. . The problem is that they have to show a random ad when you first arrive and haven't yet performed a search. Many on-line stores use a "shopping cart" metaphor in which the user selects an item. Many "portal" sites let you customize the look of the main page. so that you get that result initially next time. as well as when you search on something that doesn't match any ad categories. but it is inconvenient to remember the username and password. the server looks it up. By having the server read information it sent the client previously. Since the HTTP connection is closed after each page is sent. Cookies are a good alternative for low-security sites. I'll give an example like this later in this section of the tutorial. this is so useful that servlets have an API specifically for this. the user ID is returned.

HTML"><FONT COLOR="black"><ITALIC>PAYMENT</H3></FONT></ITALIC><BR> </BODY> </HTML> Registration: <html> <head> <center><u><h1>Registration Form</h1></u></center> </head> <body> <fieldset width=300><legend class=heading>Registration Form</legend> <form actions="http://localhost:8080//servlet-examples//KiranUserProfile"> <pre class="reg"> First Name : <input type="text" size=30> Last Name : <input type="text" size=30> Age : <input type="text" size=30 onFocus="kirandisp()"> Email Id : <input type="email" size=30> Alternate .html"> </FRAMESET><H1 ALIGN="CENTER"><U><FONT COLOR="PURPLE">WELCOME TO ONLINE BOOK SHOPPING<ITALIC></ITALIC> </U></FONT></H1> <H2> <FONT COLOR="WHITE"></FONT></H2> <H3 ALIGN="CENTER"><A HREF="reg. Aim: To convert the static web pages online library into dynamic web pages using servlets and cookies.html"><BR><BR> <FONT COLOR="black"><ITALIC>REGISTRATION FORM</FONT></ITALIC><BR><BR> <BR><BR><A HREF="user profile . Convert the static web pages online library into dynamic web pages using servlets and cookies.html"><FONT COLOR="black"><ITALIC>USER PROFILE</FONT></ITALIC><BR> <BR><BR><A HREF="user login. Program: Shopping page: <html> <head> <title> ONLINE BOOK STORES</title> </head> <body bgcolor="pink"> <FRAMESET ROWS="20%.*"> <FRAME NAME="A2" SCROLLING="YES" SRC="head.HTML"><FONT COLOR="black"><ITALIC>BOOKS CART</FONT></ITALIC><BR> <BR><BR><A HREF="payment.html"><FONT COLOR="black"><ITALIC>USER LOGIN</FONT></ITALIC><BR> <BR><BR><A HREF="book catalog.html"><FONT COLOR="black"><ITALIC>BOOKS CATALOG</FONT></ITALIC><BR> <BR><BR><A HREF="confim.EXPERIMENT-7 .

URL=KiranBooksShopping.. if(name.util.IOException { res.Email Id Address Phone : <input type="email" size=30> : <textarea cols=50 rows=3></textarea> : <input type="text" size=30> Occupation : <input type="text" size=30> <input type="radio" name="agree" value="i agree">I Agree Terms & conditions <input type="radio" name="agree" value="i disagree">I DisAgree <input type="submit" value=submit> <input type="Reset" value=" reset "> </form> </fieldset> </body> </html> Sign in: <html> <head><center> <font size="6" color="Black" ><h1><u>User login. import java. import javax.*. public class KiranParameters1 extends HttpServlet { public void doGet(HttpServletRequest req.*.servlet.htm").getParameter("email"). import javax.equals(name)&&pass.equals(pass)) { res. String name=res..</u><h1></font></center> </head> <form method="POST" ACTION="http://localhost:8080//servlet-examples//KiranPass"> <body bgcolor="0x1ff0f2"> <pre> Enter Name : <input type="text" name="name" size=15 > <br> Enter Password : <input type="password" name="pwd" size=15><br> <input type= Submit name=sbmt value="Login"> </pre> </form></body> </html> //servlet program import java.setContentType("text/html"). PrintWriter out=res. IOException { doGet(request.getParameter("password").HttpServletResponse res)throws ServletException.*.http.setHeader("Refresh".HttpServletResponse response) throws ServletException. response).servlet.. } else { res.htm").setHeader("Refresh".URl=KiranUserLoginInvlid.io."5.. "5. } } public void doPost(HttpServletRequest request. String pass=res.getWriter().*. } } .

jpg width=100></td><td><b>Java Complete <br>references</b> <ul><pre><li><font color=blue>Author :Gangadhar</font> <li><font color=blue>edition :2007</font> <li><font color=blue>price :450</font> <li><font color=blue>Publicher :Ideal publishers</pre></font></pre> </ul> <td><pre><b>add to cart</b> <img src="click.gif"></pre></td> </tr> <tr> <td><img src="harry.gif"></pre></td> </td> <tr> <td><img src="vbnet.gif" width=80></td><td><b>Web Technology & Designing</b> <ul><pre><li><font color=blue>Author :Kiran-Gangadhar</font> <li><font color=blue>edition :2007</font> <li><font color=blue>price :5950</font> <li><font color=blue>Publicher :jyothi publishers</pre></font></pre> </ul> <td><pre><b>add to cart</b> <img src="click.gif"></pre></td> </tr> <tr> <td><img src="web tech.gif" width=80></td><td><b>Visual Basics</b> <ul><pre><li><font color=blue>Author :Kiran</font> <li><font color=blue>edition :2007</font> <li><font color=blue>price :950</font> <li><font color=blue>Publicher :gangii publishers</pre></font></pre> </ul> <td><pre><b>add to cart</b> <img src="click.gif" width=80></td><td><b>Web Technology & Designing</b> <ul><pre><li><font color=blue>Author :Kiran-Gangadhar</font> <li><font color=blue>edition :2007</font> <li><font color=blue>price :5950</font> <li><font color=blue>Publicher :jyothi publishers</pre></font></pre> </ul> <td><pre><b>add to cart</b> <img src="click.Books Catalog: <html> <head> </head> <body> <center><font color="red" size=7 face="Vivaldi"><b><i>Book Catlog</i></font></center></b> <table> <td><img src=java.jpg" width=80></td><td><b>Harry reference to java</b> <ul><pre><li><font color=blue>Author :Harry Potter</font> <li><font color=blue>edition :2007</font> <li><font color=blue>price :950</font> <li><font color=blue>Publicher :jyothi publishers</pre></font></pre> </ul> <td><pre><b>add to cart</b> <img src="click.gif"></pre></td> </tr> <tr> <td><img src="quick.gif"></pre></td> </tr> </table> .

public class KiranParameters1 extends HttpServlet { public void doGet(HttpServletRequest req.println("<td>"+name+" : "+value +"</td></tr>").*.util.getParameterNames(). import javax.servlet. } } .servlet.http.nextElement().*.println("<html><body><br><center>Books Selected</center><br><table>").println("</table>"). Enumeration ki=req.getParameter(name).*. out. PrintWriter out=res.setContentType("text/html"). } out. while(ki.</body> </html> //servlet program import java. out. import javax. import java. String value=req.getWriter().IOException { res.HttpServletResponse res)throws ServletException.io.hasMoreElements()) { String name=""+ki.*.

Output screens .

.

.

.

search for entries.com/advanced_search. It will help validate the page. a form to act as an interface for http://www. for the other provide default values by using hidden inputs. In each page include the link: http://validator.google. etc. gives the right parameters to the services.w3. o it should contain at least 8 inputs. o string generation form. each record should have at least 3 sub-records (for example I could extend the link elements to also contain multiple comment elements).org/check?uri=referer. A page is considered valid if:   is validated by the W3C validator. a site map. The data should be kept in memory by using a collection (lists. Each information available in the XML file should be presented in the generated HTML. You should use:    text fields for number and text inputs. (For example you could implement an email address book or a bookmark manager. 3 ) Implement a simple web application that allows the user to manipulate a simple database.org/: o integer generation form. radio buttons or drop down lists for enumerated or finite options.) The application should allow the user to:     add entries.that is used by your XML file -. o sequence generation form.) and nothing should be written to the disk. update entries. remove entries. maps. each record should have at least 4 attribute like elements (for example the name or uri element). In order to accomplish this you will have to develop some static HTML files and servlets. acting as a web interface for the web service http://www. each having a form. check boxes for on / off options. Second step: Create an XSLT file -. 2) First step: Create a database like XML (like the one in the example from above) file with:    at least 10 record like elements (for example the link element).to transform the database into a HTML file.ASSIGNMENTS 1) Implement an HTML portal that offers:     a main page describing the project and links to the other pages. three pages.random. .

ac.cse.apl.jhu.uk/awt/9103-Fa08.edu/~hall/java/Servlet-Tutorial http://www.iitb.com/xmlTutorial http://www.com/ www.tizag.References :        http://www.wikiversity.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-Cookies.upriss.ro http://www.apl.html http://www.uvt.html http://beta.in/dbms/Data/Courses/DBIS/Software/servlets/servlet_tutor ial.org/wiki/Web_technologies_--_Laboratory_6_--_20072008_--_info.jhu.html .org.w3schools.

php" extension. . which the server is configured to pass on to PHP.0. ?> </body> </html> Use your browser to access the file with your web server's URL. Think of this as a normal HTML file which happens to have a set of special tags available to you that do a lot of interesting things.0. and efficient alternative to competitors such as Microsoft's ASP. ending with the /hello.php but this depends on the web server's configuration.php file reference.CONTENT BEYOND SYLLABUS. Example #1 Our first PHP script: hello.1/hello. this file will be parsed by PHP and the following output will be sent to your browser: <html> <head> <title>PHP Test</title> </head> <body> <p>Hello World</p> </body> </html> This program is extremely simple and you really did not need to use PHP to create a page like this. When developing locally this URL will be something like http://localhost/hello. Advanced Web Technology Covering the topics like with examples Introduction to PHP Formal models of XML schemas XML transformation languages JavaScript browser programming Web application programming frameworks Web services PHP is a powerful tool for making dynamic and interactive Web pages. Note that the file does not need to be executable or special in any way. PHP is the widely-used.php <html> <head> <title>PHP Test</title> </head> <body> <?php echo '<p>Hello World</p>'. If everything is configured correctly.php or http://127. free. The server finds out that this file needs to be interpreted by PHP because you used the ". All it does is display: Hello World using the PHP echo() statement.