Вы находитесь на странице: 1из 196

S R I M A N A K U L A V IN A Y A G A R E N G IN E E R IN G C O L L E G ( A f f ilia t e d t o P o n d ic h e r r y U n iv e r s it y ) (Accredited by NBA-AICTE, New Delhi & ISO 9001: 2000 Certified Institution) MADAGADIPET, PUDUCHERRY.

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

WEB TECHNOLOGY VI SEMSTER

CS T63 WEB TECHNOLOGY UNIT I Internet Principles and Components: History of the Internet and World Wide Web- HTML protocols HTTP, SMTP, POP3, MIME, IMAP. Domain Name Server, Web Browsers and Web Servers, Dynamic HTML. UNIT II Client Side and Server Side Programming: Introduction to JAVA Scripts and VB Scripts Object Based Scripting for the web. Programming Java Script and VB Script - Structures Functions Arrays Objects, Regular Expression in java script. Java Server Pages - Session and Application management - Session tracking and cookies Access a database from JSP Developing N-tier web application. UNIT III XML and ActiveX: Anatomy of xml document - XML markup-working with elements and attributes - creating valid documents-xml objects and DOM. ActiveX controls: OLE and ActiveX -ActiveX Documents, Server side Active-X Components, ActiveX DLL and ActiveX Exe. UNIT IV Multimedia and Web Application: Multimedia in web design, Audio and video speech synthesis and recognition - Electronic Commerce E-Business Model E-Marketing Online Payments and Security N-tier Architecture. Search and Design: Working of search engines -optimizationSearch interface. UNIT V Web Services: Introduction to Web Services, UDDI, SOAP, WSDL, Web Service Architecture, Developing and deploying web services. Ajax Improving web page performance using Ajax, Programming in Ajax. TEXT BOOKS 1. Deitel and Deitel, Goldberg, Internet and World Wide Web How to Program, Pearson Education Asia, 2001. (UNIT I) 2. Rajkamal, Web Technology, Tata McGraw-Hill, 2001. (UNITs II & IV) 3. John Paul Mueller, Active X from the Ground Up, Tata McGraw-Hill, 1997.(UNIT III) 4. Eric Newcomer, Understanding Web Services: XML, WSDL, SOAP, and UDDI, AddisonWesley, 2002. (UNIT V) REFERENCES 1. Phillip Hanna, JSP 2.0 - The Complete Reference, McGraw-Hill, 2003. 2. Mathew Eernisse, Build Your Own AJAX Web Applications, SitePoint, 2006.

UNIT-I INTERNET PRINCIPLES AND COMPONENTS 2 MARKS 1. Define internet. Network is an interconnection of systems to share data and information. Internet is network of network or collection of heterogeneous networks.

2. Define proxy servers? Proxy servers are related to firewalls prevents hosts on a network from making direct connections to the outside world; a proxy server can act as a go-between. Thus a machine that is prevented from connecting to the external network by a firewall would make a request for a web page from the local proxy server instead of requesting the web page directly from the remote web server.

3. Explain about Internet servers. Mail servers Web servers FTP servers News server DNS servers 4. What is meant by web server? Collection of web pages is stored in a computer for publishing is called web server. Any computer can act as a web server if it is connected to the network. ISP (Internet Service Protocol) is used to connect a system to network.

5. What are types of web server? Application server E-mail server Database server

6. What is meant by web browser? Web browser fetches a page from a web server by a http request. The request includes page address of an http standard. Some of the web browsers are: Mozilla Firefox, Google chrome, Internet explorer.

7. What is meant by web hosting?

A web hosting is a type of Internet hosting service that allows individuals and organizations to make their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own or lease for use by their clients as well as providing Internet connectivity, typically in a data center.

8. What are the issues in web hosting? Hardware expenses Software expenses Labor expenses

9. List out the services provided by the Internet? Electronic Mail World Wide Web FTP Telnet Gopher and Chat

10. What do you mean by World Wide Web? WWW is a distributed system of inter linked pages that include text, pictures, sound and other information. It enables easy access to the information available on the internet.

11. Explain the elements of WWW. Client & server Web languages & protocols Web pages Home page Web browsers and Web sites 12. What is HTML? HTML (Hyper Text Markup Language).This is a file format, based on SGML, for hypertext documents on the Internet. It is very simple and allows for the embedding of images, sounds, video streams, form fields and simple text formatting. References to other objects are embedded using URLs. HTML is a plain text file with commands <markup tags> to tell the Web browsers how to display the file.

13.

How do you change the color of background or text in HTML?

Include the element "bgcolor" with a color code in your body tag: <BODY BGCOLOR="#ffffff" ALINK="#ffff00"> TEXT="#000000" LINK="#cc0000" VLINK="#000066"

14.

Write the format of html program. <HTML> <HEAD> <TITLE> This is the Title </TITLE> </HEAD> <BODY> . Type the body of the program </BODY> </HTML>

15. How do you use a picture as the background in HTML? Include the element "background" with the name of the graphics file: <BODY BACKGROUND="gumby.gif" BGCOLOR="#ffffff" TEXT="#000000" LINK="#cc0000" VLINK="#000066" ALINK="#ffff00">

16. How do you add music to a web page? <A HREF="http://www.snowhawk.com/sounds/hvnearth.mid">Heaven on Earth</A> 17. How do you align text next to a graphic in HTML? <IMG SRC="wflower.jpg" WIDTH="25" HEIGHT="25" ALT="wildflower photo"> Photo of wildflowers in Texas</A> ALIGN="top"BORDER="0"

18. How do you make a graphic a link? <AHREF="http://www.snowhawk.com/wildlife.html"><IMG SRC="leopard.jpg" WIDTH="25" HEIGHT="25" ALIGN="top" BORDER="0" ALT="link to wildlife"></A>

19. How do you make a new paragraph in HTML?

Inserting the <P> tag at the beginning of your paragraph will drop the text down two lines. (If you insert the <BR> tag, it will drop your text down one line.)

20. How do you make headings and text larger or smaller? There are 6 sizes to the heading tags: <H1> tag, <H2> tag, <H3> tag, <H4> tag, <H5> tag, and <H6> tag.

21. How do you make text show as bold? Placing the <B>tag before the text will make everything bold, until you close the tag with</B> (Or using <STRONG>tags</STRONG > will do the same.)

22. How do I make text show in italics? Placing the <I>tag before the text will make everything in italics, until you close the tag with</I> (Using <EM>emphasis tags</EM > will do the same.)

23. How would you make all text on a page green and a little larger than normal, but make all headings yellow? Put the following at the beginning of the Web page: <BODY TEXT=green><BASEFONT SIZE=4>Then make each heading look like this: <H1><FONT COLOR=Yellow>Heading goes here </FONT></H1>

24. Mention some text formatting tags <p> </p> - is used for introducing various paragraphs. <br> - this tag is used for giving an empty blank line. HEADING TAGS - <h1> </h1> .. <h6> </h6> is used to introduce various headings. <h1> is the biggest and h6 is the smallest heading tag. <HR> TAG is used to draw lines and horizontal rules. <B>, <I>, <U> for bold, italic and underline respectively

25. Explain about list tag. TYPES OF LISTS Unordered lists Ordered lists

UNORDERED LISTS It starts with <ul> and ends with </ul> Attributes of Unordered lists TYPE: TYPE = FILLROUND or TYPE = SQUARE

EXAMPLE <UL TYPE = FILLGROUND> <LI> CSE </LI> <LI> IT </LI> </UL>

ORDERED LISTS (NUMBERING) TYPE: Controls the numbering scheme to be used TYPE = 1 will give counting numbers (1,2,> A will give A,B,C.. a will give a,b,c I starts with Capital roman letters I,II,II I starts with small case roman letters START: Alters the numbering sequence, can be set to any numeric value VALUE: Change the numbering sequence in the middle of an ordered list EXAMPLE <OL TYPE = 1 START = 5> <LI> CSE </LI> <LI> IT </LI> </OL> OUTPUT 5 CSE 6 IT

26.

Explain the attributes of table tag with an example.

A table is a two dimensional matrix, consisting of rows and columns. All table related tags are included between <TABLE> </TABLE> tags. <TABLE> <TH> Heading </TH> <TR> Row elements </TR> <TD> Table data values </TD> </TABLE>

ATTRIBUTES OF TABLE TAG ALIGN Horizontal alignment is controlled by the ALIGN attribute. It can be set to LEFT, CENTER, or RIGHT VALIGN Controls the vertical alignment of cell contents. It accepts the values TOP, MIDDLE or BOTTOM WIDTH Sets the WIDTH of a specific number of pixels or to a percentage of the available screen width. BORDER Controls the border to be placed around the table. CELLPADING This attribute controls the distance between the data in a cell and the boundaries of the cell CELLSPACING Controls the spacing between adjacent cells COLSPAN Used to spilt the single cell to one or more columns ROWSPAN Used to spilt the single cell to one or more rows. EXAMPLE <TABLE BORDER = 3 WIDTH = 100 HEIGHT = 200> <TR> <TH> Roll Number </TH> <TH> Age </TH> <TR> <TR> <TD> 1 </TD> <TD 35 </TD> </TR> </TABLE> ALIGN: ALIGN = TOP, MIDDLE, BOTTOM BORDER: Specifies the size of the border to place around the image. WIDTH: Specifies the width of the image in pixels. HEIGHT: Specifies the height of the image in pixels HSPACE: Indicates the amount of space to the left and right of the image VSPACE: Indicates the amount of apace to the top and bottom of the image.

27.

Mention the different types of links.

HTML allows linking to other HTML documents as well as images. There are 3 attributes that can be introduced in BODY tag. LINK Changes the default color of a Hyperlink to whatever color is specified with this tag. ALINK Changes the default color of a hyperlink that is activated to whatever color is specified with this tag. VLINK Changes the default color of a hyperlink that is already visited to whatever color is specified with this tag. NOTE: User can specify the color name of a hyperlink or an equivalent hexadecimal number. EXTERNAL LINKS SYNTAX <A HREF = location name> Hyper Text Message </A>

28.

Explain image maps with its syntax.

When a hyperlink is created on an image, clicking on any part of the image will lead to opening of the document specified in the <A HREF TAG>. Linked regions of an image map are called hot regions and each hot region is associated with a filename.html. Syntax <MAP NAME = map name> ATTRIBUTES OF IMAGE MAPS COORDS: Each of the above shapes takes different coordinates as parameters. Rectangle 4 coordinates (x1, y2, x3, y2) POLYGON: 3 or more coordinates. HREF Takes the name of the .html file that s linked to the particular area on the image. <MAP NAME = fish.jpg> <AREA SHAPE = rect COORDS = 52, 65, 122, 89 HREF = sct.html> </MAP>

29. Explain about html form tag with its attributes. HTML form provides several mechanisms to collect information from people viewing your site. The syntax of the form is <FORM METHOD = POST ACTION = /cgi-bin/formail>

The METHOD attribute indicates the way the web server will organize and send you the form output. Use METHOD = post in a form that causes changes to server data, for example when updating a database. The ACTION attribute in the FORM tag is the path to this script; in this case, it is a common script which emails form data to an address. Most Internet Service Providers will have a script like this on their site. 30. Mention the various form elements. Various elements or controls can be created in FORM using <INPUT> tag. They are Label Text box Text Area Radio button Check box List box Command button Scroll bars

31.

What is the use of frames in html give the syntax of frames? Frames are used to call many html files at the same time. This can be done using <FRAMESET> </FRAMESET> tags. ATTRIBUTES OF FRAMES ROWS This attribute is used to divide the screen into multiple rows. It can be set equal to a list of values. Depending on the required size of each row. The values can A number of pixels Expressed as a percentage of the screen resolution The symbol *, which indicates the remaining space. COLS This attribute is used to divide the screen into multiple columns. EXAMPLE <FRAMESET ROWS = 30 %,*> => Divides the screen into 2 rows, occupying the remaining space <FRAMESET COLS = 50%, 50 %> => Divides the first row into 2 equal columns <FRAME SRC = file1.html> <FRAME SRC = file2.html>

<FRAMESET COLS = 50%, 50 %> => Divides the second row into 2 equal columns <FRAME SRC = file3.html> <FRAME SRC = file4.html> </FRAMESET>

32. What are the different types of HTML protocols? HTTP SMTP POP3 MIME and IMAP

33. What is meant by HTTP? The HTTP protocol is a very simple request/response protocol designed primarily t3o deliver static content. The basic idea of the protocol is that a browser will request a page from a server.

34. What are the components of HTTP URL? The components are Host an optional port path filename section and Query string.

35. List the steps functions of http protocol. Standard protocol for communication between web browsers and web servers. HTTP specifies how a client and server establish a connection, how the client requests data from the server, how the server responds to that request, and finally how the connection is closed. HTTP 1.0 is the currently accepted version of the protocol. It uses MIME to encode data. The basic protocol defines a sequence of 4 steps for each request from a client to the server. Making the connection Making a request

Receiving the response Closing the connection

36. What is SMTP?

Simple Mail Transfer Protocol (SMTP) is the de facto standard for e-mail transmissions across the Internet. SMTP is a relatively simple, text-based protocol, in which one or more recipients of a message are specified (and in most cases verified to exist) along with the message text and possibly other encoded objects. The message is then transferred to a remote server using a procedure of queries and responses between the client and server. Either an end-user's email client, MUA (Mail User Agent), or a relaying server's MTA (Mail Transport Agents) can act as an SMTP client. SMTP (Simple Mail Transfer Protocol) is a TCP/IP protocol used in sending and receiving e-mail. However, since it is limited in its ability to queue messages at the receiving end, it is usually used with one of two other protocols, POP3 or IMAP , that let the user save messages in a server mailbox and download them periodically from the server. In other words, users typically use a program that uses SMTP for sending e-mail and either POP3 or IMAP for receiving e-mail. On Unix-based systems, sendmail is the most widely-used SMTP server for e-mail. A commercial package, Sendmail, includes a POP3 server. Microsoft Exchange includes an SMTP server and can also be set up to include POP3 support. SMTP usually is implemented to operate over Internet port 25. An alternative to SMTP that is widely used in Europe is X.400. Many mail servers now support Extended Simple Mail Transfer Protocol (ESMTP), which allows multimedia files to be delivered as e-mail. 37. What is POP3? POP3 (Post Office Protocol 3). A client server protocol that is used between a user work station and a mail server. POP3 (Post Office Protocol 3) is the most recent version of a standard protocol for receiving email. POP3 is a client/server protocol in which e-mail is received and held for you by your Internet server. Periodically, you (or your client e-mail receiver) check your mail-box on the server and download any mail, probably using POP3. This standard protocol is built into most popular e-mail products, such as Eudora and Outlook Express. It's also built into the Netscape and Microsoft Internet Explorer browsers.
38.

What is the use of MIME?

MIME (Multipurpose Internet Mail Extension) is a way to encode different kinds of data, such as sound and text, to be transmitted over a 7-bit ASCII connection. It also lets the recipient know what kind of data has been sent, so that it can be displayed properly. MIME was originally designed to facilitate multimedia email and to provide an encoding that could get binary data past the most train damaged mail transfer programs. MIME is an open standard for sending multipart, multimedia data through Internet email. MIME was originally intended for email, it has become a widely used technique to describe a files contents so that client software can tell the difference between different kinds of data.

Multipurpose Internet Mail Extensions, a specification for formatting non-ASCII messages so that they can be sent over the Internet. Many e-mail clients now support MIME, which enables them to send and receive graphics, audio, and video files via the Internet mail system. In addition, MIME supports messages in character sets other than ASCII.

There are many predefined MIME types, such as GIF graphics files and PostScript files. It is also possible to define your own MIME types. In addition to e-mail applications, Web browsers also support various MIME types. This enables the browser to display or output files that are not in HTML format. MIME was defined in 1992 by the Internet Engineering Task Force (IETF). A new version, called S/MIME, supports encrypted messages. 39. List the predefined MIME content types. Text Multipart Message Image Audio Video Model Application 40. What is IMAP? Internet Message Access Protocol IMAP provides extensive mechanisms for reading messages or even parts of messages, a feature useful when using a slow modem to read the text part of a multipart message with large audio and video attachments. Since the working assumption is that messages will not be transferred to the user's computer for permanent storage, IMAP provides mechanisms for creating, destroying, and manipulating multiple mailboxes on the server. In this way a user can maintain a mailbox for each correspondent and move messages there from the inbox after they have been read.

41. What is meant by DNS? DNS (Domain Name System). It is a hierarchical naming system for computer services for any resources connected to internet or private network. The important work of DNS protocol is to convert the computer host name into IP address.

42. What are the properties of DNS?

The properties of DNS are: Each label in the domain can contain up to 63 characters. The full domain name should not exceed the length of 253 characters.

The domain name should follow LDH rule.

43. What is DNS server? A DNS server translates the numeric IP addresses to the corresponding Domain name.

44. What is Domain Name? Each host computer on the Internet has a unique number called IP address. And also have a name know as host name. The name of each host computer consists of a series of words separated by dots.

45. What are domain & mention different types of domains Domain is a place where information is available. Domain name extension .edu Servers that provide Educational services .gov About the government of a country.

.mil Servers that provide military information. .org Provide information about the organizations in the world. .com Servers providing commercial services on the Internet.

46. Define DHTML? Dynamic Hyper Text Transfer Protocol

DHTML stands for Dynamic HTML. DHTML is NOT a language or a web standard.

To most people DHTML means the combination of HTML, JavaScript, DOM and CSS.

According to the World Wide Web Consortium (W3C): "Dynamic HTML is a term used by some vendors to describe the combination of HTML, style sheets and scripts that allows documents to be animated." Dynamic HTML is a collective term for a combination of Hypertext Markup Language (HTML) tags and options that can make Web pages more animated and interactive than

previous versions of HTML. Much of dynamic HTML is specified in HTML 4.0. Simple examples of dynamic HTML capabilities include having the color of a text heading change when a user passes a mouse over it and allowing a user to "drag and drop" an image to another place on a Web page. Dynamic HTML can allow Web documents to look and act like desktop applications or multimedia productions.

11 MARKS 1. Explain the internet principles? (5 marks) The Internet (also known simply as the Net) is the worldwide, publicly accessible system of interconnected computer networks that transmit data by packet switching using the standard Internet Protocol (IP). It consists of millions of smaller domestic, academic, business, and government networks, which together carry various information and services, such as electronic mail, online chat, and the interlinked Web pages and other documents of the World Wide Web. Contrary to some common usage, the Internet and the World Wide Web are not synonymous: the Internet is a collection of interconnected computer networks, linked by copper wires, fiber-optic cables, wireless connections etc.; the Web is a collection of interconnected documents, linked by hyperlinks and URLs, and is accessible using the Internet. The Internet also provides many other services including e-mail, file sharing and others described below. 2. Discuss the history of the Internet and World Wide Web? (6 marks) In the late 1960s, one of the authors (HMD) was a graduate student at MIT. His research at MITs Project MAC (now the Laboratory for Computer Sciencethe home of the World Wide Web Consortium) was funded by ARPAthe Advanced Research Projects Agency of the Department of Defense. ARPA sponsored a conference at which several dozen ARPA-funded graduate students were brought together at the University of Illinois at Urbana-Champaign to meet and share ideas. During this

conference, ARPA rolled out the blueprints for networking the main computer systems of about a dozen ARPA-funded universities and research institutions. They were to be connected with communications lines operating at a then-stunning 56 Kbps (i.e., 56,000 bits per second)this at a time when most people (of the few who could) were connecting over telephone lines to computers at a rate of 110 bits per second. There was great excitement at the conference. Researchers at Harvard talked about communicating with the Univac 1108 supercomputer at the University of Utah to handle calculations related to their computer graphics research. Many other intriguing possibilities were raised. Academic research about to take a giant leap forward. Shortly after this conference, ARPA proceeded to implement the ARPANET, which eventually evolved into todays Internet. Things worked out differently from what was originally planned. Rather than enabling researchers to share each others computers, it rapidly became clear that enabling researchers to communicate quickly and easily via what became known as electronic mail (e-mail, for short) was the key early benefit of the ARPANET. This is true even today on the Internet, as e-mail facilitates communications of all kinds among a billion people worldwide. One of the primary goals for ARPANET was to allow multiple users to send and receive information simultaneously over the same communications paths (e.g., phone lines). The network operated with a technique called packet switching, in which digital data was sent in small bundles called packets. The packets contained address, error-control and sequencing information. The address information allowed packets to be routed to their destinations. The sequencing information helped in reassembling the packets which, because of complex routing mechanisms, could actually arrive out of orderinto their original order for presentation to the recipient. Packets from different senders were intermixed on the same lines. This packet-switching technique greatly reduced transmission costs, as compared with the cost of dedicated communications lines.

The network was designed to operate without centralized control. If a portion of the network failed, the remaining working portions would still route packets from senders to receivers over alternative paths for reliability. The protocol for communicating over the ARPANET became known as TCPthe Transmission Control Protocol. TCP ensured that messages were properly routed from sender to receiver and that they arrived intact. As the Internet evolved, organizations worldwide were implementing their own networks for both interorganization (i.e., within the organization) and interorganization (i.e., between organizations) communications. A wide variety of networking hardware and software appeared. One challenge was to get these different networks to communicate. ARPA accomplished this with the development of IPthe Internet Protocol, truly creating a network of networks, the current architecture of the Internet. The combined set of protocols is now commonly called TCP/IP. Initially, Internet use was limited to universities and research institutions; then the military began using the Internet. Eventually, the government decided to allow access to the Internet for commercial purposes. Initially, there was resentment in the research and military communitiesthese groups were concerned that response times would become poor as the Net became saturated with users. In fact, the exact opposite has occurred. Businesses rapidly realized that they could tune their operations and offer new and better services to their clients, so they started spending vast amounts of money to develop and enhance the Internet. This generated fierce competition among communications carriers and hardware and software suppliers to meet this demand. The result is that bandwidth (i.e., the

information-carrying capacity) on the Internet has increased tremendously and costs have decreased significantly. The World Wide Web allows computer users to locate and view multimedia-based documents on almost any subject over the Internet. Though the Internet was developed decades ago, the web is a relatively recent creation. In 1989, Tim Berners-Lee of CERN (the European Organization for Nuclear Research) began to develop a technology for sharing information via hyperlinked text documents. Berners-Lee called his invention the Hyper Text Markup Language (HTML). He also wrote communication protocols to form the backbone of his new information system, which he called the World Wide Web. In particular, he wrote the Hypertext Transfer Protocol (HTTP)a communications protocol used to send information over the web. Web use exploded with the availability in 1993 of the Mosaic browser, which featured a user-friendly graphical interface. Marc Andreessen, whose team at NCSA developed Mosaic, went on to found Netscape, the company that many people credit with initiating the explosive Internet economy of the late 1990s. In the past, most computer applications ran on computers that were not connected to one another, whereas todays applications can be written to communicate among the worlds computers. The Internet mixes computing and communications technologies. It makes our work easier. It makes information instantly and conveniently accessible worldwide. It enables individuals and small businesses to get worldwide exposure. It is changing the way business is done. People can search for the best prices on virtually any product or service. Special-interest communities can stay in touch with one another. Researchers can be made instantly aware of the latest breakthroughs. The Internet and the web are surely among humankinds most profound creations.

3. Explain briefly about the fundamental in HTML elements? (11 marks) Some Fundamental HTML Elements HTML Element Syntax

An HTML element starts with a start tag / opening tag An HTML element ends with an end tag / closing tag The element content is everything between the start and the end tag Some HTML elements have empty content Empty elements are closed in the start tag Most HTML elements can have attributes

ELEMENTS FOR THE HEAD SECTION The HEAD section of a document may only contain the following elements. If any other elements, or text, occur inside the HEAD section, the browser should assume the HEAD ends here, and start rendering the BODY. See the syntax rules for an explanation of the syntax used in the overview.

TITLE - Document title ISINDEX - Primitive search

META - Meta-information LINK - Site structure BASE - Document location SCRIPT - Inline script STYLE - Style information

ELEMENTS FOR THE BODY SECTION Block-level elements The BODY of a document consists of multiple block elements. If plain text is found inside the body, it is assumed to be inside a paragraph P. See the syntax rules for an explanation of the syntax used in the overview. Headings

Lists H1 - Level 1 header H2 - Level 2 header H3 - Level 3 header H4 - Level 4 header H5 - Level 5 header H6 - Level 6 header
UL - Unordered list OL - Ordered list DIR - Directory list MENU - Menu item list LI - List item DL - Definition list o DT - Definition o DD- Definition

term

Text containers P - Paragraph PRE - Preformatted text BLOCKQUOTE - Large quotation


Others

DIV - Logical division CENTER - Centered division FORM - Input form HR - Horizontal rule TABLE - Tables

ADDRESS - Address information

Text-level elements These elements are used to mark up text inside block level elements. Some block level elements exclude certain text level elements, and some text level elements may only appear inside specific block level elements. This is documented in the section on that block level element. Logical markup Physical markup

EM - Emphasized text STRONG - Strongly emphasized DFN - Definition of a term CODE - Code fragment SAMP - Sample text KBD - Keyboard input

TT - Teletype I - Italics B - Bold U - Underline STRIKE - Strikeout BIG - Larger text

VAR - Variable CITE - Short citation

SMALL - Smaller SUB - Subscript SUP

text

- Superscript

Special markup A - Anchor BASEFONT - Default font size IMG - Image APPLET - Java applet PARAM- Parameters for Java applet FONT - Font modification BR - Line break MAP - Client-side image map

Forms INPUT - Input field, button, etc. SELECT - Selection list OPTION - Selection list option

TEXTAREA - Input area Tables


CAPTION - Table caption TR - Table row TH - Header cell TD - Table cell INPUT - Input field, button, etc. ISINDEX - Primitive search I - Italics KBD - Keyboard input LINK - Site structure LI - List item MAP - Client-side image map

ADDRESS - Address information APPLET - Java applet AREA - Hotzone in image map A - Anchor BASE - Document location BASEFONT - Default font size BIG - Larger text

BLOCKQUOTE - Large quotation BODY - Document body BR - Line break B - Bold CAPTION - Table caption CENTER - Centered division CITE - Short citation CODE - Code fragment DD - Definition DFN - Definition of a term DIR - Directory list DIV - Logical division DL - Definition list DT - Definition term EM - Emphasized text FONT - Font modification FORM - Input form H1 - Level 1 header H2 - Level 2 header H3 - Level 3 header H4 - Level 4 header H5 - Level 5 header H6 - Level 6 header HEAD - Document head

MENU - Menu item list META - Meta-information OL - Ordered list OPTION - Selection list option PARAM - Parameter for Java applet PRE - Preformatted text P - Paragraph SAMP - Sample text SCRIPT - Inline script SELECT - Selection list SMALL - Smaller text STRIKE - Strikeout STRONG - Strongly emphasized STYLE - Style information SUB - Subscript SUP - Superscript TABLE - Tables TD - Table cell TEXTAREA - Input area TH - Header cell TITLE - Document title TR - Table row TT - Teletype UL - Unordered list

HR - Horizontal rule HTML - HTML Document

U - Underline VAR - Variable An unordered list:


Lists An ordered list: 1. The first list item 2. The second list item 3. The third list item HTML Unordered Lists

List item List item List item

An unordered list starts with the <ul> tag. Each list item starts with the <li> tag. The list items are marked with bullets (typically small black circles). <ul> <li>Coffee</li> <li>Milk</li> </ul>

How the HTML code above looks in a browser:


Coffee Milk

HTML Ordered Lists An ordered list starts with the <ol> tag. Each list item starts with the <li> tag. The list items are marked with numbers. <ol> <li>Coffee</li> <li>Milk</li> </ol> How the HTML code above looks in a browser: 1. Coffee 2. Milk HTML Definition Lists A definition list is a list of items, with a description of each item.

The <dl> tag defines a definition list. The <dl> tag is used in conjunction with <dt> (defines the item in the list) and <dd> (describes the item in the list): <dl> <dt>Coffee</dt> <dd>- black hot drink</dd> <dt>Milk</dt> <dd>- white cold drink</dd> </dl> How the HTML code above looks in a browser: Coffee - black hot drink Milk - white cold drink

HTML List Tags Tag <ol> <ul> <li> <dl> <dt> <dd> Description Defines an ordered list Defines an unordered list Defines a list item Defines a definition list Defines an item in a definition list Defines a description of an item in a definition list

HTML Tables Tables are defined with the <table> tag. A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td> tag). td stands for "table data," and holds the content of a data cell. A <td> tag can contain text, links, images, lists, forms, other tables, etc. Table Example

<table border="1"> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td>row 2, cell 1</td> <td>row 2, cell 2</td> </tr> </table> How the HTML code above looks in a browser: row 1, cell 1 row 2, cell 1 row 1, cell 2 row 2, cell 2

HTML Tables and the Border Attribute If you do not specify a border attribute, the table will be displayed without borders. Sometimes this can be useful, but most of the time, we want the borders to show. To display a table with borders, specify the border attribute:

<table border="1"> <tr> <td>Row 1, cell 1</td> <td>Row 1, cell 2</td> </tr> </table> HTML Table Headers Header information in a table are defined with the <th> tag. The text in a th element will be bold and centered. <table border="1"> <tr> <th>Header 1</th> <th>Header 2</th> </tr> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td>row 2, cell 1</td>

<td>row 2, cell 2</td> </tr> </table> How the HTML code above looks in a browser: Header 1 Header 2 row 1, cell 1 row 1, cell 2 row 2, cell 1 row 2, cell 2 HTML Table Tags Tag <table> <th> <tr> <td> <caption> <colgroup> <col /> <thead> <tbody> <tfoot> Description Defines a table Defines a table header Defines a table row Defines a table cell Defines a table caption Defines a group of columns in a table, for formatting Defines attribute values for one or more columns in a table Groups the header content in a table Groups the body content in a table Groups the footer content in a table

HTML Forms HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons and more. A form can also contain select lists, text area, field set, legend, and label elements. The <form> tag is used to create an HTML form: <form> . input elements . </form> HTML Forms - The Input Element The most important form element is the input element. The input element is used to select user information. An input element can vary in many ways, depending on the type attribute. An input element can be of type text field, checkbox, password, radio button, submit button, and more.

The most used input types are described below. Text Fields <input type="text" /> defines a one-line input field that a user can enter text into: <form> First name: <input type="text" name="firstname" /><br /> Last name: <input type="text" name="lastname" /> </form> How the HTML code above looks in a browser: First name: Last name:

Note: The form itself is not visible. Also note that the default width of a text field is 20 characters. Password Field <input type="password" /> defines a password field: <form> Password: <input type="password" name="pwd" /> </form>

How the HTML code above looks in a browser: Password: Note: The characters in a password field are masked (shown as asterisks or circles). Radio Buttons <input type="radio" /> defines a radio button. Radio buttons let a user select ONLY ONE one of a limited number of choices: <form> <input type="radio" name="sex" value="male" /> Male<br /> <input type="radio" name="sex" value="female" /> Female </form> How the HTML code above looks in a browser: Male Female Checkboxes

<input type="checkbox" /> defines a checkbox. Checkboxes let a user select ONE or MORE options of a limited number of choices. <form> <input type="checkbox" name="vehicle" value="Bike" /> I have a bike<br /> <input type="checkbox" name="vehicle" value="Car" /> I have a car </form> How the HTML code above looks in a browser: I have a bike I have a car Submit Button <input type="submit" /> defines a submit button. A submit button is used to send form data to a server. The data is sent to the page specified in the form's action attribute. The file defined in the action attribute usually does something with the received input: <form name="input" action="html_form_action.asp" method="get"> Username: <input type="text" name="user" /> <input type="submit" value="Submit" /> </form>

How the HTML code above looks in a browser: Username:

Submit

If you type some characters in the text field above, and click the "Submit" button, the browser will send your input to a page called "html_form_action.asp". The page will show you the received input. HTML Form Tags Tag <form> <input /> <textarea> <label> <fieldset> <legend> <select> <optgroup> Description Defines an HTML form for user input Defines an input control Defines a multi-line text input control Defines a label for an input element Defines a border around elements in a form Defines a caption for a fieldset element Defines a select list (drop-down list) Defines a group of related options in a select list

<option> <button> HTML Frames

Defines an option in a select list Defines a push button

With frames, you can display more than one HTML document in the same browser window. Each HTML document is called a frame, and each frame is independent of the others. The disadvantages of using frames are:

The web developer must keep track of more HTML documents It is difficult to print the entire page

The HTML frameset Element The frameset element holds two or more frame elements. Each frame element holds a separate document. The frameset element states only HOW MANY columns or rows there will be in the frameset. The HTML frame Element The <frame> tag defines one particular window (frame) within a frameset. In the example below we have a frameset with two columns. The first column is set to 25% of the width of the browser window. The second column is set to 75% of the width of the browser window. The document "frame_a.htm" is put into the first column, and the document "frame_b.htm" is put into the second column:

<frameset cols="25%,75%"> <frame src="frame_a.htm" /> <frame src="frame_b.htm" /> </frameset> Note: The frameset column size can also be set in pixels (cols="200,500"), and one of the columns can be set to use the remaining space, with an asterisk (cols="25%,*"). HTML Frame Tags Tag <frameset> <frame /> <noframes> <iframe> Description Defines a set of frames Defines a sub window (a frame) Defines a noframe section for browsers that do not handle frames Defines an inline sub window (frame)

4. What are the different types of web protocols? (2 marks) A protocol is a set of rules defining how computers communicate how address work, how data is split into packets etc.

The protocols most commonly used are TCP/IP UDP FTP SNMP SMTP etc... 5. Explain briefly about the Hypertext Transport Protocol (HTTP)? (11 marks) HTTP, the Hypertext Transport Protocol, is the standard protocol for communication between the web browsers and the web servers. It is a stateless protocol that specifies how a client and a server establish a connection, how the client request data from the server, how the server responds to the server, and finally how the connection is closed. HTTP is a form of Communication Protocol The Basic Structure of HTTP Communication follows: Request-Response Model

Request: Client sends a Request to a Server by: clicking a link on a webpage submitting a form typing a web page address in the browser address field HTTP Request Message: The Browser uses the URL to create the request message The HTTP request message consists of: Request/ start line

requests headers / header field Blank line request / message body (optional) Start line /Request line: Consists of three parts: 1. Request Method (Example: GET) 2. Request-URI portion of web address 3. HTTP version (Example: HTTP/1.1)

REQUEST URI: Second part of the Start line is known as Request-URI Uniform Resource Identifier (URI) is a string of characters used to identify a name or a resource on the Internet. Such identification enables interaction with representations of the resource over a network (typically the World Wide Web) using specific protocols

The URL concept: URL means Uniform Resource Locator Its a standard way of specifying any kind of information available on the Internet Four elements of a URL specification: Method (i.e., the protocol for object retrieval) Host (i.e., location hostname or IP-address) Port (i.e., port-number for contacting server) Path (i.e., pathname of the resources file) The URL Format:

URN, URC, URL: URNs are used for identification, URCs for including meta-information. URLs for locating or finding resources

Comparison URN vs. URL: A URN is similar to a person's name, while a URL is like a street address. The URN defines something's identity, while the URL provides a location. Essentially, "what" vs. "where". HTTP Response: The Server receive a request and uses its URL to decide how to handle it it might simply fetch an html file and return its content back to the client it might execute an external program Browser does not care how the request is handled all it needs is a response The browser reads the HTML tags in the response and formats the page onto your screen. HTML Response-Example: HTTP/1.1 200 OK Last-Modified: Mon, 20Mar 2006 23:23:07 GMT Date:Tue, 30 Mar 2006 18:00:01 GMT Status: 200 Content-Type: text/html Servlet-Engine: Tomcat Web Server/5.0 Content-Length: 59 <html> <body> <h1> hello world!</h1> </body> </html> 6. Explain the briefly about Simple Mail Transfer Protocol (SMTP)? (11 marks) Within the Internet, e-mail is delivered by having the source machine establish a TCP connection to port 25 of the destination machine. Listening to this port is an e-mail daemon that speaks SMTP (Simple Mail Transfer Protocol). This daemon accepts incoming connections and copies messages from them into the appropriate mailboxes. If a message cannot be delivered, an error report containing the first part of the undeliverable message is returned to the sender. SMTP is a simple ASCII protocol. After establishing the TCP connection to port 25, the sending machine, operating as the client, waits for the receiving machine, operating as the server, to talk first. The server starts by sending a line of text giving its identity and telling whether it is prepared to receive mail. If it is not, the client releases the connection and tries again later. If the server is willing to accept e-mail, the client announces whom the e-mail is coming from and whom it is going to. If such a recipient exists at the destination, the server gives the client the go-ahead to send the message. Then the client sends the message and the server acknowledges it. No checksums are needed because TCP provides a reliable byte stream. If there is more e-mail, that is now sent. When all the e-mail has been exchanged in both directions, the connection is released. A sample dialog for sending the message of Fig., including the numerical codes used by SMTP, is shown in Fig. The lines sent by the client are marked C:. Those sent by the server are marked S.

Simple Mail Transfer Protocol (SMTP) is the de facto standard for e-mail transmissions across the Internet. Formally SMTP is defined in RFC 821 (STD 10) as amended by RFC 1123 (STD 3). The protocol used today is also known as ESMTP and defined in RFC 2821. SMTP is a relatively simple, text-based protocol, in which one or more recipients of a message are specified (and in most cases verified to exist) along with the message text and possibly other encoded objects. The message is then transferred to a remote server using a procedure of queries and responses between the client and server. Either an end-user's email client, a.k.a. MUA (Mail User Agent), or a relaying server's MTA (Mail Transport Agents) can act as an SMTP client. An email client knows the outgoing mail SMTP server from its configuration. A relaying server typically determines which SMTP server to connect to by looking up the MX (Mail eXchange) DNS record for each recipient's domain name (the part of the email address to the right of the at (@) sign). Conformant MTAs (not all) fall back to a simple A record in the case of no MX. Some current mail transfer agents will also use SRV records, a more general form of MX, though these are not widely adopted. (Relaying servers can also be configured to use a smart host.) The SMTP client initiates a TCP connection to server's port 25 (unless overridden by configuration). It is quite easy to test an SMTP server using the telnet program (see below). SMTP is a "push" protocol that does not allow one to "pull" messages from a remote server on demand. To do this a mail client must use POP3 or IMAP. Another SMTP server can trigger a delivery in SMTP using ETRN. A few comments about Fig. may be helpful. The first command from the client is indeed HELO. Of the various four-character abbreviations for HELLO, this one has numerous advantages over its biggest competitor. Why all the commands had to be four characters has been lost in the mists of time. In Fig. , the message is sent to only one recipient, so only one RCPT command is used. Such commands are allowed to send a single message to multiple receivers. Each one is individually acknowledged or rejected. Even if some recipients are rejected (because they do not exist at the destination), the message can be sent to the other ones.

Transferring a message from elinor@abcd.com to carolyn@xyz.com.

Finally, although the syntax of the four-character commands from the client is rigidly specified, the syntax of the replies is less rigid. Only the numerical code really counts. Each implementation can put whatever string it wants after the code. To get a better feel for how SMTP and some of the other protocols described in this chapter work, try them out. In all cases, first go to a machine connected to the Internet. On a UNIX system, in a shell, type telnet mail.isp.com 25 substituting the DNS name of your ISP's mail server for mail.isp.com. On a Windows system, click on Start, then Run, and type the command in the dialog box. This command will establish a telnet (i.e., TCP) connection to port 25 on that machine. Port 25 is the SMTP port (see or some common ports). You will probably get a response something like this: Trying 192.30.200.66... Connected to mail.isp.com Escape character is '^]'. 220 mail.isp.com Smail #74 ready at Thu, 25 Sept 2002 13:26 +0200 The first three lines are from telnet telling you what it is doing. The last line is from the SMTP server on the remote machine announcing its willingness to talk to you and accept e-mail. To find out what commands it accepts, type HELP From this point on, a command sequence such as the one in Fig. is possible, starting with the client's HELO command. It is worth noting that the use of lines of ASCII text for commands is not an accident. Most Internet protocols work this way. Using ASCII text makes the protocols easy to test and debug. They can be tested by sending commands manually, as we saw above, and dumps of the messages are easy to read.

Even though the SMTP protocol is completely well defined, a few problems can still arise. One problem relates to message length. Some older implementations cannot handle messages exceeding 64 KB. Another problem relates to timeouts. If the client and server have different timeouts, one of them may give up while the other is still busy, unexpectedly terminating the connection. Finally, in rare situations, infinite mailstorms can be triggered. For example, if host 1 holds mailing list A and host 2 holds mailing list B and each list contains an entry for the other one, then a message sent to either list could generate a never-ending amount of e-mail traffic unless somebody checks for it. To get around some of these problems, extended SMTP (ESMTP) has been defined in RFC 2821. Clients wanting to use it should send an EHLO message instead of HELO initially. If this is rejected, then the server is a regular SMTP server, and the client should proceed in the usual way. If the EHLO is accepted, then new commands and parameters are allowed. 6. Write a short note on POP3 (Post Office Protocol Version 3)? (6 marks) Unfortunately, this solution creates another problem: how does the user get the e-mail from the ISP's message transfer agent? The solution to this problem is to create another protocol that allows user transfer agents (on client PCs) to contact the message transfer agent (on the ISP's machine) and allow e-mail to be copied from the ISP to the user. One such protocol is POP3 (Post Office Protocol Version 3), which is described in RFC 1939. The situation that used to hold (both sender and receiver having a permanent connection to the Internet) is illustrated in Fig. A situation in which the sender is (currently) on-line but the receiver is not is illustrated in Fg. Figure (a) Sending and reading mail when the receiver has a permanent Internet connection and the user agent runs on the same machine as the message transfer agent. (b) Reading e-mail when the receiver has a dial-up connection to an ISP.

POP3 begins when the user starts the mail reader. The mail reader calls up the ISP (unless there is already a connection) and establishes a TCP connection with the message transfer agent at port 110. Once the connection has been established, the POP3 protocol goes through three states in sequence: 1. Authorization. 2. Transactions. 3. Update. The authorization state deals with having the user log in. The transaction state deals with the user collecting the e-mails and marking them for deletion from the mailbox. The update state actually causes the e-mails to be deleted.

This behavior can be observed by typing something like: telnet mail.isp.com 110 where mail.isp.com represents the DNS name of your ISP's mail server. Telnet establishes a TCP connection to port 110, on which the POP3 server listens. Upon accepting the TCP connection, the server sends an ASCII message announcing that it is present. Usually, it begins with +OK followed by a comment. An example scenario is shown in Fig starting after the TCP connection has been established. As before, the lines marked C: are from the client (user) and those marked S: are from the server (message transfer agent on the ISP's machine). Using POP3 to fetch three messages.

During the authorization state, the client sends over its user name and then its password. After a successful login, the client can then send over the LIST command, which causes the server to list the contents of the mailbox, one message per line, giving the length of that message. The list is terminated by a period. Then the client can retrieve messages using the RETR command and mark them for deletion with DELE. When all messages have been retrieved (and possibly marked for deletion), the client gives the QUIT command to terminate the transaction state and enter the update state. When the server has deleted all the messages, it sends a reply and breaks the TCP connection. While it is true that the POP3 protocol supports the ability to download a specific message or set of messages and leave them on the server, most e-mail programs just download everything and empty the mailbox. This behavior means that in practice, the only copy is on the user's hard disk. If that crashes, all e-mail may be lost permanently. Let us now briefly summarize how e-mail works for ISP customers. Elinor creates a message for Carolyn using some e-mail program (i.e., user agent) and clicks on an icon to send it. The e-mail program hands the message over to the message transfer agent on Elinor's host. The message transfer agent sees that it is directed to carolyn@xyz.com so it uses DNS to look up the MX record for xyz.com (where xyz.com is Carolyn's ISP). This query returns the DNS name of xyz.com's mail server. The message transfer agent now looks up the IP address of this machine using DNS again, for example, using gethostbyname. It then establishes a TCP connection to the SMTP server on port 25 of this machine. Using an SMTP command sequence analogous to that of Fig., it transfers the message to Carolyn's mailbox and breaks the TCP connection.

In due course of time, Carolyn boots up her PC, connects to her ISP, and starts her e-mail program. The email program establishes a TCP connection to the POP3 server at port 110 of the ISP's mail server machine. The DNS name or IP address of this machine is typically configured when the e-mail program is installed or the subscription to the ISP is made. After the TCP connection has been established, Carolyn's e-mail program runs the POP3 protocol to fetch the contents of the mailbox to her hard disk using commands similar to those of Fig... Once all the e-mail has been transferred, the TCP connection is released. In fact, the connection to the ISP can also be broken now, since all the e-mail is on Carolyn's hard disk. Of course, to send a reply, the connection to the ISP will be needed again, so it is not generally broken right after fetching the e-mail. 7. Write short notes on Multipurpose Internet Mail Extensions (MIME)? (6 marks) In the early days of the ARPANET, e-mail consisted exclusively of text messages written in English and expressed in ASCII. For this environment, RFC 822 did the job completely: it specified the headers but left the content entirely up to the users. Nowadays, on the worldwide Internet, this approach is no longer adequate. The problems include sending and receiving 1. 2. 3. 4. Messages in languages with accents (e.g., French and German). Messages in non-Latin alphabets (e.g., Hebrew and Russian). Messages in languages without alphabets (e.g., Chinese and Japanese). Messages not containing text at all (e.g., audio or images).

A solution was proposed in RFC 1341 and updated in RFCs 20452049. This solution, called MIME (Multipurpose Internet Mail Extensions) is now widely used. We will now describe it. For additional information about MIME, see the RFCs. The basic idea of MIME is to continue to use the RFC 822 format, but to add structure to the message body and define encoding rules for non-ASCII messages. By not deviating from RFC 822, MIME messages can be sent using the existing mail programs and protocols. All that has to be changed are the sending and receiving programs, which users can do for themselves. MIME defines five new message headers, as shown in Fig.. The first of these simply tells the user agent receiving the message that it is dealing with a MIME message, and which version of MIME it uses. Any message not containing a MIME-Version: header is assumed to be an English plaintext message and is processed as such. RFC 822 headers added by MIME.

The Content-Description: header is an ASCII string telling what is in the message. This header is needed so the recipient will know whether it is worth decoding and reading the message. If the string says: ''Photo of Barbara's hamster'' and the person getting the message is not a big hamster fan, the message will probably be discarded rather than decoded into a high-resolution color photograph.

The Content-Id: header identifies the content. It uses the same format as the standard Message-Id: header. The Content-Transfer-Encoding: tells how the body is wrapped for transmission through a network that may object to most characters other than letters, numbers, and punctuation marks. Five schemes (plus an escape to new schemes) are provided. The simplest scheme is just ASCII text. ASCII characters use 7 bits and can be carried directly by the e-mail protocol provided that no line exceeds 1000 characters. The next simplest scheme is the same thing, but using 8-bit characters, that is, all values from 0 up to and including 255. This encoding scheme violates the (original) Internet e-mail protocol but is used by some parts of the Internet that implement some extensions to the original protocol. While declaring the encoding does not make it legal, having it explicit may at least explain things when something goes wrong. Messages using the 8-bit encoding must still adhere to the standard maximum line length. Even worse are messages that use binary encoding. These are arbitrary binary files that not only use all 8 bits but also do not even respect the 1000-character line limit. Executable programs fall into this category. No guarantee is given that messages in binary will arrive correctly, but some people try anyway. The correct way to encode binary messages is to use base64 encoding, sometimes called ASCII armor. In this scheme, groups of 24 bits are broken up into four 6-bit units, with each unit being sent as a legal ASCII character. The coding is ''A'' for 0, ''B'' for 1, and so on, followed by the 26 lower-case letters, the ten digits, and finally + and / for 62 and 63, respectively. The = = and = sequences indicate that the last group contained only 8 or 16 bits, respectively. Carriage returns and line feeds are ignored, so they can be inserted at will to keep the lines short enough. Arbitrary binary text can be sent safely using this scheme. For messages that are almost entirely ASCII but with a few non-ASCII characters, base64 encoding is somewhat inefficient. Instead, an encoding known as quoted-printable encoding is used. This is just 7-bit ASCII, with all the characters above 127 encoded as an equal sign followed by the character's value as two hexadecimal digits. In summary, binary data should be sent encoded in base64 or quoted-printable form. When there are valid reasons not to use one of these schemes, it is possible to specify a user-defined encoding in the ContentTransfer-Encoding: header. The last header shown in Fig is really the most interesting one. It specifies the nature of the message body. Seven types are defined in RFC 2045, each of which has one or more subtypes. The type and subtype are separated by a slash, as in Content-Type: video/mpeg The subtype must be given explicitly in the header; no defaults are provided. The initial list of types and subtypes specified in RFC 2045 is given in Fig. Many new ones have been added since then, and additional entries are being added all the time as the need arises. Let us now go briefly through the list of types. The text type is for straight ASCII text. The text/plain combination is for ordinary messages that can be displayed as received, with no encoding and no further processing. This option allows ordinary messages to be transported in MIME with only a few extra headers.

The MIME types and subtypes defined in RFC 2045.

The text/enriched subtype allow a simple markup language to be included in the text. This language provides a system-independent way to express boldface, italics, smaller and larger point sizes, indentation, justification, sub- and superscripting, and simple page layout. The markup language is based on SGML, the Standard Generalized Markup Language also used as the basis for the World Wide Web's HTML. For example, the message The <bold> time </bold> has come the <italic> walrus </italic> said ... would be displayed as The time has come the walrus said... It is up to the receiving system to choose the appropriate rendition. If boldface and italics are available, they can be used; otherwise, colors, blinking, underlining, reverse video, etc., can be used for emphasis. Different systems can, and do, make different choices. When the Web became popular, a new subtype text/html was added (in RFC 2854) to allow Web pages to be sent in RFC 822 e-mail. A subtype for the extensible markup language, text/xml, is defined in RFC 3023. We will study HTML and XML later in this chapter. The next MIME type is image, which is used to transmit still pictures. Many formats are widely used for storing and transmitting images nowadays, both with and without compression. Two of these, GIF and JPEG, are built into nearly all browsers, but many others exist as well and have been added to the original list. The audio and video types are for sound and moving pictures, respectively. Please note that video includes only the visual information, not the soundtrack. If a movie with sound is to be transmitted, the video and audio portions may have to be transmitted separately, depending on the encoding system used. The first video format defined was the one devised by the modestly-named Moving Picture Experts Group (MPEG), but others have been added since. In addition to audio/basic, a new audio type, audio/mpeg was added in RFC 3003 to allow people to e-mail MP3 audio files. The application type is a catchall for formats that require external processing not covered by one of the other types. An octet-stream is just a sequence of uninterpreted bytes. Upon receiving such a stream, a user agent should probably display it by suggesting to the user that it be copied to a file and prompting for a file name. Subsequent processing is then up to the user.

The other defined subtype is postscript, which refers to the PostScript language defined by Adobe Systems and widely used for describing printed pages. Many printers have built-in PostScript interpreters. Although a user agent can just call an external PostScript interpreter to display incoming PostScript files, doing so is not without some danger. PostScript is a full-blown programming language. Given enough time, a sufficiently masochistic person could write a C compiler or a database management system in PostScript. Displaying an incoming PostScript message is done by executing the PostScript program contained in it. In addition to displaying some text, this program can read, modify, or delete the user's files, and have other nasty side effects. The message type allows one message to be fully encapsulated inside another. This scheme is useful for forwarding e-mail, for example. When a complete RFC 822 message is encapsulated inside an outer message, the rfc822 subtype should be used. The partial subtype makes it possible to break an encapsulated message into pieces and send them separately (for example, if the encapsulated message is too long). Parameters make it possible to reassemble all the parts at the destination in the correct order. Finally, the external-body subtype can be used for very long messages (e.g., video films). Instead of including the MPEG file in the message, an FTP address is given and the receiver's user agent can fetch it over the network at the time it is needed. This facility is especially useful when sending a movie to a mailing list of people, only a few of whom are expected to view it (think about electronic junk mail containing advertising videos). The final type is multipart, which allows a message to contain more than one part, with the beginning and end of each part being clearly delimited. The mixed subtype allows each part to be different, with no additional structure imposed. Many e-mail programs allow the user to provide one or more attachments to a text message. These attachments are sent using the multipart type. In contrast to multipart, the alternative subtype, allows the same message to be included multiple times but expressed in two or more different media. For example, a message could be sent in plain ASCII, in enriched text, and in PostScript. A properly-designed user agent getting such a message would display it in PostScript if possible. Second choice would be enriched text. If neither of these were possible, the flat ASCII text would be displayed. The parts should be ordered from simplest to most complex to help recipients with pre-MIME user agents make some sense of the message (e.g., even a pre-MIME user can read flat ASCII text). The alternative subtype can also be used for multiple languages. In this context, the Rosetta Stone can be thought of as an early multipart/alternative message. A multimedia example is shown in Fig.. Here a birthday greeting is transmitted both as text and as a song. If the receiver has an audio capability, the user agent there will fetch the sound file, birthday.snd, and play it. If not, the lyrics are displayed on the screen in stony silence. The parts are delimited by two hyphens followed by a (software-generated) string specified in the boundary parameter. Note that the Content-Type header occurs in three positions within this example. At the top level, it indicates that the message has multiple parts. Within each part, it gives the type and subtype of that part. Finally, within the body of the second part, it is required to tell the user agent what kind of an external file it is to fetch. To indicate this slight difference in usage, we have used lower case letters here, although all headers are case insensitive. The content-transfer-encoding is similarly required for any external body that is not encoded as 7-bit ASCII.

A multipart message containing enriched and audio alternatives.

Getting back to the subtypes for multipart messages, two more possibilities exist. The parallel subtype is used when all parts must be ''viewed'' simultaneously. For example, movies often have an audio channel and a video channel. Movies are more effective if these two channels are played back in parallel, instead of consecutively. Finally, the digest subtype is used when many messages are packed together into a composite message. For example, some discussion groups on the Internet collect messages from subscribers and then send them out to the group as a single multipart/digest message. 8. Explain briefly about Internet Message Access Protocol (IMAP)? (5 marks) For a user with one e-mail account at one ISP that is always accessed from one PC, POP3 works fine and is widely used due to its simplicity and robustness. However, it is a computer-industry truism that as soon as something works well, somebody will start demanding more features (and getting more bugs). That happened with e-mail, too. For example, many people have a single e-mail account at work or school and want to access it from work, from their home PC, from their laptop when on business trips, and from cybercafes when on so-called vacation. While POP3 allows this, since it normally downloads all stored messages at each contact, the result is that the user's e-mail quickly gets spread over multiple machines, more or less at random; some of them not even the users. This disadvantage gave rise to an alternative final delivery protocol, IMAP (Internet Message Access Protocol), which is defined in RFC 2060. Unlike POP3, which basically assumes that the user will clear out the mailbox on every contact and work off-line after that, IMAP assumes that all the e-mail will remain on the server indefinitely in multiple mailboxes. IMAP provides extensive mechanisms for reading messages or even parts of messages, a feature useful when using a slow modem to read the text part of a multipart message with large audio and video attachments. Since the working assumption is that messages will not be transferred to the user's computer for permanent storage, IMAP provides mechanisms for

creating, destroying, and manipulating multiple mailboxes on the server. In this way a user can maintain a mailbox for each correspondent and move messages there from the inbox after they have been read. IMAP has many features, such as the ability to address mail not by arrival number as is done in , but by using attributes (e.g., give me the first message from Bobbie). Unlike POP3, IMAP can also accept outgoing e-mail for shipment to the destination as well as deliver incoming e-mail. The general style of the IMAP protocol is similar to that of POP3 as shown in Fig., except that are there dozens of commands. The IMAP server listens to port 143. A comparison of POP3 and IMAP is given in Fig.. It should be noted, however, that not every ISP supports both protocols and not every e-mail program supports both protocols. Thus, when choosing an e-mail program, it is important to find out which protocol(s) it supports and make sure the ISP supports at least one of them. A comparison of POP3 and IMAP

9. Explain briefly about Domain Name System (DNS)? (11 marks) It is a distributed database implemented in hierarchy of name servers. Mapping of host name, to IP address. It consists of Local name server Authoritative name server. It contacts local name server first, if there is response then it contacts the Authoritative name server. Although programs theoretically could refer to hosts, mailboxes, and other resources by their network (e.g., IP) addresses, these addresses are hard for people to remember. Also, sending e-mail to tana@128.111.24.41 means that if Tanas ISP or organization moves the mail server to a different machine with a different IP address, her e-mail address has to change. Consequently, ASCII names were introduced to decouple machine names from machine addresses. In this way, Tana's address might be something like tana@art.ucsb.edu. Nevertheless, the network itself understands only numerical addresses, so some mechanism is required to convert the ASCII strings to network addresses. In the following sections we will study how this mapping is accomplished in the Internet. Way back in the ARPANET, there was simply a file, hosts.txt,that listed all the hosts and their IP addresses. Every night, all the hosts would fetch it from the site at which it was maintained. For a network of a few hundred large timesharing machines, this approach worked reasonably well.

However, when thousands of minicomputers and PCs were connected to the net, everyone realized that this approach could not continue to work forever. For one thing, the size of the file would become too large. However, even more important, host name conflicts would occur constantly unless names were centrally managed, something unthinkable in a huge international network due to the load and latency. To solve these problems, DNS (the Domain Name System) was invented. The essence of DNS is the invention of a hierarchical, domain-based naming scheme and a distributed database system for implementing this naming scheme. It is primarily used for mapping host names and email destinations to IP addresses but can also be used for other purposes. DNS is defined in RFCs 1034 and 1035. Very briefly, the way DNS is used is as follows. To map a name onto an IP address, an application program calls a library procedure called the resolver, passing it the name as a parameter. We saw an example of a resolver, gethostbyname. The resolver sends a UDP packet to a local DNS server, which then looks up the name and returns the IP address to the resolver, which then returns it to the caller. Armed with the IP address, the program can then establish a TCP connection with the destination or send it UDP packets. The DNS Name Space Managing a large and constantly changing set of names is a nontrivial problem. In the postal system, name management is done by requiring letters to specify (implicitly or explicitly) the country, state or province, city, and street address of the addressee. By using this kind of hierarchical addressing, there is no confusion between the Marvin Anderson on Main St. in White Plains, N.Y. and the Marvin Anderson on Main St. in Austin, Texas. DNS works the same way. Conceptually, the Internet is divided into over 200 top-level domains, where each domain covers many hosts. Each domain is partitioned into subdomains, and these are further partitioned, and so on. All these domains can be represented by a tree, as shown in. The leaves of the tree represent domains that have no subdomains (but do contain machines, of course). A leaf domain may contain a single host, or it may represent a company and contain thousands of hosts. A portion of the Internet domain name space.

The top-level domains come in two flavors: generic and countries. The original generic domains were com (commercial), edu (educational institutions), gov (the U.S. Federal Government), int (certain international organizations), mil (the U.S. armed forces), net (network providers), and org (nonprofit organizations). The country domains include one entry for every country, as defined in ISO 3166.

In November 2000, ICANN approved four new, general-purpose, top-level domains, namely, biz (businesses), info (information), name (people's names), and pro (professions, such as doctors and lawyers). In addition, three more specialized top-level domains were introduced at the request of certain industries. These are aero (aerospace industry), coop (co-operatives), and museum (museums). Other toplevel domains will be added in the future. As an aside, as the Internet becomes more commercial, it also becomes more contentious. Take pro, for example. It was intended for certified professionals. But who is a professional? And certified by whom? Doctors and lawyers clearly are professionals. But what about freelance photographers, piano teachers, magicians, plumbers, barbers, exterminators, tattoo artists, mercenaries, and prostitutes? Are these occupations professional and thus eligible for pro domains? And if so, who certifies the individual practitioners? In general, getting a second-level domain, such as name-of-company.com, is easy. It merely requires going to a registrar for the corresponding top-level domain (com in this case) to check if the desired name is available and not somebody else's trademark. If there are no problems, the requester pays a small annual fee and gets the name. By now, virtually every common (English) word has been taken in the com domain. Try household articles, animals, plants, body parts, etc. Nearly all are taken. Each domain is named by the path upward from it to the (unnamed) root. The components are separated by periods (pronounced ''dot''). Thus, the engineering department at Sun Microsystems might be eng.sun.com., rather than a UNIX-style name such as /com/sun/eng. Notice that this hierarchical naming means that eng.sun.com does not conflict with a potential use of eng in eng.yale.edu., which might be used by the Yale English department. Domain names can be either absolute or relative. An absolute domain name always ends with a period (e.g., eng.sun.com.), whereas a relative one does not. Relative names have to be interpreted in some context to uniquely determine their true meaning. In both cases, a named domain refers to a specific node in the tree and all the nodes under it. Domain names are case insensitive, so edu, Edu, and EDU mean the same thing. Component names can be up to 63 characters long, and full path names must not exceed 255 characters. In principle, domains can be inserted into the tree in two different ways. For example, cs.yale.edu could equally well be listed under the us country domain as cs.yale.ct.us. In practice, however, most organizations in the United States are under a generic domain, and most outside the United States are under the domain of their country. There is no rule against registering under two top-level domains, but few organizations except multinationals do it (e.g., sony.com and sony.nl). Each domain controls how it allocates the domains under it. For example, Japan has domains ac.jp and co.jp that mirror edu and com. The Netherlands does not make this distinction and puts all organizations directly under nl. Thus, all three of the following are university computer science departments: cs.yale.edu (Yale University, in the United States) cs.vu.nl (Vrije University, in The Netherlands) cs.keio.ac.jp (Keio University, in Japan)

To create a new domain, permission is required of the domain in which it will be included. For example, if a VLSI group is started at Yale and wants to be known as vlsi.cs.yale.edu, it has to get permission from whoever manages cs.yale.edu. Similarly, if a new university is chartered, say, the University of Northern South Dakota, it must ask the manager of the edu domain to assign it unsd.edu. In this way, name conflicts are avoided and each domain can keep track of all its subdomains. Once a new domain has been created and registered, it can create subdomains, such as cs.unsd.edu, without getting permission from anybody higher up the tree. Naming follows organizational boundaries, not physical networks. For example, if the computer science and electrical engineering departments are located in the same building and share the same LAN, they can nevertheless have distinct domains. Similarly, even if computer science is split over Babbage Hall and Turing Hall, the hosts in both buildings will normally belong to the same domain. Resource Records Every domain, whether it is a single host or a top-level domain, can have a set of resource records associated with it. For a single host, the most common resource record is just its IP address, but many other kinds of resource records also exist. When a resolver gives a domain name to DNS, what it gets back are the resource records associated with that name. Thus, the primary function of DNS is to map domain names onto resource records. A resource record is a five-tuple. Although they are encoded in binary for efficiency, in most expositions, resource records are presented as ASCII text, one line per resource record. The format we will use is as follows:

Domain_name Time_to_live Class Type Value The Domain_name tells the domain to which this record applies. Normally, many records exist for each domain and each copy of the database holds information about multiple domains. This field is thus the primary search key used to satisfy queries. The order of the records in the database is not significant. The Time_to_live field gives an indication of how stable the record is. Information that is highly stable is assigned a large value, such as 86400 (the number of seconds in 1 day). Information that is highly volatile is assigned a small value, such as 60 (1 minute). We will come back to this point later when we have discussed caching. The third field of every resource record is the Class. For Internet information, it is always IN. For nonInternet information, other codes can be used, but in practice, these are rarely seen. The Type field tells what kind of record this is. The most important types are listed in Fig. An SOA record provides the name of the primary source of information about the name server's zone (described below), the e-mail address of its administrator, a unique serial number, and various flags and timeouts.

The principal DNS resource record types for IPv4.

The most important record type is the A (Address) record. It holds a 32-bit IP address for some host. Every Internet host must have at least one IP address so that other machines can communicate with it. Some hosts have two or more network connections, in which case they will have one type A resource record per network connection (and thus per IP address). DNS can be configured to cycle through these, returning the first record on the first request, the second record on the second request, and so on. The next most important record type is the MX record. It specifies the name of the host prepared to accept e-mail for the specified domain. It is used because not every machine is prepared to accept e-mail. If someone wants to send e-mail to, for example, bill@microsoft.com, the sending host needs to find a mail server at microsoft.com that is willing to accept e-mail. The MX record can provide this information. The NS records specify name servers. For example, every DNS database normally has an NS record for each of the top-level domains, so, for example, e-mail can be sent to distant parts of the naming tree. We will come back to this point later. CNAME records allow aliases to be created. For example, a person familiar with Internet naming in general and wanting to send a message to someone whose login name is paul in the computer science department at M.I.T. might guess that paul@cs.mit.edu will work. Actually, this address will not work, because the domain for M.I.T.'s computer science department is lcs.mit.edu. However, as a service to people who do not know this, M.I.T. could create a CNAME entry to point people and programs in the right direction. An entry like this one might do the job: cs.mit.edu 86400 IN CNAME lcs.mit.edu Like CNAME, PTR points to another name. However, unlike CNAME, which is really just a macro definition, PTR is a regular DNS data type whose interpretation depends on the context in which it is found. In practice, it is nearly always used to associate a name with an IP address to allow lookups of the IP address and return the name of the corresponding machine. These are called reverse lookups. HINFO records allow people to find out what kind of machine and operating system a domain corresponds to. Finally, TXT records allow domains to identify themselves in arbitrary ways. Both of these record types are for user convenience. Neither is required, so programs cannot count on getting them (and probably cannot deal with them if they do get them).

Finally, we have the Value field. This field can be a number, a domain name, or an ASCII string. The semantics depend on the record type. A short description of the Value fields for each of the principal record types is given in Fig. For an example of the kind of information one might find in the DNS database of a domain, see-. This figure depicts part of a (semi hypothetical) database for the cs.vu.nl domain shown in The database contains seven types of resource records. A portion of a possible DNS database for cs.vu.nl

The first non-comment line of Fig. gives some basic information about the domain, which will not concern us further. The next two lines give textual information about where the domain is located. Then come two entries giving the first and second places to try to deliver e-mail sent to person@cs.vu.nl. The zephyr (a specific machine) should be tried first. If that fails, the top should be tried as the next choice. After the blank line, added for readability, come lines telling that the flits is a Sun workstation running UNIX and giving both of its IP addresses. Then three choices are given for handling e-mail sent to flits.cs.vu.nl. First choice is naturally the flits itself, but if it is down, the zephyr and top are the second and third choices. Next comes an alias, www.cs.vu.nl, so that this address can be used without designating a specific machine. Creating this alias allows cs.vu.nl to change its World Wide Web server without invalidating the address people use to get to it. A similar argument holds for ftp.cs.vu.nl. The next four lines contain a typical entry for a workstation, in this case, rowboat.cs.vu.nl. The information provided contains the IP address, the primary and secondary mail drops, and information about the machine. Then comes an entry for a non-UNIX system that is not capable of receiving mail itself, followed by an entry for a laser printer that is connected to the Internet. What are not shown (and are not in this file) are the IP addresses used to look up the top-level domains. These are needed to look up distant hosts, but since they are not part of the cs.vu.nl domain, they are not in this file. They are supplied by the root servers, whose IP addresses are present in a system configuration file and loaded into the DNS cache when the DNS server is booted.

There are about a dozen root servers spread around the world, and each one knows the IP addresses of all the top-level domain servers. Thus, if a machine knows the IP address of at least one root server, it can look up any DNS name. Name Servers In theory at least, a single name server could contain the entire DNS database and respond to all queries about it. In practice, this server would be so overloaded as to be useless. Furthermore, if it ever went down, the entire Internet would be crippled. To avoid the problems associated with having only a single source of information, the DNS name space is divided into non overlapping zones. One possible way to divide the name space in fig .Each zone contains some part of the tree and also contains name servers holding the information about that zone. Normally, a zone will have one primary name server, which gets its information from a file on its disk, and one or more secondary name servers, which get their information from the primary name server. To improve reliability, some servers for a zone can be located outside the zone. Part of the DNS name space showing the division into zones.

Where the zone boundaries are placed within a zone is up to that zone's administrator. This decision is made in large part based on how many name servers are desired, and where. For example, in Fig., Yale has a server for yale.edu that handles eng.yale.edu but not cs.yale.edu, which is a separate zone with its own name servers. Such a decision might be made when a department such as English does not wish to run its own name server, but a department such as computer science does. Consequently, cs.yale.edu is a separate zone but eng.yale.edu is not. When a resolver has a query about a domain name, it passes the query to one of the local name servers. If the domain being sought falls under the jurisdiction of the name server, such as ai.cs.yale.edu falling under cs.yale.edu, it returns the authoritative resource records. An authoritative record is one that comes from the authority that manages the record and is thus always correct. Authoritative records are in contrast to cached records, which may be out of date. If, however, the domain is remote and no information about the requested domain is available locally, the name server sends a query message to the top-level name server for the domain requested. To make this process clearer, consider the example of Fig.. Here, a resolver on flits.cs.vu.nl wants to know the IP address of the host linda.cs.yale.edu. In step 1, it sends a query to the local name server, cs.vu.nl. This query contains the domain name sought, the type (A) and the class (IN).

How a resolver looks up a remote name in eight steps.

Let us suppose the local name server has never had a query for this domain before and knows nothing about it. It may ask a few other nearby name servers, but if none of them know, it sends a UDP packet to the server for edu given in its database , edu-server.net. It is unlikely that this server knows the address of linda.cs.yale.edu, and probably does not know cs.yale.edu either, but it must know all of its own children, so it forwards the request to the name server for yale.edu (step 3). In turn, this one forwards the request to cs.yale.edu (step 4), which must have the authoritative resource records. Since each request is from a client to a server, the resource record requested works its way back in steps 5 through 8. Once these records get back to the cs.vu.nl name server, they will be entered into a cache there, in case they are needed later. However, this information is not authoritative, since changes made at cs.yale.edu will not be propagated to all the caches in the world that may know about it. For this reason, cache entries should not live too long. This is the reason that the Time_to_live field is included in each resource record. It tells remote name servers how long to cache records. If a certain machine has had the same IP address for years, it may be safe to cache that information for 1 day. For more volatile information, it might be safer to purge the records after a few seconds or a minute. It is worth mentioning that the query method described here is known as a recursive query, since each server that does not have the requested information goes and finds it somewhere, then reports back. An alternative form is also possible. In this form, when a query cannot be satisfied locally, the query fails, but the name of the next server along the line to try is returned. Some servers do not implement recursive queries and always return the name of the next server to try. It is also worth pointing out that when a DNS client fails to get a response before its timer goes off, it normally will try another server next time. The assumption here is that the server is probably down, rather than that the request or reply got lost. 10. Write short notes on web browser? (11 marks) A web browser is used to display web pages. Common web browsers are Netscape Navigator and Internet Explorer. The Web browser is the interpreter of our Web sites. It is very important to understand the Web browser being supported and what capabilities it has. The two most common browsers at the time of this books publication are Microsofts Internet Explorer (which accounts for the majority of browser users) and Netscapes Communicator (Navigator). While these two browsers account for most users accessing public Web sites, there are numerous other versions of browsers in use. The problem with published browser usage reports is that they dont necessarily reflect your browsing audience. Consider a site that publishes Macintosh softwareits browser usage pattern might actually show a fair number of users with OmniWeb, a Macintosh-specific browser that has a notable number of rabid followers. However, most sites probably wouldnt consider OmniWeb something to even think about.

Components of Web Medium Depending on your users, the types of browsers will vary. From statistics showing that surveyed sites favor a particular browser, it does not necessarily follow that your site will exhibit the same browser usage patternsthough it is pretty likely. Look at your own log files to determine browser usage patterns. If you are building an intranet site, you might not even have to look at your logs to understand what browsers are in use. Given a mix of browsers made up of the top two vendors with a smattering of other browsers, the question becomes how this information relates to site design and technology use. One possibility is to look at the various browsers and their capabilities, and then design for some common set of features. Considering the variations among browsers, the common ground isnt terribly advanced. The safest design platform for some still seems to be what Netscape 3.x supports, though more and more designers are embracing design for the 4.x and 5.x generation browsers and using CSS, Flash, and JavaScript more often.

The only problem with moving to the next generation is that the gap between what different generations of browsers support can be rather large. Because of this, sites (and users) significantly favor Internet Explorer over Netscape. (The installed base for IE browsers includes between 85% to 90% of all users at the time of this writing.) With the advent of Netscapes Mozilla-based browsers (Netscape 6 and 7, and Mozilla 1.0), things may get more interesting because these browsers promise more support for standardsbased Web page development than Netscapes 4.x generation browsers. Even so, there will not be an overnight adoption of new, non-IE browsers around the Web. As the installed base increases, the longer it will take for consumers to embrace new technologies. Therefore, public sites should consider developing for at least one, if not two, generations prior to the current release of a browser. Even more than six years after the release of the 2.x generation browsers, some public sites still support that generation of browsers perfectly.

OTHER BROWSERS Besides Internet Explorer and Firefox, many other web browsers are available, including Opera (www.opera.com) and Safari (www.apple.com/safari). All these browsers differ in functionality, performance and features. Also, they employ different HTML layout engines, which determine how a web page displays in a browser. Firefox 2 uses Gecko as its layout engine, Safari uses a modified version of the KHTML layout engine and Opera and IE7 have their own engines. Gecko and KHTML are both free and open source. Opera, as well as IE7 and FF2, is a browser designed to be accessible to all users, including those with visual or mobility impairments. Opera software also recently developed a lightweight Mini version of the browser that runs effectively on mobile devices. Safari, originally created for Apples Mac OS, features an elegantly simple interface and impressive speed, especially when executing JavaScript. Because browsers use different HTML layout engines, they may display the same web page differently. Additionally, some capabilities supported in one browser may not be supported in another. The existence of different browser functionality and features makes cross-browser compatibility difficult to achieve.

12. Write short notes on web servers? (6 marks) A web server is a computer system that delivers web pages. Every web server has an IP address and possibly a domain name. Example, if you enter the URL http://www.yahoo.com//index.html in your browser, this sends a request to the server whose domain name is yahoo.com. The server then fetches the page named index.html and sends it to your browser. All of the machines on the Internet can be categorized as two types: servers client Those machines that provide services (like Web servers or FTP servers) to other machines are servers. And the machines that are used to connect to those services are clients.

Like the Web browser, the Web server frames the environment of each Web transaction. The term Web server is usually understood to mean both the hardware and software. The major issue with hardware is whether the Web server is capable of handling the memory, disk, and network input/output requirements resulting from site traffic. The interplay of operating systems, such as UNIX or Windows 2000, and Web server software also is closely related to performance, as is security. From Apache to Zeus, all Web server software platforms handle basic HTTP transactions, but all tend to offer more than basic file serving facilities. Most Web server platforms provide basic security and authentication services, logging, and programming facilities. An in-depth discussion of the popular servers and their facilities is presented in Chapter 17; here, we will focus only on the programming aspects of sites. Apache is the most popular UNIX web server today. Apache was originally based on code and ideas found in the most popular HTTP server of the time, NCSA httpd 1.3 (early 1995). It has since evolved into a far superior system which can rival (and probably surpass) almost any other UNIX based HTTP server in terms of functionality, efficiency and speed. Take a look at the web server feature chart to see how Apache ranks among the competition. Open Market provides software products that are used to develop the infrastructure for Internet commerce. They pride themselves on scalability, content flexibility, lower entry and maintenance costs, and enhanced security.

Netscape sells several web server software packages. The Netscape Enterprise Server offers built in advanced services such as Internet-based access controls, automatic link management, and revision control. The FastTrack Server is an easy-to-use entry-level Web server designed to let novices create and manage a Web site. IBM's Secure Server is provided for AIX, HP-UX, and Solaris, as well as NT and OS/2. Version 4.2 servers include enhanced scalability, browser-specific response capability, enhanced CGI support, PICS support, and HTTP Version 1.1 compliance. The IB servers have consistent configuration, management, and API interfaces across all of their supported platforms. Jigsaw is W3C's sample implementation of HTTP, a full blown HTTP server entirely written in Java. Its design goals were: will run on any machine running Java, can be extended by writing new resource objects (a replacement for CGI), minimization of file system accesses. WebSTAR is a Mac HTTP server which performs dynamic web server file caching, has the ability to run server side Java applets, contains an administration plug-in that lets one administer essential server functions from any web browser on the Internet, honors keep-alive requests, supports a 20,000 username/passwd database, has integrated support for image maps, supports common log format, supports cgi-bin folder, does on the fly bin-hexing of Mac files, and supports an expanded command set for serverside includes. Microsoft IIS is tightly integrated with NT and includes native support for ActiveX, VBScript and JScript. The index server includes built-in support for HTML, text, and Microsoft Office documents, and NetShow provides streaming audio and video support for IIS. Crystal Reports is the visual reporting tool for IIS that lets you create presentation quality reports and integrate them into database applications. 13. Explain briefly about DYNAMIC HTML? (11 marks) Dynamic HTML is a collective term for a combination of Hypertext Markup Language (HTML) tags and options that can make Web pages more animated and interactive than previous versions of HTML. Much of dynamic HTML is specified in HTML 4.0. Simple examples of dynamic HTML capabilities include having the color of a text heading change when a user passes a mouse over it and allowing a user to "drag and drop" an image to another place on a Web page. Dynamic HTML can allow Web documents to look and act like desktop applications or multimedia productions. The Concepts and Features in Dynamic HTML

An object-oriented view of a Web page and its elements Cascading style sheets and the layering of content Programming that can address all or most page elements Dynamic fonts

An Object-Oriented View of Page Elements Each page element (division or section, heading, paragraph, image, list, and so forth) is viewed as an "object." (Microsoft calls this the "Dynamic HTML Object Model." Netscape calls it the "HTML Object Model." W3C calls it the "Document Object Model.") For example, each heading on a page can be named, given attributes of text style and color, and addressed by name in a small program or "script" included on the page.

This heading or any other element on the page can be changed as the result of a specified event such a mouse passing over or being clicked or a time elapsing. Or an imagecan be moved from one place to another by "dragging and dropping" the image object with the mouse. (These event possibilities can be viewed as the reaction capabilities of the element or object.) Any change takes place immediately (since all variations of all elements or objects have been sent as part of the same page from the Web server that sent the page). Thus, variations can be thought of as different properties of the object. Not only can element variations change text wording or color, but everything contained within a heading object can be replaced with new content that includes different or additional HTML as well as different text. Microsoft calls this the "Text Range technology." Although JavaScript, Java applet, and ActiveX controls were present in previous levels of Web pages, dynamic HTML implies an increased amount of programming in Web pages since more elements of a page can be addressed by a program. A feature called dynamic fonts lets Web page designers include font files containing specific font styles, sizes, and colors as part of a Web page and to have the fonts downloaded with the page. That is, the font choice no longer is dependent on what the user's browser provides. Style Sheets and Layering A describes the default style characteristics (including the page layout and font type style and size for text elements such as headings and body text) of a document or a portion of a document. For Web pages, a style sheet also describes the default background color or image, hypertext link colors, and possibly the content of page. Style sheets help ensure consistency across all or a group of pages in a document or a Web site. Dynamic HTML includes the capability to specify style sheets in a "cascading style sheet" fashion (that is, linking to or specifying different style sheets or style statements with predefined levels of precedence within the same or a set of related pages). As the result of user interaction, a new style sheet can be made applicable and result in a change of appearance of the Web page. You can have multiple layers of style sheet within a page, a style sheet within a style sheet within a style sheet. A new style sheet may only vary one element from the style sheet above it. Layering is the use of alternate style sheets or other approaches to vary the content of a page by providing content layers that can overlay (and replace or superimpose on) existing content sections. Layers can be programmed to appear as part of a timed presentation or as the result of user interaction. DHTML is the art of combining HTML, JavaScript, DOM, and CSS. What you should already know Before you continue you should have a basic understanding of the following:

HTML CSS JavaScript If you want to study these subjects first, find the tutorials on our Home Page.

DHTML is NOT a Language 1. DHTML stands for Dynamic HTML. 2. 3. DHTML is NOT a language or a web standard. To most people DHTML means the combination of HTML, JavaScript, DOM and CSS. According to the World Wide Web Consortium (W3C): "Dynamic HTML is a term used by some vendors to describe the combination of HTML, style sheets and scripts that allows documents to be animated." HTML The W3C HTML 4 standard has rich support for dynamic content: HTML supports JavaScript HTML supports the Document Object Model (DOM) HTML supports HTML Events HTML supports Cascading Style Sheets (CSS)

DHTML is about using these features, to create dynamic and interactive web pages. JavaScript HTML DOM The HTML DOM is a W3C standard. It describes the Document Object Model for HTML. The HTML DOM defines a standard way for accessing and manipulating HTML documents. DHTML is about using the DOM to access and manipulate HTML elements. You can read more about the HTML DOM in a later chapter of this tutorial. HTML Events HTML events are a part of the HTML DOM. DHTML is about creating web pages that reacts to (user) events. You can read more about events in a later chapter of this tutorial. JavaScript is the most popular scripting language on the internet, and it works in all major browsers. DHTML is about using JavaScript to control access and manipulate HTML elements. You can read more about JavaScript in the next chapter of this tutorial.

CSS CSS defines how to display HTML elements. DHTML is about using JavaScript and the HTML DOM to change the style and positioning of HTML elements.

What is the HTML DOM? The HTML DOM is: A Document Object Model for HTML A standard programming interface for HTML Platform- and language-independent A W3C standard

The HTML DOM defines the objects and properties of all HTML elements, and the methods (interface) to access them. In other words: The HTML DOM is a standard for how to get, change, add, or delete HTML elements. Change an HTML Element The following example changes the content of an h1 element: Example <html> <body> <h1 id="header">Old Header</h1> <script type="text/javascript"> document.getElementById("header").innerHTML="New Header"; </script> </body> </html>

UNIT-II CLIENT SIDE AND SERVER SIDE PROGRAMMING 2 MARKS 1. What is scripting? Scripting is used to validate the data. It is done both client and server side. In scripting, client side validation reduces the traffic, JAVA script, VB script is used in client side. In server side asp, jsp is used to validate.

2. What is meant by cookies? A cookie is a small amount of information sent by the web server which is stored on a user system for lateral retrieval. The major use of cookies is to store user identification details such as name and password.

3. What are the issues in cookies? The issues in cookies are: Inform users for cookie usage. Avoid using too many cookies Provide alternate for cookie denying users.

4. Mention the advantages of java/java script? Use sending data continuously File storage Massively parallel computing Smart forms includes various controls like text box, radio button, text area control etc. Peer-to-Peer Interaction used in various client/server model. Games Combine the ability to easily include networking in your programs with javas powerful graphics and you have the recipe for truly awesome multiplayer games. Chat Used in various chat applications. Whiteboards Java programs are not limited to sending text and data across the network. A number of programmers have developed whiteboard software that allows users in diverse locations to draw on their computers 5. Mention the types of scripting languages? JavaScript is a Scripting language (web site development environment) created by Netscape. Hence JavaScript works best with the Netscape suite of Client and Server products. JavaScript is the native scripting language of Netscape Navigator. VBScript is the native Scripting language of HTML. 6. What is server side scripting?

In Server side scripting the script program is executed at Server Side the required html program is sent to the client. The job of the server is more in server side scripting.

7. What is client side scripting? Here the script program is processed and executed in the client side itself. So that it reduces the burden of the server.
8. Write the syntax of JavaScript program?

<HTML> <HEAD> <SCRIPT language = JavaScript> body of the script program </SCRIPT> </HEAD> <BODY> <SCRIPT language = JavaScript> body of the program. </SCRIPT> </BODY> </HTML>
9. List the various dialog boxes in java script?

Dialog boxes are used to display small windows. This is also used to get input from user. SYNTAX alert(message); alert(Click here to continue) prompt(Enter your name, name) Alert is only used to display some information Prompt is used to display information along with some input value Confirm dialog box, causes program execution to halt until user action takes place. The user action can be either OK or CANCEL. OK returns true CANCEL returns false
10. Mention the various java script object models?

Math Object String Object Date Object Boolean and Number Object Document Object Window Object

11. How scripting language is differs from html?

HTML is used for simple web page design HTML with FORM is used for both form design and Reading input values from user. Scripting Language is used for Validating the given input values weather it is correct or not, if the input value is incorrect, the user can pass an error message to the user.

Using form concept various controls like Text box, Radio Button, Command Button, Text Area control and List box can be created.

12. Define function in java script?

Function is a part of a program or in other words function is a module in java program which can be called or invoked any number of times from the main program.

Function can be called any number of times but it can accept any input values or parameters, however it can return only one output at a time.

13. What do you mean by Server-side? Occurring on the server side of a client-server system. For example, on the World Wide Web, CGI scripts are server-side applications because they run on the Web server. In contrast, JavaScript scripts are client-side because they are executed by your browser (the client). Java applets can be either server-side or client- side depending on which computer (the server or the client) executes them.

14. What are the common mechanisms used for session tracking? Cookies

SSL sessions URL- rewriting

15. Explain about Session tracking?

A session is basically a conversation between a browser and a server. All the above technologies can save information for the current session for a particular user visiting a site. The session is important, as H1TP is a stateless protocol. This means that the connection between web server and a web browser is not automatically maintained, and that the state of a web session is not saved. State is a general term that includes "everything about your situation" and the specifics vary based on the application. In a word processor, the state of the application would include which windows are open, where they are on the screen, and what files you most recently used. In a web application, the state would include any data that you had entered, the results of any queries that you had run, and your security access information (e.g. whether you have logged in to the site).

16. Define VBScript?

Around the time of Jscripts release, Microsoft introduced another client-side scripting language called Visual Basic Scripting Edition, or VBScript.

VBScript is a scripting language A scripting language is a lightweight programming language

VBScript is a light version of Microsoft's programming language Visual Basic

17. Define JSP?

Java Server Pages (JSP) is a Java technology that allows software developers to dynamically generate HTML, XML or other types of documents in response to a Web client request. The technology allows Java code and certain pre-defined actions to be embedded into static content.. Java Server Pages (JSP) is an extension of servlet technology. JSPs simplify the delivery of dynamic web content. They allow web programmers to create dynamic content by reusing predefined components and by interacting with components using server-side scripting.

JSPs can reuse JavaBeans and create custom tag libraries that encapsulate complex, dynamic functionality. 18. Define cookies? JavaScript, cookies are a mechanism for storing persistent data on the client in a file called cookies.txt. Because Hypertext Transport Protocol (HTTP) is a stateless protocol, cookies provide a way to maintain information between client requests.

11MARKS 1. Explain the basic concepts in script languages? (6 marks) Scripting languages JavaScript is a Scripting language (web site development environment) created by Netscape. Hence JavaScript works best with the Netscape suite of Client and Server products. JavaScript is the native scripting language of Netscape Navigator. VBScript is the native Scripting language of HTML. Server side scripting In Server side scripting the script program is executed at Server Side the required html program is sent to the client. The job of the server is more in server side scripting. Client side scripting Here the script program is processed and executed in the client side itself. So that it reduces the burden of the server. JAVA SCRIPT 1. JavaScript is an object-oriented language that allows creation of interactive Web pages. 2. JavaScript allows user entries, which are loaded into an HTML form to be processed as required. Javascript introduction Objectives To be able to write simple java script programs To be able to use input and output statements To understand basic memory concepts

Advantages

To be able to use arithmetic operators To understand the precedence of arithmetic operators To be able to write decision making statements To be able to use relational and equality operators

1. It is an interpreted language, which requires no compilation steps. 2. Embedded within HTML. 3. Minimal Syntax easy to learn 4. Quick Development 5. Designed for simple, small programs 6. High performance 7. Procedural Capabilities support facilities such as condition checking, looping and branching. 8. Designed for programming user events like VB Java Script is also based on Events. 9. Easy Debugging and Testing 10. Platform Independent/ Architecture Neutral

What is JavaScript? JavaScript is a scripting language mainly used for writing dynamic Web pages. When a script written in JavaScript is embedded in a Web page, it will be executed by the Web browser on the client machine. JavaScript supports functions as first-class functions - Functions are really objects. Like regular objects, functions can be created during execution, stored in data structure, and passed to other functions as arguments. JavaScript is a client side scripting language for the World Wide Web that is similar to the syntax of the Java programming language. JavaScript is designed to provide limited programming functionality. Why JavaScript? By executing more web functionality on the users machine, webmasters can optimize their servers to serve more pages. The decrease in traffic from constant interaction with the server can also improve a server's performance. Because the local machine is doing the script processing, the user can view web pages much faster Introducing JavaScript Syntax A simple JavaScript program: <html> <head> <Title> Hello World </Title> </head> <body> <script language=JavaScript> document.write(Hello,World wide web); </script> </body> </html>

2. Write a short note on object based scripting for the web? (6 marks) JavaScript JavaScript was the first client-side scripting language developed by Netscape. The purpose of javascript is to provide a true programming language for use by web page authors to add more interactivity to web pages. The first version of javascript contained most of the core functionality for the scripting language. Jscript In order for Microsoft to support javascript standard, it had to create its own implementation of javascript. The Microsoft implementation of javascript is jscript. VBScript Around the time of Jscripts release, Microsoft introduced another client-side scripting language called Visual Basic Scripting Edition, or VBScript. VBScript is based upon Visual Basic Product. Placing Scripts in Web Pages The client side scripts can be integrated within a web page. The <script> tag In order to embed client side scripts in to web pages, an html tag is needed to tell the browser that the following code is a script. This is done through the <script> tag. The <script> tag has the following syntax: <script language=[scripting language]> For example, <script language = JavaScript> The <script> tag has a closing tag, </script>, to denote the end of the script. Placing Scripts in HTML code Client Side scripts can be placed anywhere in the html text. The most common place for scripts is head section. Using a script tag in the header section is a good place to define all the subroutines. JavaScript embedded in the <head> section <head> <title> Java Scripting </title> <Script Language=javascript> function display_message(string_messgae) { window.staus = string_message; } </script> </head> The script can be included in the body of the html document, when the script needs to write some dynamic code to the document as its being parsed upon loading. JavaScript example for the html body section <script language=javascript> if ( useragent == Netscape)

{ document.write(Thank you for using Netscape) } </script> Javascript example embedded in html tags <a href=toc.html onMouseOver=window.status=Return to table of contents;return true onMouseOut=window.status= ; return true> Running client side scripts Client side scripts are run by loading the web page in which they are embedded into a web browser that supports that scripting language. Depending on how the script is to be run, the web browser either executes the code immediately or waits until the user performs some action.

What can Client Side Scripts Do? Client Side scripts provide a mechanism for building more interactivity into web pages. Client side scripts are full featured programming languages with conditional statements, control structures, and data structures. Tasks that can be performed by using client-side scripting are validation of form data, status bar messages, and image rollovers and cookies manipulation. Limitations of Scripting One of the biggest problems with client side script is that the script embedded into html pages is viewable by everyone who downloads the web page. Another limitation is the scope in which they can run. Client - Side scripts are also somewhat limited in the actions they can perform. Client side scripts must contain commands that are independent of the platform on which they are run. Client Side scripts do not possess all of the power of CGI scripts. CGI script is needed to handle the form data after it has been validated. CGI script is also needed to access information in a database.

3. Write a short note on basic concepts in java script? (5 marks) Statements It is simply a line of code that contains some kind of instructions. Example document.write(<h2> Hello, WWW </h2>); Blocks The grouping of statements is a block: { document.write(<h2> Each line is a statement </h2>); document.write(<P> These statements, <BR>); document.write(are part of a block); } Comments A single line comment is denoted with two slashes ( // ) // this is comment, it will be ignored by the browser. Multi line comments

/* some text */ Data Types There are 5 basic data types in JavaScript: string, number, Boolean, object and function. Variables Variables are "containers" for storing information. Rules for JavaScript variable names: Variable names are case sensitive (y and Y are two different variables) Variable names must begin with a letter or the underscore character Declaring (Creating) JavaScript Variables Creating variables in JavaScript is most often referred to as "declaring" variables. You can declare JavaScript variables with the var statement: var x; var carname; After the declaration shown above, the variables are empty (they have no values yet). However, you can also assign values to the variables when you declare them: Varx=5; var carname="Volvo"; Expressions The methods that can be employed to manipulate the data are called expressions. There are 2 types of expressions: numerical and logical Numerical expressions deal with the number data type. Logical expression might compare two data values, including strings, to see if they match. Numerical expressions Addition, subtraction, multiplication and division are all types of numeric expressions. Numeric operators are: +, -, *, /, % Logical Expressions These are expressions that, when evaluated, can return either a true or a false. Logical Operators && - And || - Or ! - Not == - Equal != - Not Equal > - Greater than >= < <= 4. Describe briefly about java script structures? (6 marks) Flow Control Conditional statements are used to perform different actions based on different conditions. In JavaScript we have the following conditional statements: if statement - use this statement to execute some code only if a specified condition is true if...else statement - use this statement to execute some code if the condition is true and another code if the condition is false if...else if....else statement - use this statement to select one of many blocks of code to be executed

switch statement - use this statement to select one of many blocks of code to be executed .

If Statement Use the if statement to execute some code only if a specified condition is true. Syntax if (condition) { code to be executed if condition is true } Example <script type="text/javascript"> //Write a "Good morning" greeting if //the time is less than 10 var d=new Date(); var time=d.getHours(); if (time<10) { document.write("<b>Good morning</b>"); } </script> If Else Statement Use the if....else statement to execute some code if a condition is true and another code if the condition is not true. Syntax if (condition) { code to be executed if condition is true } else { code to be executed if condition is not true } Example <script type="text/javascript"> //If the time is less than 10, you will get a "Good morning" greeting. //Otherwise you will get a "Good day" greeting. var d = new Date(); var time = d.getHours(); if (time < 10) { document.write("Good morning!"); } else { document.write("Good day!"); } </script> If...else if...else Statement Use the if....else if...else statement to select one of several blocks of code to be executed. Syntax

if (condition1) { code to be executed if condition1 is true } else if (condition2) { code to be executed if condition2 is true } else { code to be executed if condition1 and condition2 are not true } JavaScript Switch Statement Conditional statements are used to perform different actions based on different conditions. Use the switch statement to select one of many blocks of code to be executed. Syntax switch(n) { case 1: execute code block 1 break; case 2: execute code block 2 break; default: code to be executed if n is different from case 1 and 2 } Example: <script type="text/javascript"> //You will receive a different greeting based //on what day it is. Note that Sunday=0, //Monday=1, Tuesday=2, etc. var d=new Date(); theDay=d.getDay(); switch (theDay) { case 5: document.write("Finally Friday"); break; case 6: document.write("Super Saturday"); break; case 0: document.write("Sleepy Sunday"); break; default: document.write("I'm looking forward to this weekend!"); } </script> JavaScript for Loop Loops execute a block of code a specified number of times, or while a specified condition is true. JavaScript Loops

Often when you write code, you want the same block of code to run over and over again in a row. Instead of adding several almost equal lines in a script we can use loops to perform a task like this. In JavaScript, there are two different kind of loops: for - loops through a block of code a specified number of times while - loops through a block of code while a specified condition is true

The for Loop The for loop is used when you know in advance how many times the script should run. Syntax for (var=startvalue;var<=endvalue;var=var+increment) { code to be executed } Example <html> <body> <script type="text/javascript"> var i=0; for (i=0;i<=5;i++) { document.write("The number is " + i); document.write("<br />"); } </script> </body> </html> JavaScript While Loop The while loop loops through a block of code while a specified condition is true. Syntax while (var<=endvalue) { code to be executed } Example <html> <body> <script type="text/javascript"> var i=0; while (i<=5) { document.write("The number is " + i); document.write("<br />"); i++; } </script> </body> </html> 5. Describe briefly about java script functions? (6 marks)

What is JavaScript Function? A function is simply a block of code with a name, which allows the block of code to be called by other components in the scripts to perform certain tasks. Functions can also accept parameters that they use complete their task.

JavaScript actually comes with a number of built-in functions to accomplish a variety of tasks Java script Function is nothing but it is a reusable code-block that is execute when the function is called. Function is defined in the head section of the code. The syntax of JavaScript function is as follows: function fname(prameter1,parameter2, ...) { JavaScript code 1 JavaScript code 2 .... } While defining JavaScript function its important to remember that the keyword function should be in lowercase otherwise JavaScript won't understand it as function. If you write function in uppercase the code will generate error. In the JavaScript semicolon is optional but its better to put semi-colon as part of best practices. All the java script code is written inside the curly braces.

Example: <html> <head> <script language="javascript"> function showmessage(){ alert("How are you"); } </script> </head> <body> <form> <input type="button" value="Click Here!" onclick="showmessage()" > </form> </body> </html> Function starts with the function keyword and code of the function is enclosed in {..} brackets. Functions are written inside the head section of the html document, because function does not execute when the page loads. The alert function displays the message "How are you", when you clicked on the button ("Click Here")..

To test the program click here. What is the use of JavaScript Functions: The java Script Function is very useful in writing the JavaScript code. It is used to group many JavaScript codes under one name. For example you can write a function to validate email address. Built-in functions JavaScript provides many built in functions that ease the development of JavaScript programs. Here is the list of the built-in JavaScript functions:

JavaScript Build in Function alert() confirm()

focus() indexOf() prompt() select() write()

Function Description The alert() built-in function displays the alert dialog box. The confirm() built-in function display the confirmation dialog box. and ask the user to determine from the two option . The focus() built -in function built the pointed object active and put the curser on the text field. The prompt() built -in function display the prompt dialog box. Inquiring the user for input. The select() built -in function used to select the pointed object. The write() built in function used to write something on the document.

Function arguments: Through variable you can pass argument to function. The out put of the function looks on the arguments given by you. Example: <html> <head> <script language="javascript"> function myfunction(text) { confirm(text) } </script> </head> <body> <form> <input type="button" onclick="myfunction('Do you want to delete it!')" value="Delete"> <input type="button" onclick="myfunction('Do you want to save it!')" value="Save"> </form> </body> </html>

6. Describe briefly about java script arrays? (5 marks) The array concept is used to store a set of values in a single variable name. This is a very important concept in any programming language.

Array Definition: The array must first be defined before it is accessed or used. There are a variety of ways this can be accomplished in JavaScript. Below are some of the ways of defining arrays in JavaScript. Arrays are JavaScript objects that are capable of storing a sequence of values. These values are stored in indexed locations within the array. The length of an array is the number of elements of an array accessed by using the name of the array followed by the index value of the array element enclosed in square brackets. Defining an Array in JavaScript: Array is defined in JavaScript by making use of the keyword new. General format of defining array in JavaScript is as follows: var varaiblename = new Array( ) For example, if a programmer wants to define an array exforsys, it is written as follows: var exforsys = new Array( ) The format for adding elements in this structure is as follows:

var varaiblename = new Array( ) variablename[0]=element1 variablename[1]=element2 variablename[2]=element3 variablename[3]=element4 .. var Exforsys = new Array( ) Exforsys[0]=Training Exforsys[1]=Division Exforsys[2]=Institute Exforsys[3]=Company It is also possible that if the programmer is certain of the array length, it can be defined while defining the array itself as: var Exforsys = new Array(4)

Shorter form: The elements can also be defined in a shorter form as: var variablename=new Array(element1,element2,elements3,.) Accessing Arrays in JavaScript You can access an array element by referring to the name of the array and the element's index number. Displaying Array Elements document.write(Exforsys[1]) The length of an array starts from 0 to n-1. The array can be created in the following methods 1. arrayName = new Array(Array length) => array size is explicitly specified, array size is predefined. 2. arrayName = new Array() =>The second example creates an array of the size 0.

7. Describe briefly about java script java script objects? (6 marks) JavaScript Objects This section does not describe the handling of objects in JavaScript since it is assumed the reader possesses object oriented knowledge. It provides information about the creation of JavaScript objects, templates, constructors, and more. Object Creation Generally objects may be created using the following syntax: name = new Object() For instance Array, Date, Number, Boolean, and String objects can be created this way as in the example below. Most objects may be created this way except for the Math object which cannot be instantiated (an instance of it may not be created). ratings = new Array(6,9,8,4,5,7,8,10) var home = new String("Residence")

var futdate = new Date() var num1 = new Number() String objects may also be created as follows: var string = "This is a test." Object Template Objects are created using templates. Templates to objects are like cookie cutters to cookies. Cookie cutters are used to create instances of cookies and object templates are used to create instances of objects. For now, the template is shown. The following creates an object, olist. function olist(elements) { this.elements = elements this.listitems = new Array(elements) this.getItem = list_getItem this.setItem = list_setItem } The methods list_setItem and list_getItem are written as follows: function list_getItem(element) { return this.listitems(element) } function list_setItem(element, stringval) { this.listitems(element) - stringval } Creating the Object var list1 = new olist(10) Changing the Object list1.setItem(0,"This is the first item in the list") list1.setItem(1,"This is the second item in the list") list1.setItem(2,"This is the third item in the list") The Prototype property The prototype property can be used to create new properties of created objects (whether they are user defined or system defined) as follows: list1.prototype.type = "1" The Function Constructor Creation:

minus2 = new Function("x","return x-2") Usage: y = minus2(10) The value of y is now 8. Object use When writing JavaScript, you are embedding the JavaScript in an object. These objects may have functions. An example function is the alert() function. It may be called as follows: alert("An error occurred!") However, the window object is the highest level JavaScript object, therefore the following code does the same thing: window.alert("An error occurred!") The following code using the "this" object declaration will perform the same: this.alert("An error occurred!") Object and Property Reference Objects and their properties are normally referenced using a dot between each object or its property or method. as follows: document.write("This is a test.")

However, a method called array notation, may be used. Array notation is required when the first character of a property name is a digit since the dot method may not be used in this case. The above example in array notation is: document ["write"] ("This is a test.") Levels of Objects JavaScript has basically three types of objects which are:

Top level objects Objects that are properties of other objects Objects that are not properties of other objects

JavaScript has three kinds of popup boxes: Alert box, Confirm box, and Prompt box. Alert Box An alert box is often used if you want to make sure information comes through to the user.

When an alert box pops up, the user will have to click "OK" to proceed. Syntax alert("sometext"); Example <html> <head> <script type="text/javascript"> function show_alert() { alert("I am an alert box!"); } </script> </head> <body> <input type="button" onclick="show_alert()" value="Show alert box" /> </body></html> Confirm Box A confirm box is often used if you want the user to verify or accept something. When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed. If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.

Syntax confirm("sometext"); Example <html> <head> <script type="text/javascript"> function show_confirm() { var r=confirm("Press a button"); if (r==true) { alert("You pressed OK!"); } else { alert("You pressed Cancel!");

} } </script> </head> <body> <input type="button" onclick="show_confirm()" value="Show confirm box" /> </body> </html> Prompt Box A prompt box is often used if you want the user to input a value before entering a page. When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value. If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null. Syntax prompt("sometext","defaultvalue"); Example <html> <head> <script type="text/javascript"> function show_prompt() { var name=prompt("Please enter your name","Harry Potter"); if (name!=null && name!="") { document.write("Hello " + name + "! How are you today?"); } } </script> </head> <body> <input type="button" onclick="show_prompt()" value="Show prompt box" /> </body> </html> <html> <head> <script type="text/javascript"> function disp_prompt() { var fname=prompt("Please enter your name:","Your name")

document.getElementById("msg").innerHTML="Greetings " + fname } </script> </head> <body> <input type="button" onclick="disp_prompt()" value="Display a prompt box" /> <br /><br /> <div id="msg"></div> </body> </html> Each HTML element has an innerHTML property that defines both the HTML code and the text that occurs between that element's opening and closing tag. By changing an element's innerHTML after some user interaction, you can make much more interactive pages. However, using innerHTML requires some preparation if you want to be able to use it easily and reliably. First, you must give the element you wish to change an id. With that id in place you will be able to use the getElementById function, which works on all browsers. After you have that set up you can now manipulate the text of an element. To start off, let's try changing the text inside a bold tag. <script type="text/javascript"> function changeText(){ document.getElementById('boldStuff').innerHTML = 'Fred Flinstone'; } </script> <p>Welcome to the site <b id='boldStuff'>dude</b> </p> <input type='button' onclick='changeText()' value='Change Text'/>

8. Describe briefly about java script regular expression? (5 marks) What is Regular Expressions? A regular expression is an object that describes a pattern of characters. When you search in a text, you can use a pattern to describe what you are searching for. A simple pattern can be one single character. A more complicated pattern can consist of more characters, and can be used for parsing, format checking, substitution and more. Regular expressions are used to perform powerful pattern-matching and "search-and-replace" functions on text. Syntax

var txt=new RegExp(pattern,modifiers); or more simply: var txt=/pattern/modifiers;


pattern specifies the pattern of an expression modifiers specify if a search should be global, case-sensitive, etc.

RegExp Modifiers Modifiers are used to perform case-insensitive and global searches. The i modifier is used to perform case-insensitive matching. The g modifier is used to perform a global match (find all matches rather than stopping after the first match). Example 1 Do a case-insensitive search for "w3schools" in a string: var str="Visit W3Schools"; var patt1=/w3schools/i; The marked text below shows where the expression gets a match: Visit W3Schools

Example 2 Do a global search for "is": var str="Is this all there is?"; var patt1=/is/g; The marked text below shows where the expression gets a match: Is this all there is? Example 3 Do a global, case-insensitive search for "is": var str="Is this all there is?"; var patt1=/is/gi;

The marked text below shows where the expression gets a match: Is this all there is? test() The test() method searches a string for a specified value, and returns true or false, depending on the result. The following example searches a string for the character "e": Example var patt1=new RegExp("e"); document.write(patt1.test("The best things in life are free")); Since there is an "e" in the string, the output of the code above will be: true exec() The exec() method searches a string for a specified value, and returns the text of the found value. If no match is found, it returns null. The following example searches a string for the character "e":

Example 1 var patt1=new RegExp("e"); document.write(patt1.exec("The best things in life are free")); Since there is an "e" in the string, the output of the code above will be: 9. Explain briefly about VB SCRIPTS? (11 marks) VBScript is a Microsoft scripting language. VBScript is the default scripting language in ASP. Client-side VBScript only works in Internet Explorer!

What is VBScript?

VBScript is a scripting language

A scripting language is a lightweight programming language VBScript is a light version of Microsoft's programming language Visual Basic

How does it Work? When a VBScript is inserted into an HTML document, the Internet browser will read the HTML and interpret the VBScript. The VBScript can be executed immediately, or at a later event. The HTML <script> tag is used to insert a VBScript into an HTML page. Put a VBScript into an HTML Page The example below shows how to use VBScript to write text on a web page: Example <html> <body> <script type="text/vbscript"> document.write("Hello World!") </script> </body> </html> The example below shows how to add HTML tags to the VBScript: Example (IE Only <html> <body> <script type="text/vbscript"> document.write("<h1>Hello World!</h1>") </script> </body> </html> Example Explained To insert a VBScript into an HTML page, we use the <script> tag. Inside the <script> tag we use the type attribute to define the scripting language. So, the <script type="text/vbscript"> and </script> tells where the VBScript starts and ends: <html> <body> <script type="text/vbscript"> ... </script> </body> </html>

The document.write command is a standard VBScript command for writing output to a page. By entering the document.write command between the <script> and </script> tags, the browser will recognize it as a VBScript command and execute the code line. In this case the browser will write Hello World! to the page: <html> <body> <script type="text/vbscript"> document.write("Hello World!") </script> </body> </html> How to Handle Simple Browsers Browsers that do not support scripting, will display VBScript as page content.To prevent them from doing this, the HTML comment tag should be used to "hide" the VBScript.Just add an HTML comment tag <!-before the first VBScript statement, and a --> (end of comment) after the last VBScript statement, like this: <html> <body> <script type="text/vbscript"> <!-document.write("Hello World!") --> </script> </body> </html>

VBScripts can be placed in the body and in the head section of an HTML document. Where to Put the VBScript VBScripts in a page will be executed immediately while the page loads into the browser. This is not always what we want. Sometimes we want to execute a script when a page loads, or at a later event, such as when a user clicks a button. When this is the case we put the script inside a function or a sub procedure, you will learn about procedures in a later chapter. Scripts in <head> Put your functions and sub procedures in the head section, this way they are all in one place, and they do not interfere with page content. Example (IE Only) <html> <head> <script type="text/vbscript">

function myFunction() alert("Hello World!") end function </script> </head> <body onload="myFunction()"> </body> </html> Scripts in <body> If you don't want your script to be placed inside a function, and especially if your script should write page content, it should be placed in the body section. Example (IE Only) <html> <head> </head> <body> <script type="text/vbscript"> document.write("This message is written by VBScript") </script> </body> </html>

Scripts in <head> and <body> You can place an unlimited number of scripts in your document, and you can have scripts in both the body and the head section. Example (IE Only) <html> <head> <script type="text/vbscript"> function myFunction() alert("Hello World!") end function </script> </head> <body> <button onclick="myFunction()">Click me</button> <script type="text/vbscript">

document.write("This message is written by VBScript") </script> </body> </html>

Using an External VBScript If you want to run the same VBScript on several pages, without having to write the same script on every page, you can write a VBScript in an external file. Save the external VBScript file with a .vbs file extension. Note: The external script cannot contain the <script> tag! To use the external script, point to the .vbs file in the "src" attribute of the <script> tag: Example <html> <head> <script type="text/vbscript" src="ex.vbs"></script> </head> <body> </body> </html>

10. Write a short note on VBSCRIPT variables? (6 marks) Variables are "containers" for storing information. VBScript Variables As with algebra, VBScript variables are used to hold values or expressions. A variable can have a short name, like x, or a more descriptive name, like carname. Rules for VBScript variable names:

Must begin with a letter Cannot contain a period (.) Cannot exceed 255 characters

In VBScript, all variables are of type variant that can store different types of data. Declaring (Creating) VBScript Variables Creating variables in VBScript is most often referred to as "declaring" variables. You can declare VBScript variables with the Dim, Public or the Private statement. Like this:

Dim x Dim carname Now you have created two variables. The name of the variables are "x" and "carname". You can also declare variables by using its name in a script. Like this: carname="Volvo" Now you have also created a variable. The name of the variable is "carname". However, this method is not a good practice, because you can misspell the variable name later in your script, and that can cause strange results when your script is running. If you misspell for example the "carname" variable to "carnime", the script will automatically create a new variable called "carnime". To prevent your script from doing this, you can use the Option Explicit statement. This statement forces you to declare all your variables with the dim, public or private statement. Put the Option Explicit statement on the top of your script. Like this: Option Explicit Dim carname carname=some value

Assigning Values to Variables You assign a value to a variable like this: carname="Volvo" x=10 The variable name is on the left side of the expression and the value you want to assign to the variable is on the right. Now the variable "carname" has the value of "Volvo", and the variable "x" has the value of "10". Lifetime of Variables How long a variable exists is its lifetime. When you declare a variable within a procedure, the variable can only be accessed within that procedure. When the procedure exits, the variable is destroyed. These variables are called local variables. You can have local variables with the same name in different procedures, because each is recognized only by the procedure in which it is declared. If you declare a variable outside a procedure, all the procedures on your page can access it. The lifetime of these variables starts when they are declared, and ends when the page is closed.

11. Write a short note on VBSCRIPT array variables? (5 marks) An array variable is used to store multiple values in a single variable. In the following example, an array containing 3 elements is declared: Dim names(2) The number shown in the parentheses is 2. We start at zero so this array contains 3 elements. This is a fixed-size array. You assign data to each of the elements of the array like this: names(0)="Tove" names(1)="Jani" names(2)="Stale" Similarly, the data can be retrieved from any element using the index of the particular array element you want. Like this: mother=names(0) You can have up to 60 dimensions in an array. Multiple dimensions are declared by separating the numbers in the parentheses with commas. Here we have a two-dimensional array consisting of 5 rows and 7 columns: Dim table(4,6)

Assign data to a two-dimensional array: Example (IE Only) <html> <body> <script type="text/vbscript"> Dim x(2,2) x(0,0)="Volvo" x(0,1)="BMW" x(0,2)="Ford" x(1,0)="Apple" x(1,1)="Orange" x(1,2)="Banana" x(2,0)="Coke" x(2,1)="Pepsi" x(2,2)="Sprite" for i=0 to 2 document.write("<p>") for j=0 to 2 document.write(x(i,j) & "<br />") next

document.write("</p>") next </script> </body> </html> 12. Write short notes on VBSCRIPT procedures? (6 marks) VBScript has two kinds procedures:

Sub procedure Function procedure

VBSCRIPT SUB PROCEDURES A Sub procedure:


is a series of statements, enclosed by the Sub and End Sub statements can perform actions, but does not return a value can take arguments without arguments, it must include an empty set of parentheses ()

Sub mysub() some statements End Sub

or Sub mysub(argument1,argument2) some statements End Sub Example (IE Only) Sub mysub() alert("Hello World") End Sub VBSCRIPT FUNCTION PROCEDURES A Function procedure:

is a series of statements, enclosed by the Function and End Function statements can perform actions and can return a value can take arguments that are passed to it by a calling procedure without arguments, must include an empty set of parentheses () returns a value by assigning a value to its name

Function myfunction() some statements myfunction=some value End Function or Function myfunction(argument1,argument2) some statements myfunction=some value End Function Example (IE Only) function myfunction() myfunction=Date() end function How to Call a Procedure There are different ways to call a procedure. You can call it from within another procedure, on an event, or call it within a script.

Example (IE Only) Call a procedure when the user clicks on a button: <body> <button onclick="myfunction()">Click me</button> </body> Procedures can be used to get a variable value: carname=findname() Here you call a Function called "findname", the Function returns a value that will be stored in the variable "carname". Function procedures can calculate the sum of two arguments: Example (IE Only)

Function myfunction(a,b) myfunction=a+b End Function document.write(myfunction(5,9)) The function "myfunction" will return the sum of argument "a" and argument "b". In this case 14. When you call a procedure you can use the Call statement, like this: Call MyProc(argument) Or, you can omit the Call statement, like this: MyProc argument

13. Write short notes on VBSCRIPT conditional statements? (6 marks) Conditional statements are used to perform different actions for different decisions. In VBScript we have four conditional statements:

If statement - executes a set of code when a condition is true If...Then...Else statement - select one of two sets of lines to execute If...Then...ElseIf statement - select one of many sets of lines to execute Select Case statement - select one of many sets of lines to execute

If...Then...Else Use the If...Then...Else statement if you want to


execute some code if a condition is true select one of two blocks of code to execute

If you want to execute only one statement when a condition is true, you can write the code on one line: If i=10 Then alert("Hello") There is no ..Else.. in this syntax. You just tell the code to perform one action if a condition is true (in this case If i=10). If you want to execute more than one statement when a condition is true, you must put each statement on separate lines, and end the statement with the keyword "End If": If i=10 Then alert("Hello") i = i+1

End If There is no ..Else.. in the example above either. You just tell the code to perform multiple actions if the condition is true. If you want to execute a statement if a condition is true and execute another statement if the condition is not true, you must add the "Else" keyword: Example (IE Only) <html> <body> <script type="text/vbscript"> Function greeting() i=hour(time) If i < 10 Then document.write("Good morning!") Else document.write("Have a nice day!") End If End Function </script> </head> <body onload="greeting()"> </body> </html>

In the example above, the first block of code will be executed if the condition is true, and the other block will be executed otherwise (if i is greater than 10). If...Then...ElseIf You can use the If...Then...ElseIf statement if you want to select one of many blocks of code to execute: Example (IE Only) <html> <body> <script type="text/vbscript"> Function greeting() i=hour(time) If i = 10 Then document.write("Just started...!") ElseIf i = 11 then document.write("Hungry!")

ElseIf i = 12 then document.write("Ah, lunch-time!") ElseIf i = 16 then document.write("Time to go home!") Else document.write("Unknown") End If End Function </script> </head> <body onload="greeting()"> </body> </html>

Select Case You can also use the "Select Case" statement if you want to select one of many blocks of code to execute: Example (IE Only) <html> <body> <script type="text/vbscript"> d=weekday(date) Select Case d Case 1 document.write("Sleepy Sunday") Case 2 document.write("Monday again!") Case 3 document.write("Just Tuesday!") Case 4 document.write("Wednesday!") Case 5 document.write("Thursday...") Case 6 document.write("Finally Friday!") Case else document.write("Super Saturday!!!!") End Select </script> </body> </html>

14. Write short notes on VBSCRIPT looping statements? (5 marks)

Looping statements are used to run the same block of code a specified number of times. In VBScript we have four looping statements:

For...Next statement - runs code a specified number of times For Each...Next statement - runs code for each item in a collection or each element of an array Do...Loop statement - loops while or until a condition is true While...Wend statement - Do not use it - use the Do...Loop statement instead

For...Next Loop Use the For...Next statement to run a block of code a specified number of times. The For statement specifies the counter variable (i), and its start and end values. The Next statement increases the counter variable (i) by one. Example <html> <body> <script type="text/vbscript"> For i = 0 To 5 document.write("The number is " & i & "<br />") Next </script> </body> </html>

The Step Keyword With the Step keyword, you can increase or decrease the counter variable by the value you specify. In the example below, the counter variable (i) is INCREASED by two, each time the loop repeats. For i=2 To 10 Step 2 some code Next To decrease the counter variable, you must use a negative Step value. You must specify an end value that is less than the start value. In the example below, the counter variable (i) is DECREASED by two, each time the loop repeats. For i=10 To 2 Step -2 some code Next

Exit a For...Next You can exit a For...Next statement with the Exit For keyword. For i=1 To 10 If i=5 Then Exit For some code Next For Each...Next Loop A For Each...Next loop repeats a block of code for each item in a collection, or for each element of an array. Example <html> <body> <script type="text/vbscript"> Dim cars(2) cars(0)="Volvo" cars(1)="Saab" cars(2)="BMW" For Each x In cars document.write(x & "<br />") Next </script> </body> </html>

Do...Loop If you don't know how many repetitions you want, use a Do...Loop statement. The Do...Loop statement repeats a block of code while a condition is true, or until a condition becomes true. Repeat Code While a Condition is True You use the While keyword to check a condition in a Do...Loop statement. Do While i>10 some code Loop If i equals 9, the code inside the loop above will never be executed. Do

some code Loop While i>10 The code inside this loop will be executed at least one time, even if i is less than 10. Repeat Code Until a Condition Becomes True You use the until keyword to check a condition in a Do...Loop statement. Do Until i=10 some code Loop If i equals 10, the code inside the loop will never be executed. Do some code Loop Until i=10 The code inside this loop will be executed at least one time, even if i is equal to 10. Exit a Do...Loop You can exit a Do...Loop statement with the Exit Do keyword. Do Until i=10 i=i-1 If i<10 Then Exit Do Loop

The code inside this loop will be executed as long as i is different from 10, and as long as i is greater than 10. Example programs in VBSCRIPT PROGRAM1: <html> <body> <script type="text/vbscript"> document.write("Hello World!") </script> </body> </html> Hello World! <html>

<body> <script type="text/vbscript"> document.write("<h1>Hello World!</h1>") </script> </body> </html> OUTPUT: Hello World! PROGRAM2: <html> <head> <script type="text/vbscript"> function myFunction() alert("Hello World!") end function </script> </head> <body onload="myFunction()"> <p>We usually use the head section for functions (to be sure that the functions are loaded before they are called).</p> </body> </html> <html> <body> <script type="text/vbscript"> document.write("This message is written by VBScript") </script> </body> </html> document.write("Today's date is " & Date()) document.write("<br />") document.write("The time is " & Time()) p>VBScripts' function <b>WeekdayName</b> is used to get a weekday:</p> <script type="text/vbscript"> document.write("<p>") document.write(WeekDayName(1)) document.write("<br />") document.write(WeekDayName(2)) document.write("</p><p>") document.write("Get the abbreviated name of a weekday:") document.write("<br />") document.write(WeekDayName(1,True)) document.write("<br />") document.write(WeekDayName(2,True)) document.write("</p><p>") document.write("Get the current weekday:") document.write("<br />") document.write(WeekdayName(weekday(Date))) document.write("<br />")

document.write(WeekdayName(weekday(Date), True)) document.write("</p>") OUTPUT: VBScripts' function WeekdayName is used to get a weekday: Sunday Monday Get the abbreviated name of a weekday: Sun Mon Get the current weekday: Tuesday Tue PROGRAM3: <html> <body> <script type="text/vbscript"> i=0 Do While i < 10 document.write(i & "<br />") i=i+1 Loop </script> </body> </html>

OUTPUT: 0 1 2 3 4 5 6 7 8 9 PROGRAM4: <html> <body> <script type="text/vbscript"> Randomize()

document.write(Rnd()) </script> </body> </html> OUTPUT: 0.2730219 15. Discuss briefly about JAVA SERVER PAGE (JSP)? (11 marks) Java Server Pages (JSP) is a Java technology that allows software developers to dynamically generate HTML, XML or other types of documents in response to a Web client request. The technology allows Java code and certain pre-defined actions to be embedded into static content. The JSP syntax adds additional XML-like tags, called JSP actions, to be used to invoke built-in functionality. Additionally, the technology allows for the creation of JSP tag libraries that act as extensions to the standard HTML or XML tags. Tag libraries provide a platform independent way of extending the capabilities of a Web server. JSPs are compiled into Java Servlets by a JSP compiler. A JSP compiler may generate a servlet in Java code that is then compiled by the Java compiler, or it may generate byte code for the servlet directly. JSPs can also be interpreted on-the-fly reducing the time taken to reload changes. Java Servlet technology and Java Server Pages (JSP pages) are server-side technologies that have dominated the server-side Java technology market; they've become the standard way to develop commercial web applications. Java developers love these technologies for myriad reasons, including: the technologies are fairly easy to learn, and they bring the Write Once, Run Anywhere paradigm to web applications. More importantly, if used effectively by following best practices, servlets and JSP pages help separate presentation from content. Best practices are proven approaches for developing quality, reusable, and easily maintainable servletand JSP-based web applications. For instance, embedded Java code (scriptlets) in sections of HTML documents can result in complex applications that are not efficient, and difficult to reuse, enhance, and maintain. Best practices can change all that. In this article, I'll present important best practices for servlets and JSP pages; I assume that you have basic working knowledge of both technologies. This article: Presents an overview of Java servlets and Java Server pages (JSP pages) Provides hints, tips, and guidelines for working with servlets and JSP pages Provides best practices for servlets and JSP pages Overview of Servlets and JSP Pages Similar to Common Gateway Interface (CGI) scripts, servlets support a request and response programming model. When a client sends a request to the server, the server sends the request to the servlet. The servlet then constructs a response that the server sends back to the client. Unlike CGI scripts, however, servlets run within the same process as the HTTP server. When a client request is made, the service method is called and passed a request and response object. The servlet first determines whether the request is a GET or POST operation. It then calls one of the following methods: doGet or doPost. The doGet method is called if the request is GET, and doPost is

called if the request is POST. Both doGet and doPost take request (HttpServletRequest) and response (HttpServletResponse). In the simplest terms, then, servlets are Java classes that can generate dynamic HTML content using print statements. What is important to note about servlets, however, is that they run in a container, and the APIs provide session and object life-cycle management? Consequently, when you use servlets, you gain all the benefits from the Java platform, which include the sandbox (security), database access API via JDBC, and cross-platform portability of servlets. INTRODUCTION TO JAVASERVER PAGES (JSP) JAVASERVER PAGES (JSP) JavaServer Pages (JSP) is an extension of servlet technology. JSPs simplify the delivery of dynamic web content. They allow web programmers to create dynamic content by reusing predefined components and by interacting with components using server-side scripting. JSPs can reuse JavaBeans and create custom tag libraries that encapsulate complex, dynamic functionality.

JSP classes and interfaces can be found in packages javax.servlet.jsp and javax.servlet.jsp.tagext There are four key components to JSPs 1. Directives: messages to the JSP container (server component executing the JSP) that enable the programmer to specify page settings, include content from other resources and specify custom tag libraries to use in a JSP. 2. Actions: encapsulate functionality based on the information send to the server as part of a specific client request. They can also create Java objects for use in JSP scriplets. 3. Scripting elements: enable the programmer to insert Java code that interacts with components in a JSP to perform request processing. 4. Tag libraries: are part of the tag extension mechanism that enables programmers to create custom tags. Typically, most useful for web page designers with little knowledge of Java.

In some ways, JSPs look like standard XHTML or XML documents. JSPs normally include XHTML or XML markup. Such markup is known as fixed-template data or fixed-template text.

Fixed-template data/text often helps a programmer decide whether to use a servlet or a JSP. Recall that JSPs are most often used when most of the content send to the client is fixed-template data and little or none of the content is generated dynamically with Java code. Servlets are more commonly used when only a small amount of the content returned to the client is fixed-template data. When a JSP-enabled server receives the first request for a JSP, the JSP container translates the JSP into a Java servlet that handles the current request as well as all future requests to the JSP. Literal text in the JSP becomes string literals in the servlet that represents the translated JSP. Any errors that occur in compiling the new servlet result in translation-time errors.

The JSP container places the Java statements that implement the JSPs response in method _jspService at translation time. If the new servlet compiles properly, the JSP container invokes method _jspService to process the request. The JSP may respond directly or may invoke other web application components to assist in processing the request. Any errors that occur during request processing are known as request-time errors. Overall, the request-response mechanism and the JSP life-cycle are the same as those of a servlet. JSPs can override methods jspInit and jspDestroy (similar to servlet methods init and destroy), which the JSP container invokes when initializing and terminating a JSP. A JSP programmer defines these methods using JSP declarations which are part of the scripting mechanism.

The JSP technology--which abstracts servlets to a higher level--is an open, freely available specification developed by Sun Microsystems as an alternative to Microsoft's Active Server Pages (ASP) technology, and a key component of the Java 2 Enterprise Edition (J2EE) specification. Many of the commercially available application servers (such as BEA WebLogic, IBM WebSphere, Live JRun, Orion, and so on) support JSP technology. Running JSP Applications How Do JSP Pages Work? A JSP page is basically a web page with traditional HTML and bits of Java code. The file extension of a JSP page is .jsp rather than .html or .htm, which tells the server that this page requires special handling that will be accomplished by a server extension or a plug-in. When a JSP page is called, it will be compiled (by the JSP engine) into a Java servlet. At this point the servlet is handled by the servlet engine, just like any other servlet. The servlet engine then loads the servlet class (using a class loader) and executes it to create dynamic HTML to be sent to the browser, as shown in Figure 1. The servlet creates any necessary object, and writes any object as a string to an output stream to the browser.

Much like a servlet, a JSP must first be processed by a web server before it can be displayed in a web browser. The web server must support JSPs and the JSP page must be stored in a file with a .jsp extension. The web server translates the JSP into a Java servlet, compiles the servlet, and executes it. The result of the execution is sent to the browser for display.

Request/Response flow calling a JSP page The next time the page is requested, the JSP engine executes the already-loaded servlet unless the JSP page has changed, in which case it is automatically recompiled into a servlet and executed. Don't overuse Java code in HTML pages: Putting all Java code directly in the JSP page is OK for very simple applications. But overusing this feature leads to spaghetti code that is not easy to read and understand. One way to minimize Java code in HTML pages is to write separate Java classes that perform the computations. Once these classes are tested, instances can be created. Choose the right include mechanism: Static data such as headers, footers, and navigation bar content is best kept in separate files and not regenerated dynamically. Once such content is in separate files, they can be included in all pages using one of the following include mechanisms: Include directive: <%@ include file="filename" %> Include action: <jsp:include page="page.jsp" flush="true" /> The first include mechanism includes the content of the specified file while the JSP page is being converted to a servlet (translation phase), and the second include includes the response generated after the specified page is executed. I'd recommend using the include directive, which is fast in terms of performance, if the file doesn't change often; and use the include action for content that changes often or if the page to be included cannot be decided until the main page is executed. Another include mechanism is the <c:import> action tag provided by the JavaServer pages Standard Tag Library (JSTL). You can use this tag to bring in, or import, content from local and remote sources. Here are some examples: <c:import url="./copyright.html"/> <c:import url="http://www.somewhere.com/hello.xml"/> Don't mix business logic with presentation: For advanced applications, and when more code is involved, it's important not to mix business logic with front-end presentation in the same file. Separating business logic from presentation permits changes to either side without affecting the other. However, production JSP code should be limited to front-end presentation. So, how do you implement the business logic part? That is where JavaBeans technology comes into play. This technology is a portable, platformindependent component model that lets developers write components and reuse them everywhere. In the context of JSP pages, JavaBeans components contain business logic that returns data to a script on a JSP page, which in turn formats the data returned from the JavaBeans component for display by the browser. A JSP page uses a JavaBeans component by setting and getting the properties that it provides.

The benefits of using JavaBeans components to augment JSP pages are: Reusable components: Different applications will be able to reuse the components. Separation of business logic and presentation logic: You can change the way data is displayed without affecting business logic. In other words, web page designers can focus on presentation and Java developers can focus on business logic.Protects your intellectual property by keeping source code secure. If you use Enterprise JavaBeans (EJBs) components with your application, the business logic should remain in the EJB components which provide life-cycle management, transaction support, and multi-client access to domain objects (Entity Beans). Please refer to the Enterprise BluePrints for further details on this. Use custom tags: Embedding bits of Java code (or scriptlets) in HTML documents may not be suitable for all HTML content developers, perhaps because they do not know the Java language and don't care to learn its syntax. While JavaBeans components can be used to encapsulate much of the Java code, using them in JSP pages still requires content developers to have some knowledge of Java syntax. JSP technology allows you to introduce new custom tags through the tag library facility. As a Java developer, you can extend JSP pages by introducing custom tags that can be deployed and used in an HTML-like syntax. Custom tags also allow you to provide better packaging by improving the separation between business logic and presentation logic. In addition, they provide a means of customizing presentation where this cannot be done easily with JSTL. Some of the benefits of custom tags are: They can eliminate scriptlets in your JSP applications. Any necessary parameters to the tag can be passed as attributes or body content, and therefore no Java code is needed to initialize or set component properties. They have simpler syntax. Scriptlets are written in Java code, but custom tags can be used in an HTMLlike syntax. They can improve the productivity of nonprogrammer content developers, by allowing them to perform tasks that cannot be done with HTML. They are reusable. They save development and testing time. Scriptlets are not reusable, unless you call cut-and-paste "reuse." In short, you can use custom tags to accomplish complex tasks the same way you use HTML to create a presentation. Support for the Model-View-Controller Paradigm

JSP Model 1 Architecture The Model 2 architecture, as shown in Figure 3, integrates the use of both servlets and JSP pages. In this mode, JSP pages are used for the presentation layer, and servlets for processing tasks. The servlet acts as a

controller responsible for processing requests and creating any beans needed by the JSP page. The controller is also responsible for deciding to which JSP page to forward the request. The JSP page retrieves objects created by the servlet and extracts dynamic content for insertion within a template.

JSP Model 2 Architecture This model promotes the use of the Model View Controller (MVC) architectural style design pattern. Note that several frameworks already exist that implement this useful design pattern, and that truly separate presentation from content. The Apache Struts is a formalized framework for MVC. This framework is best used for complex applications where a single request or form submission can result in substantially different-looking results. Tag Libraries and Files JSP OBJECTS The following programming guidelines are handy when writing custom tag libraries: Keep it simple: If a tag requires several attributes, try to break it up into several tags. Make it usable: Consult the users of the tags (HTML developers) to achieve a high degree of usability. Try not to re-invent the wheel: There are several JSP tag libraries available, such as the Jakarta Taglibs Project. Check to see if what you want is already available. Do not reinvent the wheel: While custom tags provide a way to reuse valuable components, they still need to be created, tested, and debugged. In addition, developers often have to reinvent the wheel over and over again and the solutions may not be the most efficient. This is the problem that the Java Server Pages Standard Tag Library (JSTL) solves, by providing a set of reusable standard tags. JSTL defines a standard tag library that works the same everywhere, so you no longer have to iterate over collections using a scriptlet (or iteration tags from numerous vendors). The JSTL includes tags for looping, reading attributes without Java syntax, iterating over various data structures, evaluating expressions conditionally, setting attributes and scripting variables in a concise manner, and parsing XML documents. Use the JSTL Expression Language: Information to be passed to JSP pages is communicated using JSP scoped attributes and request parameters. An expression language (EL), which is designed specifically for page authors, promotes JSP scoped attributes as the standard way to communicate information from business logic to JSP pages. Integrating Servlets and JSP Pages: The JSP specification presents two approaches for building web applications using JSP pages: JSP Model 1 and Model 2 architectures. These two models differ in the location where the processing takes place. In Model 1 architecture, as shown in Figure, the JSP page is responsible for processing requests and sending back replies to clients.

This example shows how to set the value of a JavaBean property to the value of a request parameter with the same name using the JSP standard action jsp:setProperty and how to get the values of JavaBean properties using JSP standard action jsp:getProperty .

<html> <head> <title>Example - Set Property from Associated Parameter</title> </head> <body> <pre> <jsp:useBean id="bean" class="com.stevefarmer.support.TestClass" scope="session"/> <jsp:setProperty name="bean" property="classPropInt" /> <jsp:setProperty name="bean" property="classPropFloat" /> <jsp:setProperty name="bean" property="classPropBool" /> <jsp:setProperty name="bean" property="classPropString"/> bean.classPropInt = <jsp:getProperty name="bean" property="classPropInt" /> bean.classPropFloat = <jsp:getProperty name="bean" property="classPropFloat" /> bean.classPropBool = <jsp:getProperty name="bean" property="classPropBool" /> bean.classPropString = '<jsp:getProperty name="bean" property="classPropString"/>' </pre> </body> </html>

JavaBeans Classes and JSP

Example- Create Bean with Interface Type This example shows how to create a new JavaBean using the JSP standard action jsp:useBean and its class and type attributes and how to get the values of JavaBean properties using JSP standard action jsp:getProperty . <html> <head> <title>Example - Create Bean with Interface Type</title> </head> <body> <pre> <jsp:useBean id="bean" class="com.stevefarmer.support.TestClass" type="com.stevefarmer.support.TestType"/> bean.typePropInt = <jsp:getProperty name="bean" property="typePropInt" /> bean.typePropFloat = <jsp:getProperty name="bean" property="typePropFloat" /> bean.typePropBool = <jsp:getProperty name="bean" property="typePropBool" /> bean.typePropString = '<jsp:getProperty name="bean" property="typePropString"/>' </pre> </body> </html> SCRIPTING IN JSP PAGES http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Bios.html JSP scripting elements allow you to use Java programming language statements in your JSP pages. Scripting elements are typically used to create and access objects, define methods, and manage the flow of control. Many tasks that require the use of scripts can be eliminated by using custom tag libraries, in particular the JSP Standard Tag Library. Because one of the goals of JSP technology is to separate static data from the code needed to dynamically generate content, very sparing use of JSP scripting is recommended. Nevertheless, there may be some circumstances that require its use. There are three ways to create and use objects in scripting elements: Instance and class variables of the JSP page's servlet class are created in declarations and accessed in scriptlets and expressions. Local variables of the JSP page's servlet class are created and used in scriptlets and expressions. Attributes of scope objects (see Using Scope Objects) are created and used in scriptlets and expressions. JSPs often present dynamically generated content as part of an XHTML document that is sent to the client in response to a request. In some cases, the content is static, but is output only if certain conditions are met during a request (e.g., providing values in a form that submits a request). JSP programmers can insert Java code and logic in a JSP using scripting.

JSP scripting components include scriplets, comments, expressions, declarations, and escape sequences. Scriplets are blocks of code delimited by <% and %>. They contain Java statements that the container places in method _jspService at translation time. Comments come in three flavors in JSPs: JSP comments, XHTML comments, and scripting language comments. JSP comments are delimited by <%-- and --%>. Can be placed throughout the JSP except inside scriplets. XHTML comments are delimited by <!-- and -->. Can be placed anywhere in the JSP except inside scriplets. Scripting language comments are Java comments (Java is currently the only JSP scripting language which is allowed). Scriplets can use either // or /* and */ as in normal Java. JSP comments and scripting language comments are ignored and do not appear in the response to a client. When clients view the source code of a JSP response, they will see only the XHTML comments in the source code. The different comment styles are useful for separating comments that the user should be able to see from those that document logic processed on the server-side. Expressions are delimited by <%= and %> and contain a Java expression that is evaluated when a client requests the JSP containing the expression. The contained converts the result of a JSP expression to a String object, then outputs the String as part of the response to the client. Declarations are delimited by <%! and %>. Declarations enable the JSP programmer to define variables and methods for use in a JSP. Variables become instance variables of the servlet class that represents the translated JSP. Similarly, methods become members of the class that represents the translated JSP. Declaration of variables and methods in a JSP use Java syntax such as: <%! int increment = 0; %> Escape sequences are necessary to include special characters or character sequences that the JSP container normally uses to delimit JSP code. Example: literal: <%, escape sequence is: <\% <?xml version = "1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- welcome.jsp --> <!-- JSP that processes a "get" request containing data. --> <html xmlns = "http://www.w3.org/1999/xhtml"> <!-- head section of document --> <head> <title>A JSP that processes "get" requests with data</title> </head> <!-- body section of document --> <body>

<% // begin scriptlet String name = request.getParameter( "firstName" ); if ( name != null ) { %> <%-- end scriptlet to insert fixed template data --%> <h1> Hello <%= name %>, <br /> Welcome to JavaServer Pages Technology! </h1> <% // continue scriptlet } // end if else { %> <%-- end scriptlet to insert fixed template data --%> <form action = "welcome.jsp" method = "get"> <p>Type your first name and press Submit</p> <p><input type = "text" name = "firstName" /> <input type = "submit" value = "Submit" /> </p> </form> <% // continue scriptlet } // end else %> <%-- end scriptlet --%> </body> </html> <!-- end XHTML document -->

STANDARD ACTIONS Example Set Property from value

This example shows how to set the value of a JavaBean property using the JSP standard action jsp:setProperty and its value attribute and how to get the values of JavaBean properties using JSP standard action jsp:getProperty . <html> <head> <title>Example - Set Property from Value</title> </head> <body> <pre> <jsp:useBean id="bean" class="com.stevefarmer.support.TestClass" scope="page"/> <jsp:setProperty name="bean" property="classPropInt" value="11" /> <jsp:setProperty name="bean" property="classPropFloat" value="1.1" /> <jsp:setProperty name="bean" property="classPropBool" value="true" /> <jsp:setProperty name="bean" property="classPropString" value="String 1"/> bean.classPropInt = <jsp:getProperty name="bean" property="classPropInt" /> bean.classPropFloat = <jsp:getProperty name="bean" property="classPropFloat" /> bean.classPropBool = <jsp:getProperty name="bean" property="classPropBool" /> bean.classPropString = '<jsp:getProperty name="bean" property="classPropString"/>' </pre> </body> </html>

JSP DIRECTIVES <%@ page language="lang" %> Sets the JSP script language to lang. Defaults to Java. All JSP 1.0 implementations must support Java. Some implementations, like Resin, may support other scripting languages, e.g. JavaScript.

<%@ page import="package" %> Adds to the Java package import list for the generated Java file.

Note: Only relevant when using Java. <%@ page errorPage="path" %> Defines a page to display if an error occurs in the JSP page. Robust applications can return informative error pages when something goes wrong in a file, for example if a database is overloaded. path is returned as the response file. The error page can use the additional implicit variable exception containing the thrown exception. path is relative to the current page. Its root is relative to the application root. The error page itself can be a JSP page. If the error page is a JSP page, it can use the implicit variable exception to get information about the thrown exception. <%@ page isErrorPage="true" %>

Gives an error page access to the exception implicit variable. Default to false. errorpage.jsp <%@ page isErrorPage="true" %> <h1>Received error <%= exception.message %></h1> <%@ include file="path" %> Includes the raw file path at translation time. The include directive is a replacement for an SSI include (or the C '#include'). It includes the contents of the file at path into the JSP file. The included file is parsed as JSP, so it can have active elements like expressions, declarations and scriptlets. path is relative to the current page, and its root is the application root. B <html><head> <title><%= title %></title> </head> <body color=white>

page.jsp <% var title = "Hello, World"; %> <%@ include file='header.jsp' %>

<h1><%= title %></h1> <%@ page buffer=sizekb %> Gives the size of the page buffer in kb or none for no buffer. Default 8kb. If buffer is none, all output is immediately flushed. JSP 1.0 gives page writers flexibility by buffering its output before sending the response to HTTP. The buffering allows error recovery and forwarding, even after generating some content. Once the buffer has filled, it will be flushed. So applications must still detect their errors early. The following example generates an XML section (for variety). If the form's query is missing the 'name' parameter, it will redirect the results. <?xml version='1.0'?> <form> <% if (request.form["name"] == null) pageContext.forward("redo-form.jsp"); for (var name in request.form) { out.print("<" + name + ">"); out.print(request.form[name]); out.println("</" + name + ">"); } %> </form> <%@ page autoFlush="true" %> Tells JSP to flush the page buffer when it fills. Default is true. If autoFlush is false, the JSP engine will throw an exception if the buffer overflows. <%@ page session="true" %> Tells JSP that the page participates in a session. Defaults to true. The session declaration makes the session implicit variable available to a JSP page. <%@ page isThreadSafe="true" %> Tells the JSP that multiple pages can execute in parallel. Defaults to true. JSP pages are always responsible for synchronization of shared variables, such as the session and application variables. In some rare cases, a page may use servlet variables (created with a declaration), and be too lazy to handle the synchronization.

Even with isThreadSafe=false, the JSP engine may create multiple instances of the JSP servlet. So the page author can never absolve herself of synchronization issues.

In the following example, a JSP engine might create 3 servlet instances of the page. So three calls to the same page may return counts of 17, 3 and 398. In addition, the JSP engine is free to destroy and recreate the servlet at any time, essentially resetting the counter to 0. <%@ page isThreadSafe="false" %> <%! var count = 0; %> <h1>Welcome, visitor <%= count++ %> <%@ page info="description" %> Gives a brief description for the page. <%@ page contentType="description" %> Sets the content type and character encoding of the page. contentType can also set the character encoding, for example to utf-8. <%@ page contentType="text/plain; charset=utf-8" %> <%! var count = 0; %> <h1>Welcome, visitor <%= count++ %> <%@ page extends="Java class" %> Changes the generated servlet's class. In general, a filter is a better solution than using the extends directive. <%@ taglib prefix="x" uri="foo" %> Configures tags with prefix x to use the tag library foo. <%@ taglib prefix='x' uri='http://www.caucho.com/mytag/test' %> <x:mytag/> 16. Explain the Accessing a Database from an ASP Page (11 marks) The common way to access a database from inside an ASP page is to: 1. 2. 3. 4. 5. 6. 7. Create an ADO connection to a database Open the database connection Create an ADO recordset Open the recordset Extract the data you need from the recordset Close the recordset Close the connection

Extract Data from the Recordset

After a recordset is opened, we can extract data from recordset. Suppose we have a database named "Northwind", we can get access to the "Customers" table inside the database with the following lines: <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" set rs=Server.CreateObject("ADODB.recordset") rs.Open "Select * from Customers", conn for each x in rs.fields response.write(x.name) response.write(" = ") response.write(x.value) next %> Display records in an HTML table <html> <body> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open(Server.Mappath("/db/northwind.mdb")) set rs = Server.CreateObject("ADODB.recordset") rs.Open "SELECT Companyname, Contactname FROM Customers", conn %> <table border="1" width="100%"> <%do until rs.EOF%> <tr> <%for each x in rs.Fields%> <td><%Response.Write(x.value)%></td> <%next rs.MoveNext%> </tr> <%loop rs.close conn.close %> </table> </body> </html>

ADO RecordCount Property

Syntax objRecordset.RecordCount Example <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open(Server.Mappath("northwind.mdb")) set rs=Server.CreateObject("ADODB.recordset") sql="SELECT * FROM Customers" rs.Open sql,conn if rs.Supports(adApproxPosition)=true then i=rs.RecordCount response.write("The number of records is: " & i) end if rs.Close conn.Close %> Update record in table <html> <body> <h2>Update Record</h2> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" cid=Request.Form("customerID") if Request.form("companyname")="" then set rs=Server.CreateObject("ADODB.Recordset") rs.open "SELECT * FROM customers WHERE customerID='" & cid & "'",conn %> <form method="post" action="demo_update.asp"> <table> <%for each x in rs.Fields%> <tr> <td><%=x.name%></td> <td><input name="<%=x.name%>" value="<%=x.value%>"></td> <%next%> </tr> </table> <br /><br /> <input type="submit" value="Update record"> </form> <% else sql="UPDATE customers SET " sql=sql & "companyname='" & Request.Form("companyname") & "'," sql=sql & "contactname='" & Request.Form("contactname") & "'," sql=sql & "address='" & Request.Form("address") & "',"

sql=sql & "city='" & Request.Form("city") & "'," sql=sql & "postalcode='" & Request.Form("postalcode") & "'," sql=sql & "country='" & Request.Form("country") & "'" sql=sql & " WHERE customerID='" & cid & "'" on error resume next conn.Execute sql if err<>0 then response.write("No update permissions!") else response.write("Record " & cid & " was updated!") end if end if conn.close %> </body> </html>

Delete a Record in a Table <html> <body> <h2>Delete Record</h2> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" cid=Request.Form("customerID") if Request.form("companyname")="" then set rs=Server.CreateObject("ADODB.Recordset") rs.open "SELECT * FROM customers WHERE customerID='" & cid & "'",conn %> <form method="post" action="demo_delete.asp"> <table> <%for each x in rs.Fields%> <tr> <td><%=x.name%></td> <td><input name="<%=x.name%>" value="<%=x.value%>"></td> <%next%> </tr> </table> <br /><br /> <input type="submit" value="Delete record"> </form> <% else sql="DELETE FROM customers" sql=sql & " WHERE customerID='" & cid & "'" on error resume next conn.Execute sql if err<>0 then response.write("No update permissions!")

else response.write("Record " & cid & " was deleted!") end if end if conn.close %> </body> </html> Sort the Data <html> <body> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" set rs = Server.CreateObject("ADODB.recordset") sql="SELECT Companyname, Contactname FROM Customers ORDER BY CompanyName" rs.Open sql, conn %> <table border="1" width="100%"> <tr> <%for each x in rs.Fields response.write("<th>" & x.name & "</th>") next%> </tr> <%do until rs.EOF%> <tr> <%for each x in rs.Fields%> <td><%Response.Write(x.value)%></td> <%next rs.MoveNext%> </tr> <%loop rs.close conn.close%> </table> </body> </html> Selected Data <html> <body> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb"

set rs=Server.CreateObject("ADODB.recordset") sql="SELECT Companyname, Contactname FROM Customers WHERE CompanyName LIKE 'A%'" rs.Open sql, conn %> <table border="1" width="100%"> <tr> <%for each x in rs.Fields response.write("<th>" & x.name & "</th>") next%> </tr> <%do until rs.EOF%> <tr> <%for each x in rs.Fields%> <td><%Response.Write(x.value)%></td> <%next rs.MoveNext%> </tr> <%loop rs.close conn.close%> </table> </body> </html> No. Of Visitors <% Set FS=Server.CreateObject("Scripting.FileSystemObject") Set RS=FS.OpenTextFile(Server.MapPath("counter.txt"), 1, False) fcount=RS.ReadLine RS.Close fcount=fcount+1 'This code is disabled due to the write access security on our server: 'Set RS=FS.OpenTextFile(Server.MapPath("counter.txt"), 2, False) 'RS.Write fcount 'RS.Close Set RS=Nothing Set FS=Nothing %> <html> <body> <p> This page has been visited <%=fcount%> times. </p> </body> </html> Counter.txt 0

ADROTATOR <% url=Request.QueryString("url") If url<>"" then Response.Redirect(url) %> <html><body> <% set adrotator=Server.CreateObject("MSWC.AdRotator") adrotator.TargetFrame="target='_blank'" response.write(adrotator.GetAdvertisement("text/advertisements2.txt")) %> <p>NOTE: Because images are changed randomly, and because this page has few images to choose from, it will often display the same advertisement twice in a row.</p> <p><a href="text/advertisements2.txt"><img border="0" src="/images/btn_view_text.gif"></a></p> </body></html> REDIRECT demo_adrotator2.asp * /banners/rd_htmlref.jpg http://www.w3schools.com/html/html_reference.asp Complete HTML 4.0 Reference 20 /banners/w3schools.gif http://www.w3schools.com Web Tutorials from W3Schools 20 /banners/rd_xhtml.jpg http://www.w3schools.com/xhtml/default.asp XHTML Tutorial 20

16. Discuss about the SESSION AND COOKIES? (11 marks) SESSION TRACKING Session tracking is a mechanism that servlets use to maintain state about a series of requests from the same user (that is, requests originating from the same browser) across some period of time. SESSION-TRACKING BASICS Every user of a site is associated with a javax.servlet.http.HttpSession object that servlets can use to store or retrieve information about that user Basic session tracking functionalities, Obtain a session (an HttpSession object) for a user. Store or get data from the HttpSession object. Invalidate the session (optional).

GET SESSION

A servlet uses its request object's getSession() method to retrieve the current HttpSession object: public HttpSession HttpServletRequest.getSession(boolean create) This method returns the current session associated with the user making the request. If the user has no current valid session, this method creates one if create is true or returns null if create is false. To ensure the session is properly maintained, this method must be called at least once before any output is written to the response. PUT VALUE You can add data to an HttpSession object with the putValue() method: public void HttpSession.putValue(String name, Object value) This method binds the specified object value under the specified name. Any existing binding with the same name is replaced. GET VALUE To retrieve an object from a session, use getValue(): public Object HttpSession.getValue(String name) This methods returns the object bound under the specified name or null if there is no binding. You can also get the names of all of the objects bound to a session with getValueNames(): public String[] HttpSession.getValueNames() This method returns an array that contains the names of all objects bound to this session or an empty (zero length) array if there are no bindings. REMOVE VALUE Finally, you can remove an object from a session with removeValue(): public void HttpSession.removeValue(String name) This method removes the object bound to the specified name or does nothing if there is no binding Each of these methods can throw a java.lang.IllegalStateException if the session being accessed is invalid. THE SESSION LIFE CYCLE Sessions do not last forever. A session either expires automatically, after a set time of inactivity (for the Java Web Server the default is 30 minutes), or manually, when it is explicitly invalidated by a servlet. When a session expires (or is invalidated), the HttpSession object and the data values it contains are removed from the system. Beware that any information saved in a user's session object is lost when the session is invalidated. If you need to retain information beyond that time, you should keep it in an external location (such as a database) and store a handle to the external data in the session object (or your own persistent cookie)

URL REWRITING

METHODS INVOLVED IN MANAGING THE SESSION LIFE CYCLE: public boolean HttpSession.isNew() This method returns whether the session is new or not. public void HttpSession.invalidate() This method causes the session to be immediately invalidated. All objects stored in the session are unbound. public long HttpSession.getCreationTime() This method returns the time at which the session was created public long HttpSession.getLastAccessedTime() This method returns the time at which the client last sent a request associated with this session. COOKIES In Javascript, cookies are a mechanism for storing persistent data on the client in a file called cookies.txt. Because Hypertext Transport Protocol (HTTP) is a stateless protocol, cookies provide a way to maintain information between client requests. Each cookie is a small item of information with an optional expiration date and is added to the cookie file in the following format: name=value;expires=expDate; Here, name is the name of the datum being stored, and value is its value. expDate is the expiration date, in GMT date format: Wdy, DD-Mon-YY HH:MM:SS GMT Below is a simple function named setCookie() to create a cookie called myname. It also uses a function getCookie() to get the value of a cookie, if cookie name exist and is given as an argument. We end the discussion of javascript by providing you with the organizational chart which features you the hierarchy of objects of HTML 4.0 that can be easily accessed using the javascript 17. Explain briefly about developing n-tier web application? (11 marks) MULTI-TIER APPLICATIONS In software engineering, multi-tier architecture (often referred to as n-tier architecture) is a client-server architecture in which, the presentation, the application processing and the data management are logically separate processes. For example, an application that uses middleware to service data requests between a user and a database employs multi-tier architecture. The most widespread use of "multi-tier architecture" refers to three-tier architecture. The concepts of layer and tier are often used interchangeably. However, one fairly common point of view is that there is indeed a difference, and that a layer is a logical structuring mechanism for the elements that make up the software solution, while a tier is a physical structuring mechanism for the system infrastructure. Three-tier is a client-server architecture in which the user interface, functional process logic ("business rules"), computer data storage and data access are developed and maintained as independent modules, most often on separate platforms. The three-tier model is considered to be a software architecture and a software design pattern. Apart from the usual advantages of modular software with well-defined interfaces, the three-tier architecture is intended to allow any of the three tiers to be upgraded or replaced independently as requirements or technology change. For example, a change of operating system in the presentation tier would only affect the user interface code.

Typically, the user interface runs on a desktop PC or workstation and uses a standard graphical user interface, functional process logic may consist of one or more separate modules running on a workstation or application server, and an RDBMS on a database server or mainframe contains the computer data storage logic. The middle tier may be multi-tiered itself (in which case the overall architecture is called an "n-tier architecture"). The 3-Tier architecture has the following three tiers: Presentation Tier This is the topmost level of the application. The presentation tier displays information related to such services as browsing merchandise, purchasing, and shopping cart contents. It communicates with other tiers by outputting results to the browser/client tier and all other tiers in the network. Application Tier (Business Logic/Logic Tier) The logic tier is pulled out from the presentation tier and, as its own layer; it controls an applications functionality by performing detailed processing. Data Tier This tier consists of Database Servers. Here information is stored and retrieved. This tier keeps data neutral and independent from application servers or business logic. Giving data its own tier also improves scalability and performance. Comparison with the MVC architecture At first glance, the three tiers may seem similar to the Model-view-controller (MVC) concept; however, topologically they are different. A fundamental rule in three-tier architecture is the client tier never communicates directly with the data tier; in a three-tier model all communication must pass through the middleware tier. Conceptually the three-tier architecture is linear. However, the MVC architecture is triangular: the View sends updates to the Controller, the Controller updates the Model, and the View gets updated directly from the Model. From a historical perspective the three-tier architecture concept emerged in the 1990's from observations of distributed systems (e.g., web applications) where the client, middleware and data tiers ran on physically separate platforms. Whereas MVC comes from the previous decade (by work at Xerox PARC in the late 1970's and early 1980's) and is based on observations of applications that ran on a single graphical workstation; MVC was applied to distributed applications much later in its history. Web Development usage In the Web development field, three-tier is often used to refer to Websites, commonly electronic commerce websites, which are built using three tiers: A front end Web server serving static content. A middle dynamic content processing and generation level Application server, for example Java EE platform. A back end Database, comprising both data sets and the Database management system or RDBMS software that manages and provides access to the data. DATABASE-CENTRIC ARCHITECTURE Database-centric architecture or data-centric architecture has several distinct meanings, generally relating to software architectures in which databases play a crucial role. Often this description is meant to contrast the design to an alternative approach. For example, the characterization of architecture as "database-centric" may mean any combination of the following:

using a standard, general-purpose relational database management system, as opposed to customized in-memory or file-based data structures and access methods. With the evolution of sophisticated DBMS software, much of which is either free or included with the operating system, application developers have become increasingly reliant on standard database tools, especially for the sake of rapid application development. Using dynamic, table-driven logic, as opposed to logic embodied in previously compiled programs. The use of table-driven logic, i.e. behavior that is heavily dictated by the contents of a database, allows programs to be simpler and more flexible. This capability is a central feature of dynamic programming languages. using stored procedures that run on database servers, as opposed to greater reliance on logic running in middle-tier application servers in a multi-tier architecture. The extent to which business logic should be placed at the back-end versus another tier is a subject of ongoing debate. For example, Toon Koppelaars presents a detailed analysis of alternative Oracle-based architectures that vary in the placement of business logic, concluding that a database-centric approach has practical advantages from the standpoint of ease of development and maintainability. using a shared database as the basis for communicating between parallel processes in distributed computing applications, as opposed to direct inter-process communication via message passing functions and message-oriented middleware. A potential benefit of database-centric architecture in distributed applications is that it simplifies the design by utilizing DBMS-provided transaction processing and indexing to achieve a high degree of reliability, performance, and capacity. For example, Base One describes a database-centric distributed computing architecture for grid and cluster computing, and explains how this design provides enhanced security, fault-tolerance, and scalability.

MULTI-TIER APPLICATIONS N-tier (multi-tier) applications have become the norm for building enterprise software today. To most people, an N-tier application is anything that is divided into discrete logical parts. The most common choice is a three-part breakdownpresentation, business logic, and data although other possibilities exist. N-tier applications first emerged as a way of solving some of the problems associated with traditional client/server applications, but with the arrival of the Web, this architecture has come to dominate new development. The Microsoft Windows DNA technology has been a very successful foundation for N-tier applications. The Microsoft .NET Framework also provides a solid platform for building N-tier applications. Yet the changes .NET brings should make architects re-think some of the lessons they've learned in the Windows DNA world about designing N-tier applications. Even more important, the fundamental support for XML Web services built into the .NET Framework allows building new kinds of applications that go beyond the traditional N-tier approach. Understanding how best to architect applications for .NET requires knowing what changes in this new world and how to exploit these changes. This article takes a look at these issues, beginning with a review of key architectural lessons learned in building N-tier applications using Windows DNA. It next examines these same findings, in the same order, as they apply to building applications using the .NET Framework. The final section provides some advice on architecture for applications that use XML Web services.

CLIENT / SERVER APPLICATIONS Typically, cooperating applications can be categorized as either a client or a server. The client application requests services and data from the server, and the server application responds to client requests. Early two-tier (client/server) applications were developed to access large databases, and incorporated the rules used to manipulate the data with the user interface into the client application. The server's task was simply to process as many requests for data storage and retrieval as possible. Two-tier applications perform many of the functions of stand-alone systems: They present a user interface, gather and process user input, perform the requested processing, and report the status of the request. This sequence of commands can be repeated as many times as necessary. Because servers provide only access to the data, the client uses its local resources to perform most of the processing. One major advantage of the client/server model was that by allowing multiple users to simultaneously access the same application data, updates from one computer were instantly made available to all computers that had access to the server. However, as the number of clients increased, the server would quickly become overwhelmed with client requests. Also, because much of the processing logic was tied to a monolithic suite of applications, changes in business rules led to expensive and time-consuming alterations to source code. Although the ease and flexibility of two-tier products continue to drive many small-scale business applications, the need for faster data access and more rapid developmental timelines has persuaded systems developers to seek out a new way of creating distributed applications.

UNIT-III XML AND ACTIVE X 2 MARKS 1. What is meant by DTD? DTD (Document Type Definition).It is useful standard for validating the xml document. These standards are useful to creating a quality xml document.

2. How to create xml document? Xml document can be created using text editor like notepad text edit and other software like team viewer and notepad++.

3. What are xml parsing errors? Each parsing software can handle different errors has different parsing error messages. The common errors are: closing tags elements not matching up closing quotations Incorrect order.

4. What are the rules for creating DTD? The rules are: When creating DTD, the elements and their attributes have to be defined. To link a DTD with the XML document, the prolong section of the xml document should be specified about the link of the DTD element.

5. What is meant by active X? Active X will be used to enable the developers to choose their own languages, tools and they can re-use the existing active X components in their application.

6. What are the technologies include in active X? The technologies are:


ActiveX documents. ActiveX controls. ActiveX scripting. ActiveX enabled internet protocols. ActiveX API.

7. What is meant Active X scripting? Active X scripting enables the script to be written in variety of scripting language. It includes two components:

scripting hosts Scripting engine.

8. What is meant by scripting engine? A scripting engine is responsible for processing script commands and performing script actions. The script engines are:

Microsoft internet explorer Microsoft server products Microsoft front page.

9. What is meant by OLE? OLE is the extension of DDE (Dynamic Data Exchange).OLE was capable of maintaining active links between two documents and embedding one type of document within another.

10. Write about get Content method ()? The get Content method () is used to handle the information received from the input stream.

11. What is the use of xml namespace? XML allows document authors to create custom elements. This extensibility can result in naming collisions (i.e. different elements that have the same name) among elements in an XML document. An XML namespace is a collection of element and attribute names. Each namespace has a unique name that provides a means for document authors to unambiguously refer to elements with the same name (i.e. prevent collisions). 12. What are the uses of xml? CML Chemical Markup Language for chemical equations MML - Mathematical Markup Language for Mathematical equations and derivations. Used in bio medical line. 13. What is the use of xml? Extensible Markup Language, derived from SGML (Standard Generalized Markup Language. XML is widely supported open technology (i.e. non-proprietary) for electronic data exchange and storage. XML is actually a language used to create other markup languages to describe data in a structured manner. XML documents contain only data, not formatting instructions, so applications that process XML documents must decide how to manipulate or display the documents data.

14. What do you mean by DTD in xml? DTD means Document Type Definition. DTD file is similar to CSS file, because DTD also contains only styles. DTD contains various styles which are to be applied in XML document. Like .CSS file .DTD file also should be linked with XML program. Styles in XML program should be save with .xsl (Xml Style Sheet Language) extension

15. Define XML. XML is a meta-markup language that provides a format for describing structured data. This facilitates more structured declarations of content and more meaningful search results across multiple platforms. 16. Write a note on ActiveX controls? A loosely defined set of technologies developed by Microsoft for sharing information among different applications. ActiveX is an outgrowth of two other Microsoft technologies called OLE (Object Linking and Embedding) and COM (Component Object Model). As a moniker, ActiveX can be very confusing because it applies to a whole set of COM-based technologies.

Most people, however, think only of ActiveX controls, which represent a specific way of implementing ActiveX technologies. 17. What is the DOM? The DOM defines a standard for accessing documents like XML and HTML: "The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."

18. List the XML DOM? XML DOM definition XML DOM Nodes XML DOM - Properties and Methods XML DOM Parser XML Load functions What is the XML DOM? The XML DOM is: A standard object model for XML A standard programming interface for XML Platform- and language-independent A W3C standard

List the XML DOM Properties

These are some typical DOM properties: x.nodeName - the name of x x.nodeValue - the value of x x.parentNode - the parent node of x x.childNodes - the child nodes of x x.attributes - the attributes nodes of x

List the XML DOM Methods x.getElementsByTagName(name) - get all elements with a specified tag name x.appendChild(node) - insert a child node to x x.removeChild(node) - remove a child node from x

22. What are ACTIVEX documents? An existing application that doesn't need to be embedded in a Web page can be converted to an ActiveX document. ActiveX documents are based upon a more general abstraction called DocObjects. The DocObjects technology is a set of extensions to OLE documents, the compound document technology of OLE. As with OLE documents, the DocObjects standard requires a container to provide the display space for a DocObject.

11 MARKS 1. Write short notes on anatomy of XML document? (5 marks)


XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to describe data XML tags are not predefined. You must define your own tags XML uses a Document Type Definition (DTD) or an XML Schema to describe the data XML with a DTD or XML Schema is designed to be self-descriptive

The main difference between XML and HTML XML was designed to carry data. XML is not a replacement for HTML. XML and HTML were designed with different goals: XML was designed to describe data and to focus on what data is. HTML was designed to display data and to focus on how data looks. HTML is about displaying information, while XML is about describing information. XML is free and extensible XML tags are not predefined. You must "invent" your own tags. The tags used to mark up HTML documents and the structure of HTML documents is predefined. The author of HTML documents can only use tags that are defined in the HTML standard (like <p>, <h1>, etc.). XML allows the author to define his own tags and his own document structure.

The tags in the example above (like <to> and <from>) are not defined in any XML standard. These tags are "invented" by the author of the XML document.

How can XML be used? It is important to understand that XML was designed to store, carry, and exchange data. XML was not designed to display data. XML can separate Data from HTML With XML, your data is stored outside your HTML. When HTML is used to display data, the data is stored inside your HTML. With XML, data can be stored in separate XML files. This way you can concentrate on using HTML for data layout and display, and be sure that changes in the underlying data will not require any changes to your HTML. XML data can also be stored inside HTML pages as "Data Islands". You can still concentrate on using HTML only for formatting and displaying the data. XML is used to Exchange Data With XML, data can be exchanged between incompatible systems. In the real world, computer systems and databases contain data in incompatible formats. One of the most time-consuming challenges for developers has been to exchange data between such systems over the Internet. Converting the data to XML can greatly reduce this complexity and create data that can be read by many different types of applications.

XML can be used to Share Data With XML, plain text files can be used to share data. Since XML data is stored in plain text format, XML provides a software- and hardware-independent way of sharing data. This makes it much easier to create data that different applications can work with. It also makes it easier to expand or upgrade a system to new operating systems, servers, applications, and new browsers. XML can be used to Store Data With XML, plain text files can be used to store data. XML can also be used to store data in files or in databases. Applications can be written to store and retrieve information from the store, and generic applications can be used to display the data. XML can make your Data more Useful With XML, your data is available to more users. Since XML is independent of hardware, software and application, you can make your data available to other than only standard HTML browsers. Other clients and applications can access your XML files as data sources, like they are accessing databases. Your data can be made available to all kinds of "reading machines" (agents), and it is easier to make your data available for blind people, or people with other disabilities. XML can be used to create new Languages XML is the mother of WAP and WML. The Wireless Markup Language (WML), used to markup Internet applications for handheld devices like mobile phones, is written in XML. 2. Explain briefly about XML MARKUP language? (5 marks)

The syntax rules of XML are very simple and very strict. The rules are very easy to learn, and very easy to use. Because of this, creating software that can read and manipulate XML is very easy to do. An example XML document XML documents use a self-describing and simple syntax. <? xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> The first line in the document - the XML declaration - defines the XML version and the character encoding used in the document. In this case the document conforms to the 1.0 specification of XML and uses the ISO-8859-1 (Latin-1/West European) character set. The next line describes the root element of the document (like it was saying: "this document is a note"): <note>

The next 4 lines describe 4 child elements of the root (to, from, heading, and body): <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> And finally the last line defines the end of the root element: 3. Discuss about working with xml elements and attributes? (11 marks) XML ELEMENTS All XML elements must have a closing tag With XML, it is illegal to omit the closing tag. In HTML some elements do not have to have a closing tag. The following code is legal in HTML: <p>This is a paragraph <p>This is another paragraph In XML all elements must have a closing tag, like this: <p>This is a paragraph</p> <p>This is another paragraph</p> XML tags are case sensitive Unlike HTML, XML tags are case sensitive. With XML, the tag <Letter> is different from the tag <letter>. Opening and closing tags must therefore be written with the same case: <Message>This is incorrect</message>

<message>This is correct</message> All XML elements must be properly nested Improper nesting of tags makes no sense to XML. In HTML some elements can be improperly nested within each other like this: <b><i>This text is bold and italic</b></i> In XML all elements must be properly nested within each other like this: <b><i>This text is bold and italic</i></b> All XML documents must have a root element All XML documents must contain a single tag pair to define a root element. All other elements must be within this root element. All elements can have sub elements (child elements). Sub elements must be correctly nested within their parent element: <root> <child> <subchild>.....</subchild> </child> </root>

Attribute values must always be quoted With XML, it is illegal to omit quotation marks around attribute values. XML elements can have attributes in name/value pairs just like in HTML. In XML the attribute value must always be quoted. Study the two XML documents below. The first one is incorrect, the second is correct: <?xml version="1.0" encoding="ISO-8859-1"?> <note date=12/11/2002> <to>Tove</to> <from>Jani</from> </note> <?xml version="1.0" encoding="ISO-8859-1"?> <note date="12/11/2002"> <to>Tove</to> <from>Jani</from> </note> The error in the first document is that the date attribute in the note element is not quoted. This is correct: date="12/11/2002". This is incorrect: date=12/11/2002. With XML, white space is preserved With XML, the white space in your document is not truncated. This is unlike HTML. With HTML, a sentence like this: Hello my name is Tove, will be displayed like this: Hello my name is Tove, because HTML strips off the white space.

With XML, CR / LF is converted to LF With XML, a new line is always stored as LF. Do you know what a typewriter is? Well, a typewriter is a mechanical device used in the previous century to produce printed documents. :-) After you have typed one line of text on a typewriter, you have to manually return the printing carriage to the left margin position and manually feed the paper up one line. In Windows applications, a new line is normally stored as a pair of characters: carriage return (CR) and line feed (LF). The character pair bears some resemblance to the typewriter actions of setting a new line. In Unix applications, a new line is normally stored as a LF character. Macintosh applications use only a CR character to store a new line. Comments in XML The syntax for writing comments in XML is similar to that of HTML. <!-- This is a comment --> There is nothing special about XML There is nothing special about XML. It is just plain text with the addition of some XML tags enclosed in angle brackets. Software that can handle plain text can also handle XML. In a simple text editor, the XML tags will be visible and will not be handled specially. In an XML-aware application however, the XML tags can be handled specially. The tags may or may not be visible, or have a functional meaning, depending on the nature of the application.

XML ATTRIBUTES XML elements can have attributes in the start tag, just like HTML. Attributes are used to provide additional information about elements. XML elements can have attributes. From HTML you will remember this: <IMG SRC="computer.gif">. The SRC attribute provides additional information about the IMG element. In HTML (and in XML) attributes provide additional information about elements: <img src="computer.gif"> <a href="demo.asp"> Attributes often provide information that is not a part of the data. In the example below, the file type is irrelevant to the data, but important to the software that wants to manipulate the element: <file type="gif">computer.gif</file> Take a look at these examples: <person sex="female"> <firstname>Anna</firstname> <lastname>Smith</lastname> </person> <person>

<sex>female</sex> <firstname>Anna</firstname> <lastname>Smith</lastname> </person> In the first example sex is an attribute. In the last, sex is a child element. Both examples provide the same information. There are no rules about when to use attributes, and when to use child elements. My experience is that attributes are handy in HTML, but in XML you should try to avoid them. Use child elements if the information feels like data. Should you avoid using attributes? Here are some of the problems using attributes: attributes cannot contain multiple values (child elements can) attributes are not easily expandable (for future changes) attributes cannot describe structures (child elements can) attributes are more difficult to manipulate by program code attribute values are not easy to test against a Document Type Definition (DTD) - which is used to define the legal elements of an XML document If you use attributes as containers for data, you end up with documents that are difficult to read and maintain. Try to use elements to describe data. Use attributes only to provide information that is not relevant to the data.

4. Write short notes on creating valid documents? (5 marks) XML with correct syntax is Well Formed XML. XML validated against a DTD is Valid XML. "Well Formed" XML documents A "Well Formed" XML document has corrects XML syntax. A "Well Formed" XML document is a document that conforms to the XML syntax rules that were described in the previous chapters: <?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> A "Valid" XML document also conforms to a DTD. A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD): <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE note SYSTEM "InternalNote.dtd"> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading>

<body>Don't forget me this weekend!</body> </note> XML DTD A DTD defines the legal elements of an XML document. The purpose of a DTD is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements. You can read more about DTD, and how to validate your XML documents in our DTD tutorial. XML Schema XML Schema is an XML based alternative to DTD. W3C supports an alternative to DTD called XML Schema. You can read more about XML Schema in our Schema tutorial. Errors will stop you Errors in XML documents will stop the XML program. The W3C XML specification states that a program should not continue to process an XML document if it finds a validation error. The reason is that XML software should be easy to write, and that all XML documents should be compatible. With HTML it was possible to create documents with lots of errors (like when you forget an end tag). One of the main reasons that HTML browsers are so big and incompatible, is that they have their own ways to figure out what a document should look like when they encounter an HTML error. With XML this should not be possible.

A general XML Validator To help you validate your xml files, we have created this link so that you can validate any XML file. Viewing XML Files Raw XML files can be viewed in IE 5.0 (and higher) and in Netscape 6, but to make it display like a web page, you have to add some display information. Viewing XML Files To view an XML document in IE 5.0 (and higher) you can click on a link, type the URL in the address bar, or double-click on the name of an XML file in a files folder. If you open an XML document in IE, it will display the document with color coded root and child elements. A plus (+) or minus sign (-) to the left of the elements can be clicked to expand or collapse the element structure. If you want to view the raw XML source, you must select "View Source" from the browser menu. To view an XML document in Netscape 6 you'll have to open the XML file and then right-click in XML file and select "View Page Source". If you open an XML document in Netscape 6, it will display the document with color coded root and child elements. 5. Write a short note on XML OBJECTS AND DOM? (11 marks) What is the DOM? The DOM defines a standard for accessing documents like XML and HTML:

"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document." DOM, the so-called Document Object Model, is another name in this context for how XML can be read into memory as a tree/hierarchy and manipulated by a script or program. When an HTML page is loaded, the same is done. The browser is programmed to create an internal 'tree'/hierarchical representation, and certain properties and methods are available to read or modify parts of this internal page hierarchy. Those made available would be called the - application programming interface. The DOM is separated into 3 different parts / levels:

Core DOM - standard model for any structured document XML DOM - standard model for XML documents HTML DOM - standard model for HTML documents

The DOM defines the objects and properties of all document elements, and the methods (interface) to access them. XML DOM XML DOM definition XML DOM Nodes XML DOM - Properties and Methods XML DOM Parser XML Load functions

What is the XML DOM? The XML DOM is:


A standard object model for XML A standard programming interface for XML Platform- and language-independent A W3C standard

The XML DOM defines the objects and properties of all XML elements, and the methods (interface) to access them. In the DOM, everything in an XML document is a node.In other words: The XML DOM is a standard for how to get, change, add, or delete XML elements. DOM Nodes According to the DOM, everything in an XML document is a node. The DOM says:

The entire document is a document node Every XML element is an element node The text in the XML elements are text nodes Every attribute is an attribute node

Comments are comment nodes

DOM Example <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="cooking"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="children"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="web"> <title lang="en">XQuery Kick Start</title> <author>James McGovern</author> <author>Per Bothner</author> <author>Kurt Cagle</author> <author>James Linn</author> <author>Vaidyanathan Nagarajan</author> <year>2003</year> <price>49.99</price> </book> <book category="web" cover="paperback"> <title lang="en">Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore> The root node in the XML above is named <bookstore>. All other nodes in the document are contained within <bookstore>.The root node <bookstore> holds four <book> nodes. The first <book> node holds four nodes: <title>, <author>, <year>, and <price>, which contains one text node each, "Everyday Italian", "Giada De Laurentiis", "2005", and "30.00". A common error in DOM processing is to expect an element node to contain text. However, the text of an element node is stored in a text node.In this example: <year>2005</year>, the element node <year>, holds a text node with the value "2005". XML DOM Tree Example

XML DOM - Properties and Methods Programming Interface: The DOM models XML as a set of node objects. The nodes can be accessed with JavaScript or other programming languages. In this tutorial we use JavaScript. The programming interface to the DOM is defined by a set standard properties and methods.Properties are often referred to as something that is (i.e. nodename is "book").Methods are often referred to as something that is done (i.e. delete "book").

XML DOM Properties These are some typical DOM properties:


x.nodeName - the name of x x.nodeValue - the value of x x.parentNode - the parent node of x x.childNodes - the child nodes of x x.attributes - the attributes nodes of x

Note: In the list above, x is a node object. XML DOM Methods


x.getElementsByTagName(name) - get all elements with a specified tag name x.appendChild(node) - insert a child node to x x.removeChild(node) - remove a child node from x

Note: In the list above, x is a node object.

Example The JavaScript code to get the text from the first <title> element in books.xml: txt=xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue After the execution of the statement, txt will hold the value "Everyday Italian" Explained:

xmlDoc - the XML DOM object created by the parser. getElementsByTagName("title")[0] - the first <title> element childNodes[0] - the first child of the <title> element (the text node) nodeValue - the value of the node (the text itself)

XML DOM Parser Most browsers have a build-in XML parser to read and manipulate XML. The parser converts XML into a JavaScript accessible object (the XML DOM). XML Parser The XML DOM contains methods (functions) to traverse XML trees, access, insert, and delete nodes.However, before an XML document can be accessed and manipulated, it must be loaded into an XML DOM object.An XML parser reads XML, and converts it into an XML DOM object that can be accessed with JavaScript. Most browsers have a build-in XML parser.

XML Accessing Nodes You can access a node in three ways: 1. By using the getElementsByTagName() method 2. By looping through (traversing) the nodes tree. 3. By navigating the node tree, using the node relationships. The getElementsByTagName() Method getElementsByTagName() returns all elements with a specified tag name. Syntax node.getElementsByTagName("tagname"); Example The following example returns all <title> elements under the x element:

x.getElementsByTagName("title"); Note that the example above only returns <title> elements under the x node. To return all <title> elements in the XML document use: xmlDoc.getElementsByTagName("title"); where xmlDoc is the document itself (document node). DOM Node List The getElementsByTagName() method returns a node list. A node list is an array of nodes. The following code loads "books.xml" into xmlDoc using loadXMLDoc() and stores a list of <title> nodes (a node list) in the variable x: xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.getElementsByTagName("title"); The <title> elements in x can be accessed by index number. To access the third <title> you can write:: y=x[2];

DOM Node List Length The length property defines the length of a node list (the number of nodes). You can loop through a node list by using the length property: Example xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.getElementsByTagName("title"); for (i=0;i<x.length;i++) { document.write(x[i].childNodes[0].nodeValue); document.write("<br />"); } Example explained: 1. Load "books.xml" into xmlDoc using loadXMLDoc() 2. Get all <title> element nodes 3. For each title element, output the value of its text node

Node Types The documentElement property of the XML document is the root node. The nodeName property of a node is the name of the node. The nodeType property of a node is the type of the node. NodeType 1 2 3 4 5 6 7 8 9 10 11 12 Named Constant ELEMENT_NODE ATTRIBUTE_NODE TEXT_NODE CDATA_SECTION_NODE ENTITY_REFERENCE_NODE ENTITY_NODE PROCESSING_INSTRUCTION_NODE COMMENT_NODE DOCUMENT_NODE DOCUMENT_TYPE_NODE DOCUMENT_FRAGMENT_NODE NOTATION_NODE

Traversing Nodes The following code loops through the child nodes, that are also element nodes, of the root node: Example xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.documentElement.childNodes; for (i=0;i<x.length;i++) { if (x[i].nodeType==1) {//Process only element nodes (type 1) document.write(x[i].nodeName); document.write("<br />"); } } Example explained:

1. 2. 3. 4.

Load "books.xml" into xmlDoc using loadXMLDoc() Get the child nodes of the root element For each child node, check the node type of the node. If the node type is "1" it is an element node Output the name of the node if it is an element node

Navigating Node Relationships The following code navigates the node tree using the node relationships: Example xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.getElementsByTagName("book")[0].childNodes; y=xmlDoc.getElementsByTagName("book")[0].firstChild; for (i=0;i<x.length;i++) { if (y.nodeType==1) {//Process only element nodes (type 1) document.write(y.nodeName + "<br />"); } y=y.nextSibling; } 1. Load "books.xml" into xmlDoc using loadXMLDoc() 2. Get the child nodes of the first book element 3. Set the "y" variable to be the first child node of the first book element

4. 5. 6. 7.

For each child node (starting with the first child node "y"): Check the node type. If the node type is "1" it is an element node Output the name of the node if it is an element node Set the "y" variable to be the next sibling node, and run through the loop again.

XML DOM Load Functions The code for loading XML documents can be stored in a function. The loadXMLDoc() Function To make the code from the previous page simpler to maintain (and check for older browsers), it should be written as a function: function loadXMLDoc(dname) { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); } else {

xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET",dname,false); xhttp.send(""); return xhttp.responseXML; } The function above can be stored in the <head> section of an HTML page, and called from a script in the page. An External JavaScript for loadXMLDoc() To make the code above even easier to maintain, and to make sure the same code is used in all pages, we store the function in an external file. The file is called "loadxmldoc.js", and will be loaded in the head section of an HTML page. Then, the loadXMLDoc() function can be called from a script in the page. The following example uses the loadXMLDoc() function to load books.xml: Example <html> <head> <script type="text/javascript" src="loadxmldoc.js"> </script> </head> <body> <script type="text/javascript"> xmlDoc=loadXMLDoc("books.xml"); code goes here..... </script> </body> </html> The loadXMLString() Function To make the code from the previous page simpler to maintain (and check for older browsers), it should be written as a function: function loadXMLString(txt) { if (window.DOMParser) { parser=new DOMParser(); xmlDoc=parser.parseFromString(txt,"text/xml"); }

else // Internet Explorer { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.loadXML(txt); } return xmlDoc; } The function above can be stored in the <head> section of an HTML page, and called from a script in the page. Access across Domains For security reasons, modern browsers do not allow access across domains.This means, that both the web page and the XML file it tries to load, must be located on the same server.The examples on W3Schools all open XML files located on the W3Schools domain.If you want to use the example above on one of your web pages, the XML files you load must be located on your own server. XML DOM Clone Nodes Examples The examples below use the XML file books.xml. A function, loadXMLDoc(), in an external JavaScript is used to load the XML file. This example uses cloneNode() to copy a node and append it to the root node of the XML document.

Copy a Node The cloneNode() method creates a copy of a specified node. The cloneNode() method has a parameter (true or false). This parameter indicates if the cloned node should include all attributes and child nodes of the original node. The following code fragment copies the first <book> node and appends it to the root node of the document: Example xmlDoc=loadXMLDoc("books.xml"); oldNode=xmlDoc.getElementsByTagName('book')[0]; newNode=oldNode.cloneNode(true); xmlDoc.documentElement.appendChild(newNode); //Output all titles y=xmlDoc.getElementsByTagName("title");

for (i=0;i<y.length;i++) { document.write(y[i].childNodes[0].nodeValue); document.write("<br />"); } OUTPUT: Everyday Italian Harry Potter XQuery Kick Start Learning XML Everyday Italian Example explained: 1. 2. 3. 4. 5. . Get the Value of an Element The following code retrieves the text value of the first <title> element: Load "books.xml" into xmlDoc using loadXMLDoc() Get the node to copy Copy the node into "newNode" using the cloneNode method Append the new node to the the root node of the XML document Output all titles for all books in the document

Example x=xmlDoc.getElementsByTagName("title")[0].childNodes[0]; txt=x.nodeValue; Get the Value of an Attribute The following code retrieves the text value of the "lang" attribute of the first <title> element: Example txt=xmlDoc.getElementsByTagName("title")[0].getAttribute("lang"); Change the Value of an Element

The following code changes the text value of the first <title> element: Example x=xmlDoc.getElementsByTagName("title")[0].childNodes[0]; x.nodeValue="Easy Cooking"; Change the Value of an Attribute The setAttribute() method can be used to change the value of an existing attribute, or to create a new attribute. The following code adds a new attribute called "edition" (with the value "first") to each <book> element: Example x=xmlDoc.getElementsByTagName("book"); for(i=0;i<x.length;i++) { x[i].setAttribute("edition","first"); } Create an Element The createElement() method creates a new element node. The createTextNode() method creates a new text node.

The appendChild() method adds a child node to a node (after the last child). To create a new element with text content, it is necessary to create both an element node and a text node.

The following code creates an element (<edition>), and adds it to the first <book> element: newel=xmlDoc.createElement("edition"); newtext=xmlDoc.createTextNode("First"); newel.appendChild(newtext); x=xmlDoc.getElementsByTagName("book"); x[0].appendChild(newel); Example explained:

Create an <edition> element Create a text node with value = "First" Append the text node to the <edition> element Append the <edition> element to the first <book> element

Remove an Element The removeChild() method removes a specified node (or element). The following code fragment will remove the first node in the first <book> element: x=xmlDoc.getElementsByTagName("book")[0]; x.removeChild(x.childNodes[0]); 6. Explain briefly about ACTIVEX CONTROLS? (11 marks) Dynamic Web Concept

HTTP is a protocol that relies on TCP/IP. Understanding how this relationship affects your Web Dynamic content can be generated in a number of ways including through the use of CGI The Common Gateway Interface (CGI) is a standard protocol for interfacing external application This allows the server to pass requests from a client web browser to the external application. The web server can then return the output from the application to the web browser. ActiveX and Java are the beginning of a new era in dynamic content over the Web.

documents is very important.

applications.

software with an information server, commonly a web server.


Dynamic documents in the Internet market space are clearly one of those key technological shifts. More specifically, ActiveX enables software developers to easily include dynamic, animated, Two basic problems plagued the static content model prior to the advent of Sun Microsystems' The computing power of client machine executing the Web browser is woefully underused in the

engaging content in Web pages without significant programming.

Java and Microsoft's ActiveX, which are as follows:

rendering of the content. The Web browser (or the user) had to know about and have available executable software capable In the static content model, the Web browser, the content, and the content viewer are all separate

of rendering downloaded content.

objects.

In the dynamic model, the content knows how to execute itself. The Web browser understands Since the downloaded object knows how to render itself, the browser has no need to worry about Since the browser knows how to deal with executable objects such as Java applets and ActiveX

executable content in a generic sense.

helper applications and the like.

Controls, the computing power available on the client side of the client/server equation is exercised more strenuously. SHAPE \*

MERGEFORMAT

OVERVIEW OF ACTIVEX ActiveX is not a single technological thing. If you've browsed Microsoft's Web site, you've probably gathered that ActiveX is a centerpiece of Microsoft's overall Internet strategy. ActiveX helps application developers and Web content authors build dynamic Internet tools, content, and sites. That's a pretty tall order. To achieve this design goal, Microsoft needed to bring together a number of different components.

Add Internet functionality to your applications with these easy-to-use ActiveX Controls.

High performance server side application for the Web is made possible with this framework.

ActiveX Controls for the Internet As the content you consume from the Internet becomes more and more dynamic, the Web browser will be managing more and more of the computing tasks required to render that content. Sun Microsystems's Java takes early honors in the race for the development standard for executable content. Netscape helped to push Java into prominence by releasing Navigator 2.0 with support for Java applets. Java provides Web developers with a highly sophisticated tool set for interacting with the user and the client machine.

Microsoft, not to be outdone, announced support for Java in MSIE 3.0 and a new alternative called ActiveX Controls. ActiveX Controls are based upon the OLE 2.0 standard. ActiveX Controls are to Web pages what the VBX and OCX are to MS-Windows GUI development. ActiveX Controls have the following advantages over Java applets: They are built from tools you already know. They are easy to integrate with other applications. They are easy to employ in containers that are not Web pages ActiveX Controls are not constructed using Microsoft Foundation Classes. Instead, Microsoft has made the ActiveX Template Library (ATL) available to help developers build ActiveX controls. Although stand-alone applications can be constructed using Java, Java does not really offer the same potential interaction with other existing applications yet. Java applets are intended to execute in a Web browser and not as controls in other applications. The Internet ActiveX Control Pack demonstrates the value of ActiveX in other development environments like Visual C++, Delphi, Visual Basic, and MS-Access. There are a couple of problems with the use of ActiveX Controls: They are not currently supported in Netscape. They are not currently supported on UNIX platforms.

Internet ActiveX Control Pack The Internet ActiveX Control Pack (ICP) is not really an ActiveX control. ICP is, instead, an application of ActiveX. With ICP, it's easy to integrate ActiveX controls into your Visual Basic programs. The ICP contains controls for most of the major Internet services you'll want to integrate into your own applications.

Some of the controls are: The TCP Control The UDP Control The FTP Client Control The HTTP Client Control The HTML Client Control The SMTP Control The POP Client Control The NNTP Control

ActiveX Server Framework The ActiveX Server Framework provides an alternative to the Common Gateway Interface method of executing applications on a Web server and interacting with the Web browser dynamically. There are two major types of applications that can be developed using the ActiveX Server Framework: ISAPI applications ISAPI filters

ISAPI Applications The Internet Server Applications Programming Interface (ISAPI) specification provides an alternative to CGI programs with potentially higher performance type capabilities for the Microsoft Internet Information Server (IIS). ISAPI allows Web developers to build applications that execute in the same process space as the Web server CGI and ISAPI have different approaches to use of process space. Applications using ISAPI are faster simply because the operating system does not have to duplicate the environment and spawn a new process as is required by CGI. ISAPI applications are actually Dynamic Link Libraries (DLLs). Operating in the server's process space carries higher risk while providing somewhat higher performance. Since the ISAPI application is loaded in the same process as the HTTP server, an access violation by the ISAPI application may crash the HTTP server.

ISAPI Filters The Internet Survey Application Programming Interface (ISAPI) also provides a mechanism for modifying the behavior of the server in specific ways. You'll employ ISAPI filters in cases where the default behavior of the server is inappropriate for the application. ISAPI filters can modify the behavior of the following server functions: Authentication Compression Encryption Logging

Traffic Analysis

7. Explain briefly about building a basic OLE and ActiveX controls? (11 marks) OCX controls are the standard solution for Windows component software. They are implemented using OLE 2.0 technology and are designed for use on the desktop environment. Most OCX controls today are built using the Control Development Kit, which is supplied as an integrated part of Microsoft Visual C++ version 4.x. Controls developed with Visual C++ are built using the standard OLE 2.0 interfaces, some of which were mandatory. This means they contain a lot of unnecessary code. They are also dependent on the Microsoft Foundation Classes (MFC) libraries which are several megabytes in size. These controls are therefore relatively big in size which may limit their utility in the slow Internet environment. Also, in order to use these controls on the Internet, the user must first have the MFC libraries on their machine. A onetime download of these libraries for all controls to share may not be too much of a penalty, but MFC is being revised and released approximately every three months. This means users of these controls must download these new libraries every three months or their controls may not work. Management of data and properties is another potential problem. OCX controls on the desktop operate synchronously. Function calls made to the OLE libraries or control containers do not return until they have completed. While this is not a problem on the desktop, where data and properties are stored locally in files and can be retrieved quickly. But it causes problems in a slow environment like the Internet, where large amounts of data have to be retrieved from a remote site and loaded into the control. A 24 bit bitmap file for instance, can be several megabytes in size and take many minutes to download.

ActiveX Control Pad The ActiveX Control Pad provides an integration environment for combining three major elements of the basic World Wide Web dynamic document interface. You'll combine your basic HTML, ActiveX controls, as well as client-side scripts into a single development tool with the ActiveX Control Pad. Managing your ActiveX controls and scripts is visual and easy when you use the ActiveX Control Pad. ActiveX objects can be inserted into your HTML documents using the ActiveX Control Pad. HTML layouts can be inserted into your HTML documents using the ActiveX Control Pad, as well. Select and add controls using the control toolbox and properties.

Adding scripts to your HTML Web pages is simple using the ActiveX Control Pad. Use the List View and the Code View to manage VB scripts in your Web pages.

Using the ActiveX Control Pad Inserting ActiveX controls and adding client-side scripting like VBScript is straightforward. You'll recognize many of the elements of the user interface from other applications you use, like Lotus 1-2-3 or Microsoft Word are present here too. Most of the common items are there including, the File toolbar for saving, creating, and opening new HTML files. However, there are also a couple of elements that you probably haven't seen before. The first of these two new items is found on the toolbar that uses a scroll as its icon. Pressing this button brings up the script wizard. The second item is in the document window.

You'll be inserting objects and scripts into the HTML documents in this window. The scroll icon indicates the start of a script. Pressing the scroll button in the margin bar opens the Script Wizard, and loads the appropriate script. ActiveX objects are indicated in the margin bar by a small cube icon. This iconography indicates the start of an <OBJECT> declaration in the HTML.

Pressing the ActiveX object button in the gray margin bar brings up a window containing the object, and a window containing its property sheet. The Control Pad uses a special icon for insertions of HTML layouts. HTML layouts are indicated in the margin bar by a small icon containing the letter A, a circle, and a square. Pressing this button brings up the HTML Layout editor and its associated tool bar.

8. Write a short note on ACTIVEX documents? (5 marks) An existing application that doesn't need to be embedded in a Web page can be converted to an ActiveX document. ActiveX documents are based upon a more general abstraction called DocObjects. The DocObjects technology is a set of extensions to OLE documents, the compound document technology of OLE. As with OLE documents, the DocObjects standard requires a container to provide the display space for a DocObject. This technology allows the browser to present documents from Office and Office Compatible applications. Such functionality might allow any kind of document to be displayed within the Web browser. Documents that conform to the ActiveX standard can be opened within other ActiveX document containers including the following: Microsoft Internet Explorer 3.0 Microsoft Office Binder Forthcoming new Windows shell

Embedded objects do not, however, control the page on which they appear. These types of objects are usually quite small and hold very little persistent data. ActiveX documents, on the other hand, provide a fully functional document space. ActiveX documents also control the page in which they appear (called a DocObject container). This means that ActiveX documents can be considerably more feature rich than the related embedded object. Microsoft's Internet Explorer 3.0 is an excellent example of an ActiveX document hosting engine.

UNIT IV MULTIMEDIA AND WEB APPLICATION 2 MARKS 1. What is web design? Web design is a multidisciplinary pursuit pertaining to the planning and Production of web sites, including, but not limited to, technical development, information structure ,visual design and networked delivery.

2. What is Search Engine? A search tool that allows a user to enter queries. The program responds with a list of matches from its database. A relevancy score for each match and click able URL are usually returned. Define multimedia? The multimedia revolution occurred first on the desktop computer, with the widespread availability of CD-ROMs. This platform is rapidly evolving towards DVD technology, but our focus in this chapter is on the explosion of sound and video technology that appears on the World Wide Web. What is audio and video format? Audio and video can be used in Web pages in a variety of ways. Audio and video files can be embedded in a Web page or placed on a Web server such that they can be downloaded ondemand. A variety of audio and video file formats are available for different uses. Common video file formats include MPEG (Moving Pictures Experts Group), Quick- Time, RealPlayer, AVI (Video for Windows) and MJPEG (Motion JPEG). Audio formats include MP3 (MPEG Layer 3), MIDI (Musical Instrument Digital Interface), WAV (Windows Waveform) and AIFF (Audio Interchange File FormatMacintosh only). Define electronic commerce? Any web site that offers products and/or services for sale is a commercial web site. There are thousands of commercial web sites on the Internet. Some of them have been successful, and some weren't so lucky. What elements make up a good commercial web site? Of course, web pages should look attractive to a customer. However, even the most attractive web pages will not make a person come back to a web site where it takes too long to find the right product or where order forms don't work. In this lecture we will discuss what functionality is needed for a successful commercial web site and what technology implements various web site elements.

Examples of commercial web sites Let's browse the following two web sites, which are fairly typical web sites for online shopping. Online bakery. A web site for a small business. Trains.com Online sore of model trains and related products. An example of a larger commercial web site.

3. What are the different types of E-BUSINESS model? Business-to-Consumer (B2C) Business Models Business-to-Business (B2B) Business Models

4. What are the Major Business-to-Consumer (B2C) Business Models? Portal E-tailer Content Provider Transaction Broker Market Creator

5. What are the Major Business-to-Business (B2B) Business Models? B2B Hub E-distributor B2B Service Provider Matchmaker Infomediary

6. What are the Components of e-Business Models? Price Competition E-Commerce Business Models Value Position Revenue Model Market Opportunity Competitive Environment

Market Strategy Organizational Development Management Team

7. Define E-Marketing?

E-marketing must be defined to include the management of the consumers online experience of the product, from first encounter through purchase to delivery and beyond. Digital marketers should care about the consumers online experiences for the simple reason that all of them -- good, bad, or indifferent -- influence consumer perceptions of a product or a brand. The web offers companies ownership and control of all interactions with customers and thus creates both the ability and the need to improve their overall experience.
8. What are the different 7 Cs of E-Marketing?

Contract Content Construction Community Concentration Convergence Commerce

9. List the common online electronic payment system? Internet Bank Card Payment System E-Cash (Electronic-cash) Internet Payment System

10. What are the strategies of e-commerce security? Security Strategy Legal Protection Social Moral Norms Perfect Management Strategy 11. What are the Components of a well-functioning commercial website? A well-organized collection of products and/or services A convenient way for a customer to select products Convenient order forms Convenient ways of payment Secure communication system

Some way of storing information about customers A way of keeping information about orders customer support and feedback

15. What is E-Cash (Electronic-cash) Internet Payment System? E-cash is a form of data, the currency in circulation, there is electronic cash currency; it can be converted to cash a series of encrypted numerical sequence number, and then use these sequences to show the value of all sizes. Its characteristic is as follows: an agreement between the banks and businesses and authorization, identity verification by e-cash to complete it, electronic cash can be kept, admission, and transfer to smaller transactions. 16. What are the advantages of E-cash and e-payment systems? Anonymity; Not shadowing; Savings on transaction costs; Savings on transmission costs; Poor risk; Pay flexibility; Prevent forgery and repeatability. 17. What is web crawling? Programs called Spiders; robots etc. collect pages of the Web for indexing. Start processing with a certain number of starting point URLs and follow other links. Visited pages or portions of pages are saved for analysis. 18. What are the designing a search interface? Search form must fit the type of data being searched. HTML and Scripting languages are used. Primary element Search query field. Second aspect Button to execute the search. ( Form buttons or Custom buttons)

11 MARKS 1. Write a short note on multimedia in web design? (5marks) Just a few years back, the typical desktop computers power, although considered substantial at the time, made it impossible to think of integrating high-quality audio and video into applications. Todays computers typically include CD-ROMs, sound cards and other hardware and special software which have make computer multimedia a reality. Economical desktop machines are so powerful that they can store and play DVD-quality sound and video and we expect to see a huge advance in the kinds of programmable multimedia capabilities available through programming languages.

The multimedia revolution occurred first on the desktop computer, with the widespread availability of CD-ROMs. This platform is rapidly evolving towards DVD technology, but our focus in this chapter is on the explosion of sound and video technology that appears on the World Wide Web. In general, we expect the desktop to lead with the technology, because the Web is so dependent on bandwidth, and, for the foreseeable future, Internet bandwidths for the masses are likely to lag considerably behind those available on the desktop. One thing that Deitel has learnedhaving been in this industry for nearly four decades nowis to plan for the impossible. In the computer and communications a field, the impossible has repeatedly become reality so many times that it is almost routine at this point. In this chapter, we discuss how to add sound, video and animated characters to Web based applications. Your first reaction may be a sense of caution because you realize that these are complex technologies and most readers have had little if any education in these areas. This is one of the beauties of todays programming languages. They give the programmer easy access to complex technologies and hide most of the complexity. Multimedia files can be quite large. Some multimedia technologies require that the complete multimedia file be downloaded to the client before the audio or video begins playing. With streaming technologies, audio and video can begin playing while the files are downloading, to reduce delays. Streaming technologies are becoming increasingly popular. Creating audio and video to incorporate into Web pages often requires complex and powerful software such as Adobe After Effects or Macromedia Director. Rather than discuss how to create media clips, this chapter focuses on using existing audio and video clips to enhance Web pages. The chapter also includes an extensive set of Internet and World Wide Web resources. Some of these Web sites display examples of interesting multimedia enhancements; others provide instructional information for developers planning to enhance their own sites with multimedia.

2. Explain briefly about audio and video speech synthesis and recognition? (11 marks) Audio and Video Audio and video can be used in Web pages in a variety of ways. Audio and video files can be embedded in a Web page or placed on a Web server such that they can be downloaded on-demand. A variety of audio and video file formats are available for different uses.

Common video file formats include MPEG (Moving Pictures Experts Group), Quick- Time, RealPlayer, AVI (Video for Windows) and MJPEG (Motion JPEG). Audio formats include MP3 (MPEG Layer 3), MIDI (Musical Instrument Digital Interface), WAV (Windows Waveform) and AIFF (Audio Interchange File FormatMacintosh only). Encoding and compression determine a files format. An encoding algorithm or CODEC compresses media files by taking the raw audio or video and transforming it into a format that Web pages can read. Different encoding levels and formats produce file sizes that are ideal for different applications. Some CODECs are available to the public in the form of encoding applications. Most encoding applications compress audio and video files. Some serve as format converters, converting one file format into another. Adding Background Sounds with the bgsound Element

Some Web sites provide background audio to create a particular atmosphere on the site. Various ways exist to add sound to a Web page, the simplest is the bgsound element. The src property specifies the URL of the audio clip to play. Internet Explorer supports a wide variety of audio formats. The loop property specifies the number of times the audio clip will play. The value -1 (the default) specifies that the audio clip should loop until users browse a different Web page or click the browsers Stop button. A positive integer indicates the exact number of times the audio clip should loop. Negative values (except -1) and zero values for this property cause the audio clip to play once. The balance property specifies the balance between the left and right speakers. The value for this property is between -10000 (sound only from the left speaker) and 10000 (sound only from the right speaker). The default value, 0, indicates that the sound should be balanced between the two speakers. The XHTML document of Fig demonstrates the bgsound element and scripting the elements properties. This examples audio clip came from the Microsoft Developer Networks downloads site, msdn.microsoft.com/downloads/default.asp Adding Video with the img Elements dynsrc Property Users can tremendously enhance the multimedia presentations by incorporating a variety of video formats into their Web pages. The img element incorporates both images and videos in a Web page. The src property, shown previously, indicates that the source is an image. The dynsrc (i.e., dynamic source) property indicates that the source is a video clip. The dynsrc property may have other properties such as loop, which is similar to the bgsound loop property. The XHTML document of demonstrates the img element and its dynsrc property. <?xml version = "1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- Fig. 33.2: Dynamicimg.html --> <!-- Demonstrating the img elements dynsrc property --> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>An Embedded Video Using the dynsrc Property</title> <bgsound src = "http://msdn.microsoft.com/downloads/sounds/carib.MID" loop = "-1"></bgsound>

</head> <body> <h1>An Embedded Video Using the img element's dynsrc Property</h1> <h2>Car and Carribean Music</h2> <table> <tr><td><img dynsrc = "car_hi.wmv"start = "mouseover" width = "180"height = "135" loop = "-"alt = "Car driving in circles" /></td> <td>This page will play the audio clip and video in a loop.<br /> The video will not begin playing until you move the mouse over the video.<br /> Press

<strong>Stop</strong> to stop playing the sound and the video.</td> </tr> </table> </body> </html>

The img element in lines 2124 uses the dynsrc property to load and display the video car_hi.wmv. Property start specifies when the video should start playing. There are two possible start eventsfileopen indicates that the video should play as soon as it loads into the browser, and mouseover indicates that the video should play when users first position the mouse over the video.

Adding Audio or Video with the embed Element Previously, we used elements bgsound and img to embed audio and video in a Web page. In both cases, users of the page have little control over the media clip. In this section, we introduce the embed element, which embeds a media clip (audio or video) into a Web page. The embed element displays a graphical user interface that gives users direct control over the media clip. When the browser encounters a media clip in an embed element, the browser plays the clip with the player registered to handle that media type on the client computer. For example, if the media clip is a wave file (i.e., a Windows Wave file), Internet Explorer typically uses the Windows Media Player ActiveX control to play the clip.

The Windows Media Player has a GUI that enables users to play, pause and stop the media clip. Users can also control the volume of audio and move forward and backward through the clip using the GUI. The embed element is supported by both Microsoft Internet Explorer and Netscape Communicator, however it is not part of the XHTML 1.0 recommendation. Documents written in XHTML using the embed element should render properly in either browser, however, errors may occur when trying to validate the document using the World Wide Web Consortiums XHTML 1.0 validator. The XHTML document of fig modifies the wave filter example by using an embed element to add audio to the Web page. Line 58 uses the embed element to specify that the audio file humming.wav should be embedded in the Web page. The loop property indicates that the media clip should loop indefinitely. The width and height properties define the size of the controls for the sound clip. By default, the GUI for the media player is displayed. To prevent the GUI from appearing in the Web page, add the hidden property to the <embed> element. To script the element, specify a scripting name by adding the id property to the <embed> element. The embed element can specify video clips as well as audio clips. Demonstrates an embedded video. The embed element that loads and plays the video is located in line 18. <?xml version = "1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- Fig. 33.3: EmbeddedAudio.html --> <!-- Background Audio via the embed Element --> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Background Audio via the embed Element</title> <style type = "text/css"> span { width: 600 } .big { color: blue; font-family: sans-serif;15 font-size: 50pt;16 font-weight: bold } </style> <script type = "text/javascript"> <!-var TimerID; var updown = true; var str = 1; function start() { TimerID = window.setInterval( "wave()", 100 ); } function wave() { if ( str > 20 || str < 1 ) updown = !updown; if ( updown ) str++; else str--; wft.filters( "wave" ).phase = str * 30; wft.filters( "wave" ).strength = str;

} // --> </script> </head> <body onload = "start()"> <h1>Background Audio via the embed Element</h1> <p>Click the text to stop the script.</p> <p class = "big" align = "center"> <span onclick = "window.clearInterval( TimerID )" id = "wft" style = "filter:wave( add = 0, freq = 3, light = 0, phase = 0, strength = 5)"> WAVE FILTER EFFECT</p></span> <p>These controls can be used to control the audio.</p> <embed src = "humming.wav" loop = "true"></embed> </body> </html> Embedding audio with the embed element

3. Explain briefly about electronic commerce? (11 marks) Any web site that offers products and/or services for sale is a commercial web site. There are thousands of commercial web sites on the Internet. Some of them have been successful, and some weren't so lucky. What elements make up a good commercial web site? Of course, web pages should look attractive to a customer. However, even the most attractive web pages will not make a person come back to a web site where it takes too long to find the right product or where order forms don't work. In this lecture we will discuss what functionality is needed for a successful commercial web site and what technology implements various web site elements. Examples of commercial web sites Let's browse the following two web sites, which are fairly typical web sites for online shopping.

Online bakery. A web site for a small business. Trains.com Online sore of model trains and related products. An example of a larger commercial web site.

Components of a well-functioning commercial web site A well-organized web site should be easy for a customer to use and easy for the owner to maintain. It takes a lot to build a well-organized web site. Below is a list of the most important elements that a good web site should have: 1. A well-organized collection of products and/or services. Smaller web sites can just list all their products on one or several web pages. Larger sites provide indices of products and search engines so that customers can find what they need. There should be a way for customers to get all necessary information about products, compare several products, get an advice on related products that they might want to get, etc. To maintain a web site, the owner should be able to change product information easily. A web site where a price change of a single product requires changing 3 web pages is just bound to have inconsistencies.

he owner should be able to add or remove products based on every day's availability, change prices, add product cross-references, etc. without making the web site inconsistent even for a minute. 2. A convenient way for a customer to select products. Usually implemented as a shopping cart or a shopping basket. The customer should be able to select and delete products while browsing the web site. 3. Convenient order forms. The form should be flexible enough to allow to specify a different address for the product delivery, a gift message, etc. It should have as few required fields as possible. A returning customer should be provided default information so that not to type it every time. For both the customer and the owner it is essential that the form catches simple typos (s.a. 4 digits in a zip code). 4. Convenient ways of payment. There should be options of paying by a credit card, by a check (not everyone has credit cards!), and by a credit card over the phone if the customer is not comfortable sending his/her credit card number. The options may include some electronic payment systems. For the owner, there should be a quick way to verify the credit card information or in some other way to check that the payment is valid. 5. Secure communication system not only to protect transmission of a credit card number, but also to guarantee privacy of the customer (including details of the purchase). A web site might have a user registration system with a password, in which case all transactions by the user should be private. It is also important to prevent unauthorized access to the web site (by a hacker or accidental). 6. Some way of storing information about customers. This is convenient for customers so that they don't need to reenter their information every time they access the site. It also allows to "customize" the web site for someone's interests. This can be done via customer registration or by means of "cookies", which we will discuss later. The owner can benefit a lot from storing information about a customer: he/she can customize ads based on the customer's profile or send an e-mail advertising a new product (but keep in mind that many people don't like this!) However, the greatest benefit is the owner's ability to monitor customer's behavior: which pages have the customer visited and which purchases (if any) he/she have made afterwards. 7. A way of keeping information about orders. This allows customers to track their orders, and for owners to get all kinds of financial and statistical information. It is also important to keep order information in case of later disputes. 8. The last, but not the least, customer support and feedback. There should be online documentation for all products ever sold on the web site, various FAQs, and, ideally, a way of customers to post their opinion about the product. Easy access to this information may make a difference between a frequently visited web site and a lonely online looser. This aspect of a web site cannot be completely mechanized: a human being has to answer e-mail, judge the relevance of customer's comments (otherwise the web site may be flooded with nonsense), and organize comments by topics, and so on. However, there is a lot that can be computer-aided in this process, for instance sorting incoming messages by their title and/or return address to forward them to an appropriate customer support person. Note that we are only considering business-to-customer interactions here (so-called B2C), leaving out all the features related to business-to-business (B2B) interactions. While such interactions are basically similar to B2C, they can be optimized if a company has stable business partners which have more powerful computers than an average customer does. Even a customer oriented web site has a B2B part when dealing with vendors of products. We are not considering B2B connections in designing a web site.

Some technologies used to implement all this 1. Convenient storage and retrieval of information about products and customers require a database. Some terminology: A database is a collection of data organized in such a way that it can be easily accessed, managed, and updated. A query is a request to a database written in a form that's supported by the database. Every brand of databases has its own language of queries (a query language). A well-organized database allows you to store each piece of information only once, so if you need to change it, you change it in one place. Databases allow you to store information about orders, needed both for you and for customers. For instance, customers can track their orders by requesting information from the database, which will automatically reply whether the order has been shipped. You can use customer information to fill in forms for returning customers with their recorded information. You can store statistics about customers (how many times they have visited the web sites, which pages, what did they buy, and so on). Customer's feedback about products can be organized and displayed later when someone else is interested in the same product. It's hard to imagine an interesting web site that does not have a database behind it. There are various kinds of databases, from a simple one, which is a collection of "flat" files storing data, to very sophisticated commercial products, s.a. ORACLE. The most common kind is a relational database. A relational database is a database organized as a collection of tables. 2. A convenient interface to the database from the web site. A customer does not need to know anything even about the existence of the database, not to mention details of its organization. He/she should be able to get all necessary information by typing in keywords and filling in electronic forms. 3. Various programming languages (for instance, Java, JavaScript) provide libraries to implement a remote connection to a database server. A server is a computer that provides a remote access to some service, for instance a web page server "serves" web pages, i.e. sends HTML files, graphics files, etc. in response to http requests, a database server provides responses to database queries, and so on. One machine can provide several different services at the same time. A client is a computer that makes a request for a service. We will use a Java JDBC (Java Database Connectivity) package to facilitate a connection to a relational database. It does not depend on a particular kind of the database, as long as the database supports SQL (Structured Query Language).

SQL is a standard for a query language of a relational database. An interface has to provide way for customers to fill in forms, press buttons, etc. We will use javax.swing package to build an interactive graphical interface. 4. We need to be able to process user's forms, for instance order forms, and produce various web pages, depending on the request. Ways of processing electronic forms include various server-side scripts, s.a. CGI, PERL, asp (Active Server Pages, an extension of JavaScript) and others. We will use Java Servlets for this purpose.

5. A web site responds to requests for web pages. It doesn't "know" where the requests have come from, so it can't tell if two requests for web pages have been made by the same user. To keep track of a user during a session (and sometimes between sessions), a web server uses cookies. A cookie is a small text file placed by a web server on the client machine. The file gets sent back every time the client requests a web page from the server. A cookie has an expiration time, which may be just for the session or longer. Java Servlet package also implements cookies. 6. Encryption and security. A common way secure communications are implemented is via SSL (Secure Sockets Layer), which allows various forms of encryption, depending on the maximum level of encryption provided by the server and the client and on geographic location of the machines (a different level of encryption is allowed in the US for connections to domestic and foreign computers). We will study and compare several encryption algorithms. On the practical side, we will use Java packages which implement encryption and secure communications.

7. Electronic payment systems are based on customer's accounts with one of trusted vendors. A customer obtains certificates "signed" by the vendor which are analogous to checks ("personal money") and cash ("anonymous money"). The implementation should be such that mere copying of any piece of information transmitted in the transaction does not allow the thief to use the "money". We will study protocols for verifying validity of "checks" and "cash" in electronic transactions. We will also study ways of implementing "coins" on the Internet, i.e. certificates for small amounts of money.

4. Explain briefly about E-BUSINESS model? (11 marks) Learning Objectives Identify the key components of e-commerce business models. Describe the major B2C business models. Describe the major B2B business models. Recognize business models in other emerging areas of e-commerce. Understand key business concepts and strategies applicable to e-commerce.

Components of e-Business Models

Price Competition Price for books and CDs sold on the Internet less than conventional channel Average 9-16% Price increments Price change on the Internet is smaller than conventional channel Price dispersion Substantial differences in price across retailers on the Internet Heterogeneity in consumer awareness Heterogeneity in retailer branding and trust E-Commerce Business Models Business model a set of planned activities designed to result in a profit in a marketplace E-commerce business model a business model that aims to use and leverage the unique qualities of the Internet and the World Wide Web. Value Position Defines how a companys product or service fulfills the needs of customers. Questions Why will customers choose to do business with your firm instead of another company? What will your firm provide that other firms do not and cannot?

Revenue Model Describes how the firm will earn revenue, produce profits, and produce a superior return on invested capital. E-commerce revenue models include: advertising model subscription model transaction fee model

sales model affiliate model Advertising revenue model a company provides a forum for advertisements and receives fees from advertisers (Yahoo) Subscription revenue model a company offers it users content or services and charges a subscription fee for access to some or all of it offerings (Consumer Reports or Wall Street Journal) Transaction fee revenue model a company receives a fee for enabling or executing a transaction (eBay or E-Trade) Sales revenue model a company derives revenue by selling goods, information, or services (Amazon or DoubleClick) Affiliate revenue model a company steers business to an affiliate and receives a referral fee or percentage of the revenue from any resulting sales (MyPoints)

Market Opportunity Market opportunity refers to the companys intended market space and the overall potential financial opportunities available to the firm in that market space defined by the revenue potential in each of the market niches where you hope to compete Market space the area of actual or potential commercial value in which a company intends to operate

Competitive Environment Refers to the other companies operating in the same marketplace selling similar products Influenced by: how many competitors are active how large are their operations the market share of each competitor how profitable these firms are how they price their products

Market Strategy The plan you put together that details exactly how you intend to enter a new market and attract new customers Best business concepts will fail if not properly marketed to potential customers

Organizational Development Describes how the company will organize the work that needs to be accomplished Work is typically divided into functional departments Move from generalists to specialists as the company grows

Management Team Employees of the company responsible for making the business model work

Strong management team gives instant credibility to outside investors A strong management team may not be able to salvage a weak business model

Should be able to change the model and redefine the business as it becomes necessary

Major Business-to-Consumer (B2C) Business Models

Portal offers powerful search tools plus an integrated package of content and services typically utilizes a combines subscription/advertising revenues/transaction fee model may be general or specialize (vortal) E-tailer online version of traditional retailer includes virtual merchants (online retail store only) clicks and mortar e-tailers (online distribution channel for a company that also has physical stores) catalog merchants (online version of direct mail catalog) online malls (online version of mall) Manufacturers selling directly over the Web Content Provider information and entertainment companies that provide digital content over the Web typically utilizes an advertising, subscription, or affiliate referral fee revenue model Transaction Broker processes online sales transactions typically utilizes a transactions feel revenue model Market Creator uses Internet technology to create markets that bring buyers and sellers together typically utilizes a transaction fee revenue model E.g. Auction English auction Dutch auction Sealed-bid auction Double auction

Major Business-to-Business (B2B) Business Models

B2B Hub also known as marketplace/exchange electronic marketplace where suppliers and commercial purchasers can conduct transactions may be a general (horizontal marketplace) or specialized (vertical marketplace) E-distributor supplies products directly to individual businesses B2B Service Provider sells business services to other firms Matchmaker links businesses together charges transaction or usage fees Infomediary gather information and sells it to businesses

5. Discuss briefly about E-MARKETING? (11 marks) These 7 Cs e-marketing are fundamental to understanding the intricacies of Internet marketing and to transforming a venture from being a mere web presence to a highly successful e-venture. They are also instrumental in shaping the overall business strategy and the economic model that an organization needs to adopt. The value propositions of products and services offered in the physical world are essentially limited point solutions that meet only part of a consumers need or want. In the online world, even a simple banner advertisement can be both an advertisement and a direct marketing service. The banner raises the passive consumers awareness of a product. Yet it also encourages the consumer to pursue action by clicking on it.

E-marketing must be defined to include the management of the consumers online experience of the product, from first encounter through purchase to delivery and beyond. Digital marketers should care about the consumers online experiences for the simple reason that all of them -- good, bad, or indifferent -- influence consumer perceptions of a product or a brand. The web offers companies ownership and control of all interactions with customers and thus creates both the ability and the need to improve their overall experience. There are two reasons for building the concept of e-marketing around consumer experiences. First, this approach forces marketers to adopt the consumers point of view. Second, it forces managers to pay attention to all aspects of their digital brands interactions with the consumer, from the design of the product or service to the marketing message, the sales and fulfillment processes, and the after-sales customer service effort. The 7 Cs of E-Marketing The Internet allows for the entire sales cycle to be conducted on one medium, nearly instantaneously. From making the consumer aware of the product to providing additional information to transacting the final purchase, the Internet can accomplish it all. The Internet is like one big point-of-sales display, with easy access to products and the ability for impulse shopping. Impulse shoppers have found a true friend in the Internet. Within seconds from being made aware of a product, consumers can purchase it online. Further, with the targeting techniques available to advertisers, consumers who turn down a product because of the price can be identified and served a special offer more likely to result in a purchase. In the right hands, with the right tools, the Internet really is an advertisers dream come true.

As opposed to the 4 Ps of brick-and-mortar marketing, the changing outlook in the area of e-marketing can be explained on the basis of 7 Cs of e-marketing.

Contract: The e-marketers first goal is to communicate a core promise for a truly distinctive value proposition appealing to the target customers. Content: refers to whatever appears on the website itself and on hot linked websites. If chosen appropriately, it can increase both the rates at which browsers are converted into buyers and their transactions. Construction: The promises made by e-marketers are not unique to the Internet, but the mediums interactive capabilities make it easier for them to deliver on their promises quickly, reliably, and rewardingly. In practice, this means that promises must be translated into specific interactive functions and Web design features collectively giving consumers a seamless experience. Such design features as one-click ordering and automated shopping help deliver the promise of convenience. Community: Through site-to-user and user-to-user forms of interactivity (such as chat rooms), emarketers can develop a core of dedicated customers who become avid marketers of the site too. Concentration: Targeting through online behavioral profiling. Advertisers have known for some time that behavioral targeting (a.k.a., profiling) is vastly superior to simple demographic targeting. Knowledge of a consumers past purchases interests, likes/dislikes, and behavior in general allows an advertiser to target an advertisement much more effectively. Department stores have long kept track of consumers past purchases. They are thus able to project what other types of products a consumer might be interested in and then send an appropriate coupon or sale offer.

Credit card companies are the ultimate gatherers of behavioral targeting information. They maintain vast databases of cardholders past transactions, and they sell lists of this data to advertisers. The same type of behavioral model is forming on the Internet. Publishers and advertisement networks monitor the items that a consumer has expressed interest in or purchased on a site (or network of sites) in the past and target advertisements based on this information. Convergence: We will soon enter the next round of the E-marketing battle as broadband reaches the masses. The Internet will become more ubiquitous and wireless; televisions will become more interactive; video/data/voice appliances will converge; brand advertising and direct marketing practices will integrate; domestic brands, commerce and marketing will become even more global; and big marketing spenders will spend more money online. Many companies that are well positioned today will need to continue to evolve to take advantage of the opportunities. The success of Internet advertising companies will largely be driven by how they maneuver among the coming developments. Rich media, brought on by broadband, will allow advertisers much greater creativity by bringing in new types of advertising to the Internet, as well as enhancing some of the more traditional forms. Broadband technology will allow the convergence of television and the Internet. Dubbed interactive TV, in its simplest form, will consist of a television with some interactive capabilities. Basically, a user will see a television screen that is three-quarters traditional television, but with a frame that has Internet capabilities. This frame will allow users to access up-to-the-minute sports scores or news on the Web, for example. More importantly for E- marketers, it would allow viewers to immediately leap to the website of an advertiser whose ad was being shown. The user could find out more information or order the product right there.

Commerce: The last emerging fundamental of e-marketing is commerce, whether it includes offering goods and services directly, or marketing those of another company for a fee, thus helping to cover the fixed costs of site operations and to offset customer acquisition costs. To be successful on the Internet, e-marketers will have to do more than reproduce their off-line business models on line because these business models work only at considerable scale. Interestingly, It is possible for online marketers to be profitable even at lower sales volume if they exploit efficiencies in e-marketing and synergies with the off-line business, with examples as follows. Exploiting more than one channel to close the transaction: Although early winners on the web might belong to an exclusive club of Internet start-up companies, established players in the off-line industry can catch them and even overtake them by offering a choice of channels. Leveraging low customer acquisition costs: Traditional brick-and mortar companies can bring their existing customers online at a much lesser cost than Internet start-up companies who must lay out a hefty amount per head to acquire customers. Exploiting alternative revenue streams: An online presence offers an E-marketer a wider variety of sales opportunities. For web-based retailers, acting as an agent on behalf of the customer can become a revenue source in the future. Purchasing scale at low volumes: E-marketers can cut down on their purchasing cost and shorten their procurement cycle by replacing EDI tools with Internet based ones that facilitate product comparison, streamline logistics, and help B2B vendors aggregate their retailers back office purchases.

Reducing customer churn: Given the high cost of replacing established customers, losing them is expensive. A web presence supplies the personalized attention that could keep customers loyal. Maximizing the pricing potential: It has been reported by consumer researchers that buyers shop online more for convenience than for cost. In view of this relative indifference to price, e-marketers can capture some margin premium, at least in the early days of their sites. Challenges in e-marketing: Every online fulfillment operation, large or small, faces four main challenges: controlling customer data, integrating on- and off-line orders, delivering the goods cost effectively, and handling returns. Controlling customer data: As outsourcing arrangements proliferate and delivery services become more expert in using information technology, e-marketers risk losing their lock on consumer data. In an economy where knowledge is revenue as well as power, e-marketers must consider how to strike a balance between the efficiencies offered by the out-sourcing of fulfillment and the confidentiality that keeping data in-house preserves. Integrating on and off-line orders: When the volume of orders is high, companies must decide how much integration they need. In a totally integrated system, Internet orders would be automatically transmitted through a processing center and transferred to the suppliers manifest. An integrated system with full ERP (enterprise resourceplanning) capabilities, for example, can ensure that surges in demand dont retard key fulfillment operations such as data entry, inventory, and packing.

Although the problems of rapid growth are complex in themselves, the lack of a fully integrated order management system compounds them. In the future evolution of the Web, however, integration will become essential for building effective customer service and package-tracking systems. Delivering the goods cost-effectively: At present, every single transaction challenges e-marketers to deliver the goods quickly, cheaply, and conveniently. But this is largely a technical and logistical problem, and it will be possible (though perhaps expensive) to solve it by developing new sorting and scanning equipment and by deploying larger delivery vehicles. Making contact with the recipient is a trickier problem but one that must be resolved if the full potential of eimpulse orders is to be realized, for an impulse purchase loses its power to gratify if the product or service takes too long to appear. But since each missed delivery adds as much as a full day to the fulfillment process, spanning that final mile to the home can take longer than traveling the rest of the fulfillment loop. Handling returns: E- marketers, with their emphasis on convenience and customization, must match the high standard of service exhibited by some physical marketers regarding returns. At present, they do not. To begin with, few ecommerce retailers (or mail order companies, for that matter) design their packaging for easy returns. Customers often have to find new packing materials; call to arrange credits and refunds, and physically take packages to delivery services. Each step represents an inconvenience that, however minor, can combine with others to create negative feelings about the vendor. Even if a convenient solution for returns were developed, e-marketers might discover that impulse sales carry hidden costs. The implication is that fulfillment costs must be driven down to preserve profitability.

Choice of Marketing Strategy An online companys choice of marketing strategy will depend on four main variables: the nature of the customers interaction with the product and seller; the current capabilities of the business; the capabilities that are (or will become) commodity operations, in which competitive advantage cannot be sustained; and the trade-off between time and control. This is essentially a value chain concept (as propounded by Porter) whereby e-marketers look at each component of the value chain and the support activities to determine where and in what form can they add value to the customer. This translates into their competitive advantage. And in this entire process, it is the 7 Cs of e-marketing that act as fundamental guiding principles. Rethinking the business model As e-marketers align the contract and the construction, they must also align the economic model that will sustain their businesses. For most of them, the very process of taking the brand online will force a fundamental reconsideration of the business. . Channel supporter: E-marketers can use the Internet more to support their existing channels than to generate additional sales. Beyond cross-channel promotions, many brick-and-mortar companies can use the web to increase their customers understanding of their products and services. Others can harness the webs interactivity to improve their product development and product mixes by inviting customer responses on their web sites. Advisory and information service providers:

An expert (such as an investment adviser or a personal shopper) can offer consumers unbiased advice for a fee. A business can also collect, process, and sell information through the Internet. Retail model: Vendors or products can be aggregated to facilitate transactions for buyers. Many companies can also achieve success as online auctioneers. Sellers of goods and services can provide the content; community may come from matching sellers with buyers and setting bidder against bidder; and commissions on sales and advertising revenue can generate the commerce. Vertical model: The business model that may take the greatest advantage of the Internet is the vertical model, which specializes, in a particular category or a product. It might provide specialized information and advice as well as access to a community with common interests. 6. Explain briefly about the online payments and security? (11 marks) The information technology, the Internet high speed development, electronic commerce has caused the current distribution realm significant transformation gradually. In the electronic commerce practice, the online electronic payment is the electronic commerce essential link, also is the foundation condition which electronic commerce can smoothly develop. Not the corresponding real-time electron payment means coordinate, electronic commerce only can be does not have the practical significance "the hypothesized commerce", but is unable to realize on the genuine net the transaction. The on-line electronic payment is the electronic commerce development core, is completes on the net the transaction essential step, also is at present restricts the domestic network application development a bottleneck.

ONLINE ELECTRONIC PAYMENT Online electronic payments are not tantamount to electronic payments. In the emergence of e-commerce, credit cards have long been represented by electronic means of payment, credit cards in shopping malls. Many hotels and other places and items could swipe of the card, POS terminals Regulations, ATM cash forms of payment. And online electronic payments, online payments also known as electronic currency, broadly speaking, refer to a transaction in the online exchange of funds; It is a network-based electronic financial, a business card transactions for all types of electronic tools and media, the electronic computer and communications technologies as a means Electronic data (binary data) stored in the bank's computer system and through the computer network system in the form of the flow of electronic information transfer and payment. Electronic Payment System is the basis for online payments, and online payments system development is a higher form of electronic payment. It makes electronic payment may, at any time, through the Internet directly to the transfer, settlement and form e-business environment. COMMON ONLINE ELECTRONIC PAYMENT SYSTEM In online shopping online electronic payment function is the key issue to ensure the consumers are fast and convenient, we have to ensure the safety and secrecy of the parties to a transaction, which requires a complete electronic trading systems. Currently, several online electronic payment systems used for: Internet Bank Card Payment System

Including online credit card, smart card (IC card) payment systems are established in accordance with the standards set shopping and payment system. Internet users in specific ways: sending banks coast and password encryption sent to the bank for payment. And the payment process for customers, merchants and verify the legitimacy of a request for payment. At present, domestic banks had set up such a bank cards for online payments. Based on the bank card payment the following four models: 1. No security model Its features: users complete control of the bank card business information, the transmission of messages without bank card security.

2. through third-party brokers paid model Its characteristic is as follows: Bank card information is not open to the transmission network, is paid by users. Both businessmen trusted third party (agents) to complete.

3. Simple encrypted payment system model Its characteristic is as follows: the use of encryption technology to bank cards and other critical information encrypted digital signature to confirm the authenticity of the message. Business servers and the need for software support services.

4. SET (security electronic transaction) model "Secure Electronic Transactions," and referred to the SET. In an open Internet is a realization of the international agreements and standards for secure electronic transactions. Their characteristics are as follows: SET transactions participants to provide certification to ensure data security, integrity and nonrepudiation of transactions, in particular to ensure that no information leaked to the cardholder's account for the businesses. Guarantee the safety of the SET.

E-Cash (Electronic-cash) Internet Payment System E-cash is a form of data, the currency in circulation, there is electronic cash currency; it can be converted to cash a series of encrypted numerical sequence number, and then use these sequences to show the value of all sizes. Its characteristic is as follows: an agreement between the banks and businesses and authorization, identity verification by e-cash to complete it, electronic cash can be kept, admission, and transfer to smaller transactions.

E-cash and e-payment systems also have the advantage of cash, mainly as follows: Anonymity; Not shadowing; Savings on transaction costs; Savings on transmission costs; Poor risk; Pay flexibility; Prevent forgery and repeatability.

E-purse Internet Payment System Users use e-purse shopping, the first in a personal bank account and users into a certain amount; then the corresponding electronic wallet service system free software to download and install an electronic purse; then download the corresponding website to apply online and access the cardholder "electronic safety certificate". Users shopping, the only direct hits "electronic wallet" icon and following the importation of their coast. Corresponding information such as passwords by e-purse will pay to complete the follow-up work. Modex foreign companies such as a smart card as an e-purse to the online payment system. E-purse is sporadic small payment transactions. always used in conjunction with bank cards to help users complete the entire shopping process. Electronic check (E_check) Internet Payment System Electronic check transfer payments from paper checks to the merits of using digital transmission o transfer money from one account to another account. These electronic check payments in businesses and banks linked to the online password transmission. Most common use encryption keys handwritten signature or personal identification numbers instead of signatures. Thus ensuring the safety of this form of payment.

STRATEGY OF E-COMMERCE SECURITY As e-commerce security problems caused by many factors, to solve the security problem from different aspects, offers a variety of countermeasures. 1. Security Strategy To ensure the safety communications must be the necessary measures to guard against them. Communications links, we can use a firewall, proxy server, Virtual Private Network (VPN) technology; in the identification and authentication, encryption and authentication techniques.

2. Legal Protection As e-commerce activities are a commodity transaction and security issues should be protected by law must ensure that the legal status of electronic contracts and digital signatures, electronic contracting parties to the contract approved Electronic Contract denied or modified to ensure that electronic contracts can be implemented. 3. Social Moral Norms As e-commerce transactions are not direct, face-to face features Transactions are often seen in the traditional process of e-commerce fraud is bound to have security implications. Thus, the healthy development of ecommerce depends on the establishment and perfection of social ethics. 4. Perfect Management Strategy As e-commerce transaction system is a highly integrated man-machine system, in addition to network security, and management is also very important, but the factors that play a decisive role. Thus, the whole system of power distribution management and supervision, management training and assessment, ethical and professional standards must draw up complete training regulations, management jobs in order to enhance the spirit of love. 7. Write a short on working of search engines? (11 marks) Three basic tasks are performed Searching the internet, selecting documents based on important words Keep an index of the words they find, and where they find them. Allow users to look for the words or combinations of words found in that index. Gathering pages (web crawling) Programs called Spiders; robots etc. collect pages of the Web for indexing. Start processing with a certain number of starting point URLs and follow other links. Visited pages or portions of pages are saved for analysis. Indexing pages Indexing determining what a page is about. Looks for the components of a page like <title> <meta> tags Link texts Texts in headings and body Comment text Tries to distill the meaning of the page. Position or frequency of the text will be considered. Stop words, the more common and little useful ones, are ignored. Pages with similar key words are ranked and are stored in the database. Page Rank A numeric value that represents how important a page is, on the web. When one page links to another, it is effectively casting a vote for the other page. The more votes cast on a page, the more important the page is. Importance of the page that casts the vote also determines the importance of the vote. A pages importance is calculated from the votes cast for it. Page A has voted for Page B but not to Page C. Hence Page Rank for each

page is Page A = 0.15 Page B = 1 Page C = 0.15 Consider the linking of all pages to all pages. This produces page rank as Page A = 1 Page B = 1 Page C = 1 resulting in maximum Page Rank. Providing a Search Mechanism Deals with search interface and result page Search page an interface, the user makes their query form. Contains primary query text box, varies to advanced searches. Basic and advanced searches differ in interfaces. DESIGNING A SEARCH INTERFACE Search form must fit the type of data being searched. HTML and Scripting languages are used. Primary element Search query field. Second aspect Button to execute the search. ( Form buttons or Custom buttons) Result Page Design Must contain as much information as possible relevant to users query. Elements of a result page Original query Scope of the search and the results found Page or document titles Page summaries URL of returned page Size and Type of result

- Relevancy of results Keyword matches Navigation

Negative results page Tries to help the user identify what went wrong and says why a query went wrong. Possibilities nothing may match the search terms; search facility may be used incorrectly. Functions: Clear failure message Search again mechanism Help information Example

Overview of search engines OPTIMIZATION Done for a page to rank it highly, for better search results. Depends on <meta> tags Titles and file naming Relevant text contents Links and entry points (doorway pages) etc. SEARCH ENGINE PROMOTION Adding to the Engines Informing a Search Engine that a site exists. Done by adding an URL for indexing. Bulk submissions may also be done

UNIT-V

WEB SERVICES 2 MARKS 1. What is SOAP? (Simple Object Access Protocol) SOAP is an XML based protocol that allows applications to easily over the internet using XML documents called AOAP message. A SOAP message contains an envelope, which is a structure that describes a method call. A SOAP messages body contains either a request or a response. A request messages body contains a Remote Procedure Call (RPC), which is a request for another machine to perform task. The RPC specifies the method to be invoked and any parameters the method takes. The application sends the SOAP message via an HTTP POST. A SOAP response message is an HTTP response document that contains the results from the methods call (e.g. return values, error messages.) 2. What is the use of web services? Web services encompass a set of related standards that can enable two computer The data is passed back and forth using standard protocols such as HTTP, the same protocol used to transfer ordinary web pages. Web services operate using open, text-based standards that enable components written in different languages and on different platforms to communicate. They are ready to use pieces of software on the Internet. XML, SOAP, Web Services Description Language (WSDL) and Universal Description, Discovery and Integration (UDDI) are the standards on which web services rely. UDDI is another XML based format that enables developers and business to publish and locate Web services on a network. 3. What are the advantages of web services? Reusable application-components. There are things applications need very often. So why make these over and over again? Web services can offer application-components like: currency conversion, weather reports, or even language translation as services. Connect existing software. Web services can help to solve the interoperability problem by giving different applications a way to link their data. With Web services you can exchange data between different applications and different platforms. 4. What is SOAP? Service Oriented Architecture Protocol. It provides a standard, extensible, composable framework for packaging and exchanging XML messages. In the context of this architecture, SOAP also provides a convenient mechanism for referencing capabilities (typically by use of headers). 5. What is WSDL? Web Services Description Language WSDL is a language for describing Web services. WSDL describes Web services starting with the messages that are exchanged between the requester and provider agents. The messages themselves are described abstractly and then bound to a concrete network protocol and message format. What are Web Services? Web services are application components

Web services communicate using open protocols Web services are self-contained and self-describing Web services can be discovered using UDDI Web services can be used by other applications XML is the basis for Web services

How does web services Work? The basic Web services platform is XML + HTTP. XML provides a language which can be used between different platforms and programming languages and still express complex messages and functions. The HTTP protocol is the most used Internet protocol. 6. What are the various web services platform elements? SOAP (Simple Object Access Protocol) UDDI (Universal Description, Discovery and Integration) WSDL (Web Services Description Language)

7. What are the SOAP related technologies? SOAP is a simple XML-based protocol to let applications exchange information over HTTP. In our SOAP tutorial, you will learn what SOAP is, and how it uses XML to exchange information between applications.

8. Define SOAP structure

SOAP once stood for 'Simple Object Access Protocol' but this acronym was dropped with Version 1.2 of the standard.[1] Version 1.2 became a W3C recommendation on June 24, 2003. The acronym is sometimes confused with SOA, which stands for Service-oriented architecture; however SOAP is different from SOA. What is SOAP? SOAP stands for Simple Object Access Protocol SOAP is a communication protocol SOAP is for communication between applications SOAP is a format for sending messages SOAP communicates via Internet SOAP is platform independent SOAP is language independent SOAP is based on XML SOAP is simple and extensible SOAP allows you to get around firewalls

What is AJAX? AJAX = Asynchronous JavaScript and XML. AJAX is a technique for creating fast and dynamic web pages. AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

How AJAX is based on Internet Standards? AJAX is based on internet standards, and uses a combination of: XMLHttpRequest object (to exchange data asynchronously with a server) JavaScript/DOM (to display/interact with the information) CSS (to style the data) XML (often used as the format for transferring data) AJAX applications are browser and platform-independent! 9. What are the AJAX web applications? XML the W3C DOM CSS XMLHttpRequest JavaScript 11 MARKS 1. Explain briefly about web services? (11 marks) Like the effect of rail transportation on national economic systems, Web services are fundamentally changing the rules of Web commerce. They connect programs to each other across distant points on the global map, transporting large amounts of data more efficiently and cheaply than ever before. The result is faster, better, and more productive communication for businesses and consumers alike. The Web started out supporting human interactions with textual data and graphics. People use the Internet daily to look up stock quotes, buy consumer goods, and read the latest news. This level of interaction is fine for many purposes. But the essentially text-based Web does not support software an interaction very well, especially transfers of large amounts of data. A more efficient method is needed that allows applications to interact directly with one another, automatically executing instructions that would otherwise have to be entered manually through a browser. Individuals and companies doing business over the Web need a way to publish links to their applications and data, in much the same way that they publish links to their Web pages. Internet based applications need to be able to find, access, and automatically interact with other Internet based applications. Web services improve Internet use by enabling program-to-program communication. Through the widespread adoption of Web services, applications at various Internet locations can be directly integrated and interconnected as if they were part of a single, large IT (information technology) system.

The Basics of Web Services

Web services are Extensible Markup Language (XML) applications mapped to programs, objects, or databases or to comprehensive business functions. Using an XML document created in the form of a message, a program sends a request to a Web service across the network, and, optional, receives a reply, also in the form of an XML document. Web services standards define the format of the message, specify the interface to which a message is sent, describe conventions for mapping the contents of the message into and out of the programs implementing the service, and define mechanisms to publish and to discover Web services interfaces. This technology can be used in many ways. Web services can run on desktop and handheld clients to access such Internet applications as reservations systems and order-tracking systems. Web services can also be used for business-to-business (B2B) integration, connecting applications run by various organizations in the same supply chain. Web services can also solve the broader problem of enterprise application integration (EAI), connecting multiple applications from a single organization to multiple other applications both inside and outside the firewall. In all these cases, the technologies of Web services provide the standard glue connecting diverse pieces of software. As illustrated in Figure 5-1, Web services wrap, presenting to the network a standard way of interfacing with back-end software systems, such as database management systems, .NET, J2EE (Java2 Platform, Enterprise Edition), or CORBA (common object request broker architecture), objects, adapters to enterprise resource planning (ERP) packages, integration brokers, and others. Web services interfaces receive a standard XML message from the networking environment, transform the XML data into a format understood by a particular back-end software system, and, optionally, return a reply message. The underlying software implementations of Web services can be created by using any programming language, operating system, or middleware system.

Figure 5.1 Web services interface with back-end systems Web services combine the execution characteristics of programmatic applications with the abstraction characteristics of the Internet. Today's Internet technologies succeed in part because they are defined at a sufficiently high level of abstraction to enable compatibility with any operating system, hardware, or software. The Web services-based Internet infrastructure exploits this abstraction level and includes semantic information associated with data. That is, Web services define not only the data but also how to process the data and map it into and out of underlying software applications.

A Simple Example: Searching for Information

Today, most services are invoked over the Web by inputting data into Hyper Text Markup Language (HTML) forms and sending the data to the service, embedded within a uniform resource locator (URL) string: http://www.google.com/search?q=Skate+boots&btnG=Google+Search This example illustrates how simple Web interactions, such as a search, a stock purchase, or a request for driving directions, are accessed over the Web by embedding parameters and keywords in a URL. In this example, entering a simple search request for Skate boots into the Google search engine results in the URL shown. The search keyword represents the service being requested over the Web, whereas the Skate+boots keywords represent the search string entered into the HTML form displayed by the Google Web site. The Google search service then passes the request to a series of other search engines, which return lists of URLs to pages with text matching the search keywords Skate+boots. This inefficient way of searching the Web depends entirely on matching the given text strings to cataloged HTML pages. XML provides a great many advantages for transmitting data across the Internet. Now the preceding request can be contained in an XML document instead: <SOAP-ENV:Body> <s:SearchRequest xmlns:s="www.xmlbus.com/SearchService"> <p1>Skate</p1> <p2>boots</p2> <p3>size 7.5</p3> </s:SearchRequest> </SOAP-ENV:Body> Sending the request within an XML document has many advantages, such as improved data typing and structure, greater flexibility, and extensibility. XML can represent structured and typed data the size field can be typed as a decimal string or as a floating point, for exampleand can contain a larger amount of information than is possible within a URL string. Interacting with Web Services The level of abstraction at which Web services operate encompasses such interaction styles as RPC (remote procedure call) emulation, asynchronous messaging, one-way messaging, broadcast, and publish/subscribe. Most major database management systems, such as Oracle, SQL Server, and DB2, support XML parsing and transformation services, allowing direct interaction between Web services and database management systems. Middleware vendors typically also provide a mapping of Web services to their software systems, such as application servers and integration brokers. To the user, therefore, interactions with Web services can appear as batch or online interactions, supporting synchronous or asynchronous communications patterns, and as user interfaces written using Java programs, VB (Visual Basic) programs, office applications, browsers, or thick clients to database management systems, to name a few, and can map down to any type of underlying software system. Web services standards and technologies generally encompass two major types of application interaction patterns: Remote procedure call (online) Document oriented (batch) These two types of interactions are described in the following subsections.

RPC-Oriented Interactions

In RPC-oriented interactions, the Web services request takes the form of a method or a procedure call with associated input and output parameters. In contrast to the document-oriented interaction, the RPCoriented interaction sends a document formatted specifically to be mapped to a single logical program or database, as shown in Figure 5-2. Because the "real-time" or in-season order for skate boots depends on available inventory, for example, the program accesses the database to check the available supply of the ordered item. If everything is OK, the program returns an XML document to the distributor in the request/response format to indicate that the order has been accepted and will be shipped. If supply isn't available, the return message indicates a back order or rejects the order entirely. In contrast to the document-oriented interaction style, the request and the reply are modeled as synchronous messages. That is, the application sending the message waits for a response. A single logical program can, of course, comprise multiple subprograms. Figure 5-2 This Web service supports an interactive order request/response.

Document-Oriented Interactions In the document-oriented interaction style, the Web service request takes the form of a complete XML document that is intended to be processed whole. For example, a Web service that submits a complete purchase order, such as a preseason order for skate boots, would submit the entire bulk order to the manufacturer at once, as shown in Figure 5-3 is like submitting a message to a queue for asynchronous processing. The manufacturer would typically send an e-mail or other form of acknowledgment to the retailer to indicate that the order was received and would be processed according to a predefined flow of execution. The flow might include such steps as checking the database for previous orders from the same retailer to ensure that it is not exceeding its credit limit or agreed capacity or scheduling a ship date for the order. In a real process flow, of course, many more steps are likely before the order is shipped and the invoice sent out, but the example shows only the final step: sending the XML invoice to the distributor for payment after the order has been shipped and received.

Figure 5-3 This Web service processes a complete purchase order.

Document-oriented interactions often assume that the parties to a Web services conversation have agreed to share a common business document, such as a purchase order, a ship bill, or an invoice. These parties are often identified as trading partners, or collaborating partners. Trading partners also typically agree on a common process flow, or interaction pattern, for exchanging the shared document, such as requiring an acknowledgment on receipt of a purchase order, returning specific status information in reply to an order query, or sending an e-mail alert when an order has been shipped. During the execution of the business process, a complete document might be exchanged. If the document is already held in common, fragments of information required to fill in specific sections of the shared document, such as purchase price or promised delivery date, might be exchanged. The Technology of Web Services Programs that interact with one another over the Web must be able to find one another, discover information allowing them to interconnect, figure out what the expected interaction patterns are a simple request/reply or more complicated process flow?and negotiate such qualities of service as security, reliable messaging, and transactional composition. Some of these qualities of service are covered in existing technologies and proposed standards, but others are not. In general, the Web services community is working to meet all these requirements, but it's an evolutionary process, much like the Web itself has been. Web services infrastructure and standards are being designed and developed from the ground up to be extensible, such as XML and HTML before them, so that whatever is introduced in the short term can continue to be used as new standards and technologies emerge. XML (Extensible Markup Language), the basic foundation on which Web services are built provides a language for defining data and how to process it. XML represents a family of related specifications published and maintained by the World Wide Web Consortium (W3C) and others. WSDL (Web Services Description Language), an XML-based technology, defines Web services interfaces, data and message types, interaction patterns, and protocol mappings.

SOAP (Simple Object Access Protocol), a collection of XML-based technologies, defines an envelope for Web services communicationmap able to HTTP and other transportsand provides a serialization format for transmitting XML documents over a network and a convention for representing RPC interactions. UDDI (Universal Description, Discovery, and Integration), a Web services registry and discovery mechanism, is used for storing and categorizing business information and for retrieving pointers to Web services interfaces.

2. Write a short note on UDDI? (6 marks) UDDI: Publishing and Discovering Web Services After you have defined the data in the messages (XML), described the services that will receive and process the message (WSDL), and identified the means of sending and receiving the messages (SOAP), you need a way to publish the service that you offer and to find the services that others offer and that you may want to use. This is the function that UDDI (universal distribution, discovery, and interoperability) provides. The UDDI framework defines a data model in XML and SOAP application programming interfaces (APIs) for registering and discovering business information, including the Web services a business publishes. UDDI is produced by an independent consortium of vendors, founded by Microsoft, IBM, and Ariba, to develop an Internet standard for Web service description registration and discovery. Microsoft, IBM, Hewlett-Packard, and SAP are hosting the initial deployment of a public UDDI service, which is conceptually patterned after DNS, the Internet domain name service that translates Internet host names into TCP addresses. In reality, UDDI is much more like a replicated database service accessible over the Internet. UDDI registers and publishes Web service definitions UDDI is similar in concept to a Yellow Pages directory. Businesses register their contact information, including such details as phone and fax numbers, postal address, and Web site. Registration includes category information for searching, such as geographical location, industry type code, business type, and so on. Other businesses can search the information registered in UDDI to find suppliers for parts, catering services, or auctions and marketplaces. A business may also discover information about specific Web services in the registry, typically finding a URL for a WSDL file that point to a supplier's Web service. UDDI is a directory of Web services Businesses use SOAP to register themselves or others with UDDI; then the registry clients use the query APIs to search registered information to discover a trading partner. An initial query may return several matches from which a single entry is chosen. Once a business entry is chosen, a final API call is made to obtain the specific contact information for the business. UDDI uses SOAP for registering and discovering information Figure 5-2 shows how a business would register Web service information, along with other, more traditional contact information, with the UDDI registry. A business first generates a WSDL file to describe the Web services supported by its SOAP processor (1) and uses UDDI APIs to register other contact information; the registry entry contains a URL that points to the SOAP server site's WSDL or other XML

schema file describing the Web service. Once another business's SOAP processor queries the registry (3) to obtain the WSDL or other schema (4), the client can generate the appropriate message (5) to send to the specified operation over the identified protocol (6). Of course, both client and server have to be able to agree on the same protocolin this example, SOAP over HTTPand share the same understanding, or semantic definition of the service, which in this example is represented via WSDL. With the widespread adoption of these fundamental standards, however, this common understanding of WSDL seems ensured. Figure 5-2 The UDDI repository can be used to discover a Web service.

3. Write a short note on SOAP- Accessing Web Services? (6 marks) So far, you have defined the data (XML) and expressed the abstraction of the service necessary to support the communication and processing of the message (WSDL). You now need to define the way in which the message will be sent from one computer to another and so be available for processing at the target computer. The SOAP specification defines a messaging framework for exchanging formatted XML data across the Internet. The messaging framework is simple, easy to develop, and completely neutral with respect to operating system, programming language, or distributed computing platform. SOAP is intended to provide a minimum level of transport on top of which more complicated interactions and protocols can be built. SOAP provides the communication mechanism to connect Web services SOAP is fundamentally a one-way communication model that ensures that a coherent message is transferred from sender to receiver, potentially including intermediaries that can process part of or add to the message unit. The SOAP specification contains conventions for adapting its one-way messaging for the request/response paradigm popular in RPC-style communications and also defines how to transmit complete XML documents. SOAP defines an optional encoding rule for data types, but the end points in a SOAP communication can decide on their own encoding rules through private agreement. Communication often uses literal, or native XML, encoding.

SOAP is the XML way of defining what information gets sent and how As shown in Figure 5-3, SOAP is designed to provide an independent, abstract communication protocol capable of bridging, or connecting, two or more businesses or two or more remote business sites. The connected systems can be built using any combination of hardware and software that supports Internet access to existing systems such as .NET and J2EE. The existing systems typically also represent multiple infrastructures and packaged software products. SOAP and the rest of the XML framework provide the means for any two or more business sites, marketplaces, or trading partners to agree on a common approach for exposing services to the Web. Figure 5-3 SOAP messages connect remote sites.

SOAP has several main parts: Envelope: Defines the start and the end of the message Header: Contains any optional attributes of the message used in processing the message, either at an intermediary point or at the ultimate end point Body: Contains the XML data comprising the message being sent Attachment: Consists of one or more documents attached to the main message (SOAP with Attachments only) RPC interaction: Defines how to model RPC-style interactions with SOAP Encoding: Defines how to represent simple and complex data being transmitted in the message SOAP messages contain an envelope, a header, and a body Only the envelope and the body are required. 4. Write a short note on WSDL: Describing Web Services? (6 marks) The Web Services Description Language (WSDL) is an XML schema format that defines an extensible framework for describing Web services interfaces. WSDL was developed primarily by Microsoft and IBM and was submitted to W3C by 25 companies. WSDL is at the heart of the Web services framework, providing a common way in which to represent the data types passed in messages, the operations to be performed on the messages, and the mapping of the messages onto network transports.

To date, 25 is the highest number of companies to join any W3C submission. A submission is a specification proposed for adoptions by W3C see www.w3.org/Submission/2001/07. WSDL is, like the rest of the Web services framework, designed for use with both procedure-oriented and document-oriented interactions. As with the rest of the XML technologies, WSDL is so extensible and has so many options that ensuring compatibility and interoperability across differing implementations may be difficult. If the sender and the receiver of a message can share and understand the same WSDL file the same way, however, interoperability can be ensured. WSDL is the XML format that describes what a Web service consists of WSDL is divided into three major elements: Data type definitions Abstract operations Service bindings WSDL has three major elements, according to level of abstraction Each major element can be specified in a separate XML document and imported in various combinations to create a final Web services description, or they can all be defined together in a single document. The data type definitions determine the structure and the content of the messages. Abstract operations determine the operations performed on the message content, and service bindings determine the network transport that will carry the message to its destination. WSDL elements can be defined in separate documents Figure 5-4 shows the elements of WSDL, layered according to their levels of abstraction, which are defined independently of the transport, specifically so that multiple transports can be used for the same service. For example, the same service might be accessible via SOAP over HTTP and SOAP over JMS. Similarly, data type definitions are placed in a separate section so that they can be used by multiple services. Major WSDL elements are broken into subparts. Figure 5-4 WSDL consists of three major elements and seven parts.

The definition parts include data type definitions, messages, and abstract operations, which are similar to interface definitions in CORBA or DCOM. Messages can have multiple parts and can be defined for use with the procedure-oriented interaction style, the document-oriented interaction style, or both. Through the abstraction layers, the same messages can be defined and used for componentsfor example, for including other message attributes.

WSDL interfaces are like CORBA or DCOM interfaces WSDL data type definitions are based on XML schemas, but another, equivalent or similar type definition system can be substituted. For example, CORBA Interface Definition Language (IDL) data types could be used instead of XML schema data types. (If another type definition system is used, however, both parties to a Web services interaction must be able to understand it.) Web service data types are based on XML schemas but are extensible to any other mechanism The service bindings map the abstract messages and operations onto specific transports, such as SOAP. The binding extensibility components are used to include information specific to SOAP and other mappings. Abstract definitions can be mapped to a variety of physical transports. The WSDL specification includes examples of SOAP one-way mappings for SMTP (Simple Mail Transfer Protocol), SOAP RPC mappings for HTTP, SOAP mappings to HTTP GET and POST, and a mapping example for the MIME (multipurpose Internet messaging extensions) multipart binding for SOAP. Abstract messages and operations are mapped to specific transports XML namespaces are used to ensure the uniqueness of the XML element names used in each of the three major WSDL elements. Of course, when the WSDL elements are developed separately and imported into a single complete file, the namespaces used in the separate files must not overlap. Associated schemas are used to validate both the WSDL file and the messages and operations defined within the WSDL file. Namespaces ensure WSDL element names' uniqueness It's safe to say that WSDL is likely to include many extensions, changes, and additions as Web services mature. Like SOAP, WSDL is designed as an extensible XML framework that can easily be adapted to multiple data type mappings, message type definitions, operations, and transports. For example, IETF (Internet Engineering Task Force) working groups are proposing a new protocol standardBlocks Extensible Exchange Protocol (BEEP)to define a useful connection oriented transport. (HTTP, by contrast, is inherently connectionless, making it difficult to resolve quality-ofservice problems at the transport level.) Companies interested in using Web services for internal application or integration may choose to extend WSDL to map to more traditional protocols, such as DCOM or IIOP (Internet Inter-Orb Protocol). 5. Explain briefly about the web service architecture? (11 marks) After the core standards are in place for data definition, service description, message transport, and service discovery, additional technologies are needed to complete Web services architecture that supports a broad variety of applications. Although the core standards are sufficient for many purposes, complex and critical business applications require additional features and functions. SOAP, WSDL, and UDDI supply the basic infrastructure, like the tracks of a railroad. But a railroad also requires a system of signals, switches, and stations in order to run effectively; Web services need security, process flow, transactions, guaranteed messaging, and so on to represent a complete computing environment. This describes some of the major proposed Web services specifications and technologies aimed at completing Web services architecture: Security, for Web services confidentiality, integrity, authentication, and authorization Process flow, for orchestrating the flow of execution across a series of Web services Transactions, for coordinating the results of multiple Web services Messaging, for configuring message paths and routing messages reliably across multiple network hops, including intermediaries

Security, process flow, transactions, and reliable messaging are major areas of work Microsoft and IBM continue to play a major role in Web services research, drafting and publishing specifications for additional technologies, and proposing ideas for a comprehensive Web services architecture. Although the two companies agree on many of the proposals, they disagree in other cases. One of the most difficult aspects of evaluating proposals for additional technologies is ascertaining the potential adoption levels for them. As with the core standards, these additional technologies and the requisite reference architecture proposals need independent supervision and control to become widely accepted. Microsoft and IBM often, but not always, collaborate This chapter also describes two seminal technologies that predate Web services and that continue to serve as a source of inspiration for Web services: RosettaNet, a trailblazer in Web services, especially business-critical aspects of XML processing over the Internet, including content management, process flow, security, and guaranteed messaging XML-RPC, another trailblazer for Web services, especially in the areas of simple RPC style Interaction The specifications described in this chapter are based mainly on extensions to SOAP and WSDL. Beyond this, however, is the need for an architecture that puts the additional services and technologies into their proper context. If you add security and transaction support to SOAP and WSDL, do you check the security information before processing the transaction? Do transaction control attributes belong in WSDL, or is it sufficient to incorporate them in SOAP headers? Can the security mechanism be used to secure the transaction context? And how does process flow relate to secure, transactional operations? Do process flows automatically initiate transactions? Furthermore, how can anyone reasonably decide which additional technologies are needed to complete the reference architecture, and which ones are out of scope or unnecessary? A Web services reference architecture is needed Because Web services are based on XML, they are fundamentally extensible to include other specifications and technologies. However, this flexibility introduces the problem of ensuring that the participants in a Web services interaction are using the same set of additional, compatible technologies and services. Figure 5-5 illustrates a potential Web services architecture based on the container concept. The container is a deployment vehicle for Web services, which are described and advertised using WSDL. Within the container is a dispatcher to invoke the Web service implementations in C#, Java, or other programming language, together with configuration parameters detailing container options, such as automatic handling of security, transactions, threading, messaging, multiprotocol mapping, and metadata handling. Additional Web services technologies that provide these features and functions are available to the container, perhaps as local program libraries or as remote Web services implementations. Administration and management services are also available for configuring, monitoring, and controlling the execution environment for deployed Web services.

Figure 5-5 Sample Web services architecture is based on the container concept.

Figure5.5 identifies the kinds of additional features and functionality that are needed to complete the Web services computing platform. The figure does not represent industry agreement on the overall model or on the specific set of features and functionality shown. It's one way, however, to gather together in a single diagram a representation of the types of additional technology proposals that are under consideration and that might end up in a comprehensive Web services architecture. Microsoft, IBM, and others have presented similar architectural proposals at a W3C forum on Web services, and the papers submitted to that forum provide a good source of ideas for completing the picture. The W3C Web Services Architecture Working Group is considering these papers and other proposals as it defines such reference architecture. Security Security is one of the most important and most complex issues confronting the Internet and Web services. Security is something you can't have enough of, but you have to draw a line somewhere, or you would never get anything done. Security is fundamental Basic security issues include data confidentiality and integrityto ensure that no one steals your credit card number, for example, or tampers with the content of your messageand authentication/authorization, which deals with the rights of individuals or groups to access a certain resource, such as a given Web service interface. For confidentiality and integrity, the starting point is SSL/TLS, which is implemented as HTTP over SSL (HTTPS). For authentication/authorization, the starting point is the simple checking of username/password, common to many Web sites, and proprietary mechanisms developed by such security vendors as Netegrity and Entrust. Another critical and fundamental aspect of Internet security is the use of firewalls, which have a bearing on Web services because they can be configured to inspect messages. XML-based security standards are still evolving, but consensus seems to be converging on a proposed standard for authentication and authorization (SAML) and a proposed standard for public key management (XKMS). Also, of course, and fundamental to all Internet security, are the firewalls that protect private networks. Firewalls map a publicly known IP address to another IP address on the internal network, thus establishing a managed tunnel and preventing unwanted access.

SAML Security Assertions Markup Language (SAML), an OASIS initiative, provides a standard way to profile information in XML documents and to define user identification and authorization information. SAML implementations provide an interoperable XML-based security solution, whereby user information and corresponding authorization information can be exchanged by collaborating services. SAML defines standard XML formats for authentication and authorization information that can be propagated along a call chain, using any transport technology. SAML enables single sign-on and end-to-end security for Web services. Users can travel across sites with their entitlements so that companies and partners in a trusted relationship can deliver single sign on across sites. XKMS The XML Key Management Specification (XKMS) defines a protocol for distributing and registering public keys used in encrypting and decrypting messages transmitted using SOAP and other transports. XKMS is designed for use with the W3C XML Signature specification (XMLSIG), developed jointly by W3C and IETF. XKMS includes two major parts: the XML Key Information Service Specification (XKISS) and the XML Key Registration Service Specification (X-KRSS). WS-License and WS-Security The Web services license language (WS-License) and the WS-Security specifications are Microsoft proposals that are designed to work together. The WS-License specification defines formats and encodings for security credentials used by WS-Security for preserving message confidentiality and integrity. A license is a special type of credential that contains a set of related assertions signed by an authority, such as a public or private key. Both X.509 certificates and Kerberos tickets are considered valid licenses. The main purposes of WS-License are to define a set of commonly used license types and to specify how they can be included within the WS-Security <credentials> tag. WS-Security provides credential exchange, message integrity, and message confidentiality for SOAP messages using the credentials defined by WS-License. WS-Security associates licenses with messages for confidentiality. Integrity is provided by using XML Signature and licenses to ensure that messages are not tampered with. Confidentiality is ensured by combining XML encryption with licenses. WS-License and WS-Security are designed to be used with SOAP, but their relationship to other, similar security efforts, such as SAML, is not defined 6. Explain briefly about AJAX improving web page performance using AJAX? (11 marks) AJAX is used to create more interactive applications. The following example will demonstrate how a web page can communicate with a web server while a user type characters in an input field: Example Start typing a name in the input field below: First name:

Suggestions:

Example Explained - The showHint() Function When a user types a character in the input field above, the function "showHint()" is executed. The function is triggered by the "onkeyup" event: function showHint(str) { if (str.length==0) { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","gethint.asp?q="+str,true); xmlhttp.send(); } Source code explanation: If the input field is empty (str.length==0), the function clears the content of the txtHint placeholder and exits the function. If the input field is not empty, the showHint() function executes the following:

Create an XML HttpRequest object Create the function to be executed when the server response is ready Send the request off to a file on the server Notice that a parameter (q) is added to the URL (with the content of the input field)

Ajax-DOM based XML processing Event-oriented AJAX is the art of exchanging data with a server, and update parts of a web page - without reloading the whole page.

What is AJAX? AJAX = Asynchronous JavaScript and XML. AJAX is a technique for creating fast and dynamic web pages. AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page. Classic web pages, (which do not use AJAX) must reload the entire page if the content should change. Examples of applications using AJAX: Google Maps, Gmail, Youtube, and Facebook tabs. How AJAX Works

AJAX is based on Internet Standards AJAX is based on internet standards, and uses a combination of:

XMLHttpRequest object (to exchange data asynchronously with a server) JavaScript/DOM (to display/interact with the information) CSS (to style the data) XML (often used as the format for transferring data)

AJAX applications are browser and platform-independent!

XML Canonicalization Defines a canonical character sequence for any XML document Became a Recommendation last year A necessary pre-condition for XML Signature Makes decisions about White space Attribute quotes Entity expansions Etc.

XML Signature Joint work with IETF Signing of (portions of) web resources And messages Approved as a Recommendation in February The great thing about standards Is that there are so many to choose from OASIS vs. W3C Notionally Applications vs. Infrastructure Messaging an obvious area of overlap - ebXML (OASIS) - XML Protocols (W3C) AJAX Technologies The technologies that are used to build AJAX web applications encompass a number of different programming domains, so AJAX development is neither as straightforward as regular applications development, nor as easy as old-school web development. On the other hand, the fact that AJAX development embraces so many different technologies makes it a lot more interesting and fun. Heres a brief listing of the technologies that work together to make an AJAX web application: XML the W3C DOM CSS XMLHttpRequest JavaScript Through the rest of this chapter, well meet each of these technologies and discuss the roles they play in an AJAX web application.

7. PROGRAMMING IN AJAX EXAMPLE PROGRAMS <html> <head> <script type="text/javascript"> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","ajax_info.txt",true); xmlhttp.send(); } </script> </head> <body> <div id="myDiv"><h2>Let AJAX change this text</h2></div> <button type="button" onclick="loadXMLDoc()">Change Content</button> </body> </html> Output:

AJAX is not a new programming language. AJAX is a technique for creating fast and dynamic web pages.

Load an XML file with AJAX <html> <head> <script type="text/javascript"> function loadXMLDoc(url) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById('A1').innerHTML=xmlhttp.status; document.getElementById('A2').innerHTML=xmlhttp.statusText; document.getElementById('A3').innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET",url,true); xmlhttp.send(); } </script> </head> <body> <h2>Retrieve data from XML file</h2> <p><b>Status:</b><span id="A1"></span></p> <p><b>Status text:</b><span id="A2"></span></p> <p><b>Response:</b><span id="A3"></span></p> <button onclick="loadXMLDoc('note.xml')">Get XML data</button> </body> </html> OUTPUT: Retrieve data from XML file Status: 200 Status text: OK

Response: Tove Jani Reminder Don't forget me this weekend!

Вам также может понравиться