bca-501

Upload: deepakpatni11

Post on 16-Oct-2015

44 views

Category:

Documents


0 download

DESCRIPTION

bvvv

TRANSCRIPT

  • INTERNET APPLICATIONSAND JAVA

    BCA - 501

    This SIM has been prepared exclusively under the guidance of Punjab TechnicalUniversity (PTU) and reviewed by experts and approved by the concernedstatutory Board of Studies (BOS). It conforms to the syllabi and contents asapproved by the BOS of PTU.

  • Author: Rohit KhuranaCopyright ITL Education Solutions Ltd, 2011

    All rights reserved. No part of this publication which is material protected by this copyright noticemay be reproduced or transmitted or utilized or stored in any form or by any means now known orhereinafter invented, electronic, digital or mechanical, including photocopying, scanning, recordingor by any information storage or retrieval system, without prior written permission from the Publisher.

    Information contained in this book has been published by VIKAS Publishing House Pvt. Ltd. and hasbeen obtained by its Authors from sources believed to be reliable and are correct to the best of theirknowledge. However, the Publisher and its Authors shall in no event be liable for any errors, omissionsor damages arising out of use of this information and specifically disclaim any implied warranties ormerchantability or fitness for any particular use.

    Vikas is the registered trademark of Vikas Publishing House Pvt. Ltd.

    VIKAS PUBLISHING HOUSE PVT LTDE-28, Sector-8, Noida - 201301 (UP)Phone: 0120-4078900 Fax: 0120-4078999Regd. Office: 576, Masjid Road, Jangpura, New Delhi 110 014 Website: www.vikaspublishing.com Email: [email protected]

    ReviewerSonia Sharma

  • CAREER OPPORTUNITIES

    Java is used in all areas associated with the Internet, Webdevelopment and Web technologies. Java programmers willfind job opportunities in all areas related to e-commerce, portals,content management, databases, data warehousing and customapplications development.

    Those wishing to take up software programming jobswould be expected to work on adding new functionality toexisting systems. Java programming skills would be requiredto prepare user and technical support manuals for differentapplications.

    Java programmers can use their skills to work on variousaspects of video game programming. Experienced video gameprogrammers can go on to become project managers in chargeof making sure that all the different programming componentsare working smoothly together. Being a vast field, theopportunities are many, depending on the field that the studentwants to specialize in. Coupled with a degree in management,Java programmers can climb the corporate ladder very fast

  • Section IIntroduction: Internet Architecture Board, Understandingthe Internet.Concept: Working, Surfing and Security on the Internet.Internet protocols Internet Addressing, Internet RoutingProtocols Internet Message Protocol, Internet GroupManagement protocols, Internet mail protocol.Internet applications: E-mail, multi cost backbone, net news.Web: World Wide Web advantages of web, web terminology,web access using web browser, locating information on theweb.

    Section IIIntroduction to Java: Applets, application & JDK, differentb/w Java & C++, working with Java objects: Encapsulation,inheritance & polymorphism, constructors. Garbagecollection & finalisers, data types, modifies & expressions,array & flow control statements.

    Section IIIException handling threads, Event handling, Networkprogramming & Java virtual machines, Java & databases.

    PTU DEP SYLLABI-BOOK MAPPING TABLEInternet Applications and Java

    Syllabi Mapping in Book

    Unit 1: Internet(Pages 316);

    Unit 2: Web: World Wide Web(Pages 1727);

    Unit 3: Java and the Internet(Pages 2938)

    Unit 4: Programming Elements of Java(Pages 3957)

    Unit 5: Control Statements(Pages 5976);

    Unit 6: Java Classes and Objects(Pages 7794);

    Unit 7: Arrays and Vectors(Pages 95108);

    Unit 8: Inheritance and Polymorphism(Pages 109131)

    Unit 3: Java and the Internet(Pages 2937);

    Unit 9: Exception Handling Threads(Pages 133166);

    Unit 10: Exception Handling(Pages 167184);

    Unit 11: Event Handling(Pages 185198);

    Unit 12: Network Programming(Pages 199212)

    Unit 13: Java and Database(Pages 213228)

  • CONTENTSINTRODUCTION 1

    UNIT 1 INTERNET 3161.0 Introduction1.1 Unit Objectives1.2 Understanding the Basics of the Internet

    1.2.1 Evolution of the Internet1.2.2 Internet Architecture Board1.2.3 Accessing the Internet1.2.4 Working of the Internet1.2.5 Surfing on the Internet

    1.3 Security on the Internet1.4 Internet Protocols1.5 Internet Addressing1.6 Internet Routing Protocols1.7 Internet Message Protocol (Internet Control Message Protocol)1.8 Internet Group Management Protocols1.9 Internet Mail Protocols

    1.10 Internet Applications1.11 Summary1.12 Key Terms1.13 Answers to Check Your Progress1.14 Questions and Exercises

    UNIT 2 WEB: WORLD WIDE WEB 17272.0 Introduction2.1 Unit Objectives2.2 The Web: Advantages and Terminology

    2.2.1 Web Terminology2.3 Web Access Using Web Browser2.4 Locating Information on the Web2.5 Summary2.6 Key Terms2.7 Answers to Check Your Progress2.8 Questions and Exercises

    UNIT 3 JAVA AND THE INTERNET 29383.0 Introduction3.1 Unit Objectives3.2 Basic Features of Java Programming Language3.3 Difference between Java and C++3.4 Java Applications and Applets3.5 Java Compiler3.6 Java Virtual Machine Concepts3.7 Java Development Kit (JDK)3.8 A First Look at Java Program3.9 Running Java Applications

  • 3.10 Command Line Arguments3.11 Summary3.12 Key Terms3.13 Answers to Check Your Progress3.14 Questions and Exercises

    UNIT 4 PROGRAMMING ELEMENTS OF JAVA 39574.0 Introduction4.1 Unit Objectives4.2 Character Set4.3 Tokens

    4.3.1 Keywords4.3.2 Identifiers4.3.3 Constants4.3.4 Operators4.3.5 Punctuators

    4.4 Structure of a Java Program4.5 Data Types

    4.5.1 Primitives Data types4.5.2 Non-Primitive Data types

    4.6 Variables4.7 Type Casting4.8 Operators and Operations

    4.8.1 Arithmetic Operators4.8.2 Increment and Decrement Operators4.8.3 Relational Operators4.8.4 Logical Operators4.8.5 Conditional Operator4.8.6 Assignment Operators4.8.7 Other Operators4.8.8 Operators Precedence and Associativity

    4.9 Summary4.10 Key Terms4.11 Answers to Check Your Progress4.12 Questions and Exercises

    UNIT 5 CONTROL STATEMENTS 59765.0 Introduction5.1 Unit Objectives5.2 Selection Statements5.3 Iteration Statements

    5.3.1 The for Loop5.3.2 The while Loop5.3.3 The do-while Loop

    5.4 Jump Statements5.5 Labelled Loops5.6 Summary5.7 Key Terms5.8 Answers to Check Your Progress5.9 Questions and Exercises

  • UNIT 6 JAVA CLASSES AND OBJECTS 77946.0 Introduction6.1 Unit Objectives6.2 Encapsulation6.3 Defining a Class

    6.3.1 Defining Methods6.4 Creating Objects6.5 Accessing Members of a Class6.6 Argument Passing

    6.6.1 Call-by-Value6.6.2 Call-by-Reference

    6.7 Constructors6.7.1 Parameterized Constructors

    6.8 Method Overloading6.9 Static Members

    6.10 this Keyword6.11 Garbage Collection

    6.11.1 The finalize() Method6.12 Summary6.13 Key Terms6.14 Answers to Check Your Progress6.15 Questions and Exercises

    UNIT 7 ARRAYS AND VECTORS 951087.0 Introduction7.1 Unit Objectives7.2 Arrays

    7.2.1 Single-Dimensional Arrays7.2.2 Multi-Dimensional Arrays

    7.3 Vectors7.4 Wrapper Classes7.5 Summary7.6 Key Terms7.7 Answers to Check Your Progress7.8 Questions and Exercises

    UNIT 8 INHERITANCE AND POLYMORPHISM 1091318.0 Introduction8.1 Unit Objectives8.2 Inheritance Basics

    8.2.1 Defining a Subclass8.3 Types of Inheritance

    8.3.1 Single Inheritance8.3.2 Hierarchical Inheritance8.3.3 Multilevel Inheritance8.3.4 Multiple Inheritance

    8.4 Access Modifiers8.5 Subclass Constructor8.6 Method Overriding8.7 Polymorphism

  • 8.8 Using final Keyword8.8.1 Final Variables8.8.2 Final Methods8.8.3 Final Classes

    8.9 Abstract Methods and Classes8.10 Summary8.11 Key Terms8.12 Answers to Check Your Progress8.13 Questions and Exercises

    UNIT 9 EXCEPTION HANDLING THREADS 1331669.0 Introduction9.1 Unit Objectives9.2 Concept of Threads

    9.2.1 Main Thread9.2.2 Creating Threads9.2.3 Extending Threads9.2.4 Implementing Runnable Interface

    9.3 Life Cycle of a Thread9.4 Thread Methods

    9.4.1 Using Yield(), Sleep() and Stop() Method9.4.2 Using isalive() and join() Method

    9.5 Threads Priority9.6 Synchronization of Threads

    9.6.1 Synchronizing Methods9.6.2 Synchronizing Statements9.6.3 Deadlock

    9.7 Inter-Thread Communication9.8 Suspending, Resuming and Stopping Threads9.9 Summary

    9.10 Key Terms9.11 Answers to Check Your Progress9.12 Questions and Exercises

    UNIT 10 EXCEPTION HANDLING 16718410.0 Introduction10.1 Unit Objectives10.2 Exceptions

    10.2.1 Keywords Used in Exception Handling10.2.2 Types of Exceptions

    10.3 Using try and catch Blocks10.3.1 Multiple catch Blocks10.3.2 Nested try Blocks

    10.4 Using finally Block10.5 Using throw Block10.6 Using throws Keyword10.7 Creating Your Own Exceptions10.8 Summary10.9 Key Terms

    10.10 Answers to Check Your Progress10.11 Questions and Exercises

  • UNIT 11 EVENT HANDLING 18519811.0 Introduction11.1 Unit Objectives11.2 Events11.3 Event Handling Model

    11.3.1 Java 1.0 Event Model11.3.2 Delegation Event Model

    11.4 Event Handling: Classes, Sources and Listner Interfaces11.4.1 Event Classes11.4.2 Event Sources11.4.3 Event Listener Interfaces

    11.5 Summary11.6 Key Terms11.7 Answers to Check Your Progress11.8 Questions and Exercises

    UNIT 12 NETWORK PROGRAMMING 19921212.0 Introduction12.1 Unit Objectives12.2 Networking Fundamentals

    12.2.1 TCP/IP Protocols12.2.2 Internet Addressing12.2.3 Ports12.2.4 Sockets

    12.3 The Networking Classes and Interfaces12.4 The InetAddress Class12.5 TCP/IP Socket Programming

    12.5.1 Creating a TCP Server12.5.2 Creating a TCP Client

    12.6 UDP Socket Programming12.6.1 Creating a UDP Server Program12.6.2 Creating a UDP Client Program

    12.7 Summary12.8 Key Terms12.9 Answers to Check Your Progress

    12.10 Questions and Exercises

    UNIT 13 JAVA AND DATABASE 21322813.0 Introduction13.1 Unit Objectives13.2 Architecture of JDBC13.3 JDBCODBC Bridge13.4 The java.sql Package

    13.4.1 The DriverManager Class13.4.2 The Connection Interface13.4.3 The Statement Interface13.4.4 The ResultSet Interface13.4.5 The PreparedStatement Interface13.4.6 The ResultSetMetaData Interface13.4.7 The SQLException Class

    13.5 Summary13.6 Key Terms13.7 Answers to Check Your Progress13.8 Questions and Exercises

  • Self-InstructionalMaterial 1

    Introduction

    NOTES

    INTRODUCTION

    Java is a programming language that has been developed by Sun Microsystems and isone of the most popular programming languages in use. It is widely used in various waysranging from application software to Web applications. It is a general-purpose, class-based and object-oriented language that is specifically designed to have the least numberof implementation dependencies possible. All these features led to the process of usingit as the language for the Internet. It also supports various Internet protocols and Webservices and is used for all applications of the Internet.

    This book, Internet Applications and Java, is divided into thirteen units. Thefirst unit deals with the basics of the Internet, including its evolution and variousapplications. The next unit provides an introduction to the World Wide Web. Therelationship between Java and the Internet has been analysed in the third unit. Thefourth unit deals with the programming elements of Java, while the control statements inJava have been shown in the fifth unit. The following unit highlights Java classes andobjects. The seventh unit deals with arrays and vectors. The eighth unit deals withinheritance and polymorphism. The next unit discusses the exception handling threads.The tenth unit explains exception handling, while the eleventh unit deals with eventhandling. Network programming has been discussed in the twelfth unit. Accessing adatabase in Java has been dealt with in the last unit.

    The book follows the self-instructional mode wherein each unit begins with anIntroduction to the topic. The Unit Objectives are then outlined before going on to thepresentation of the detailed content in a simple and structured format. Check YourProgress questions are provided at regular intervals to test the student's understandingof the subject. A Summary, a list of Key Terms and a set of Questions and Exercises areprovided at the end of each unit for recapitulation.

  • Self-InstructionalMaterial 3

    Internet

    NOTES

    UNIT 1 INTERNET

    Structure1.0 Introduction1.1 Unit Objectives1.2 Understanding the Basics of the Internet

    1.2.1 Evolution of the Internet1.2.2 Internet Architecture Board1.2.3 Accessing the Internet1.2.4 Working of the Internet1.2.5 Surfing on the Internet

    1.3 Security on the Internet1.4 Internet Protocols1.5 Internet Addressing1.6 Internet Routing Protocols1.7 Internet Message Protocol (Internet Control Message Protocol)1.8 Internet Group Management Protocols1.9 Internet Mail Protocols

    1.10 Internet Applications1.11 Summary1.12 Key Terms1.13 Answers to Check Your Progress1.14 Questions and Exercises

    1.0 INTRODUCTION

    The word Internet is derived from two words: Interconnection and Network. TheInternet is basically a network of networks that facilitates data transmission and exchange,across the million of domestic, academic, business and government networks. It is aglobal, publicly accessible network that enables sharing of files and other resourcesusing protocols through the transmission media. With the two hundred computers in1980, the Internet has now evolved to millions of computers linked worldwide.

    The Internet has grown from a small network to todays biggest network ofcomputers. Due to this colossal growth, the Internet has become the biggest domain ofinformation. Nowadays, an Internet user has access to a wide variety of services, suchas electronic mail, file transfer, vast information resources, interest group membership,interactive collaboration, multimedia displays, real-time broadcasting, shoppingopportunities, and much more.

    1.1 UNIT OBJECTIVES

    After going through this unit, you will be able to: Understand the basics of the Internet Discuss the working of Internet Describe the various protocols that are used for communication between different

    devices

  • Self-Instructional4 Material

    Internet

    NOTES

    Understand the Internet addressing Explain Internet routing protocols, Internet message control protocols, Internet

    group management protocols and Internet mail protocols Explain few applications of Internet

    1.2 UNDERSTANDING THE BASICS OF THEINTERNET

    The Internet refers to a global system of interconnected computer networks that use thestandard Internet Protocol Suite (TCP/IP) for serving millions of users worldwide. It isa network of networks comprising millions of private, public, academic, business andgovernment networks.

    This section deals with the basic aspects of the Internet, such as how it evolved,how it is accessed, how it works, and so on.

    1.2.1 Evolution of the InternetThe foundation of the Internet was laid in 1969 by the Department of Defense (DOD)of the United States of America. The DOD wanted to create a computer network thatcould continue to function in the event of a disaster, such as a nuclear war. Even if a partof the network was damaged or destroyed, the rest of the system would continue towork. That network was known as Advanced Research Projects Agency Network(ARPANET), which linked US scientific and academic researchers. It was the forerunnerof todays Internet.

    Later in 1980, another agency, the National Science Foundation (NSF) created anew network of computers based on ARPANET, called NSFNET, which turned out tobe more efficient and capable. Initially, NSFNET was designed to link five supercomputers situated at the major universities of NSF and allowed only academic research.Over the time, this network expanded to include sites for business, universities,government, etc. and finally becoming a network consisting of millions of computers,now known as the Internet.

    1.2.2 Internet Architecture BoardWhen ARPANET was developed, the DOD established a committee known as InternetActivities Board (IAB) to monitor and control the development of Internet. This boardwas later renamed to Internet Architecture Board. This committee was responsible fordeciding the standards required and how these standards should be implemented tocontrol the working of Internet. Some of the other responsibilities of IAB include:

    It monitors the structure of protocols used by the Internet. It monitors the procedures used to create the Internet standards. It acts as a representative of the interests of the Internet Society.

    The members of IAB regularly met and discussed the outcomes of the researchand reported to the DOD and NSF. In 1989, the IAB committee was divided into twogroups, namely, Internet Research Task Force (IRTF) and Internet Engineering TaskForce (IETF). The idea underlying the reorganization is to make IRTF focus on longterm research and IETF to handle short term engineering issues. The main purpose ofIRTF is to create research groups that focus on Internet protocols, applications,

  • Self-InstructionalMaterial 5

    Internet

    NOTES

    architecture, and technology, whereas, IETF is a large open community of networkdesigners, operators, vendors and researchers that focuses on solving technical problemson the Internet.

    1.2.3 Accessing the InternetAs you know, the Internet is a vast collection of different networks that allows thecomputers to exchange information with each other. It is a huge cooperative communitythat is not under the control of anyone. However, there are several organizations thatpropose standards and the guidelines for its proper usage. As a result, anyone havingInternet access can communicate directly with anyone on the Internet, post information,use distant applications and services or buy and sell products. For accessing the Internet,you need to buy an Internet connection from an authorized Internet Service Provider(ISP). An ISP is an organization that provides access to the Internet. It charges a monthlyfee and subscribes you as a user to connect to the Internet. Once you get subscribed,you can log on to the Internet and browse the Web any time as per your convenience.There are thousands of ISPs established all over India. Some of the common ISPsinclude Mahanagar Telephone Nigam Limited (MTNL), Videsh Sanchar Nigam Limited(VSNL), Satyam Online, etc.

    ISP provides a variety of Internet connections varying in the speed of accessingthe Internet. Following are the types of Internet connections provided by ISPs.

    Dial-up access Integrated services digital network (ISDN) Cable Digital subscriber line (DSL) Leased line

    1.2.4 Working of the InternetMost of the computers are not directly connected to the Internet, instead they are part ofsmall networks which in turn are connected to Internet backbone through gateways.Internet backbone act as interconnecting structure used to connect one or more networksand gateway is a device used to connect dissimilar networks.

    Now, let us see how messages are transferred from one system to another on theInternet. The message sent by the source computer is divided into small parts known aspackets. Each packet is assigned a sequence number 1, 2, 3, so on. All these packetsare then sent to the destination computer with the help of routers. At the destinationcomputer, the packets may be received in random order, thus the packets are rearrangedaccording to their sequence number and reassembled together to form the originalmessage. If any of the packets is lost or corrupted, it is resent from the source computer.

    1.2.5 Surfing on the InternetInternet contains a huge wealth of information which can help us in many ways. Thereare different websites on the Internet which are hosted by various companies,organizations, educational institutions, newspapers, magazines, individuals, etc. With thehelp of the web browser, one can easily visit these websites and gather competitiveinformation, conduct market research, and stay in touch with the current happenings.The process of locating information on the Internet is called Internet surfing or Internetbrowsing. Details of locating information on the Internet are discussed in Unit 2.

  • Self-Instructional6 Material

    Internet

    NOTES

    1.3 SECURITY ON THE INTERNET

    Internet, being a vital source of data and information, plays an important role in thegrowth of organizations, business, etc. However, at the same time, it has been a cause ofmany security risks. This is because computer systems on the Internet are vulnerable tovarious kinds of threats. Some of the common security threats that are faced today areas follows:

    Password cracking: Password cracking is a way for illegally accessing someonescomputer without his or her permission to do so.

    E-mail spoofing: Sometimes, a user can receive e-mail that appears to havebeen sent by one person but was actually sent by some other person and it resultsto spoofing. The aim of spoofing is to make the user divulge the confidentialinformation.

    Virus intrusion: Viruses are short programs which are attached to other programswith the intent to corrupt executable codes. Viruses are exposed when we receivee-mails, send documents over the network and even when we install software orcopy files from another hard disk. They are of various types, such as file infectingvirus, boot sector virus, polymorphic virus, multipartite virus, stealth virus, etc.They can affect the system in many ways like slowing down the system, formattingthe hard disk, corrupting the data, etc.

    Hackers: Hackers are the people who focus on finding some weak points in thesecurity mechanism of websites and other computer systems in order to gainunauthorized access. The activities of hackers are not limited to only gaining theunauthorized access of systems, but also include theft of confidential informationand damage the information systems. They can also introduce viruses in thenetwork which can enter database or other applications and crash the wholeserver.

    There are various ways through which Internet security can be provided. Some of themare as follows:

    Authentication: It is the process of determining whether the user is allowed toaccess the computer. Identification is usually done on the basis of username andpassword and it can also be done on the basis of fingerprints, voice recognition,signature, etc.

    Authorization: It is the process of specifying whether the user is grantedpermission to use certain resources. The computer resource is thus protectedfrom unauthorized users. The resources comprise data, programs, files, application,devices, etc. Usually the permission is granted by the system administrators.

    Cryptography: It is the process of encrypting or modifying the messages to hideits meaning from the unauthorized users who try to intercept it. With the help ofthis technique, the sensitive data which is sent across the Internet can be protected.

    Firewall: A firewall is a part of a computer system or network which is placedbetween an internal network and Internet. It is configured with a set of rules todetermine which network traffic should be allowed to pass and which one shouldbe blocked, that is, it blocks the unauthorized access. It is implemented in eithersoftware or hardware or, a combination of both.

    Check Your Progress1. The Department of

    Defense of USAlaid the foundationof Internet in theyear 1969. Thatnetwork wasknown as_______.

    2. What was thepurpose ofestablishing theInternetArchitectureBoard?

    3. _________ is adevice used toconnect dissimilarnetworks.

    4. Define Internetsurfing.

  • Self-InstructionalMaterial 7

    Internet

    NOTES

    Cyber laws: Cyber laws are enforced to control the cyber crime. The lawsaddress the legal issues related to the communication technology.

    Digital signature: In order to prevent spoofing, the original sender of the e-mailmust put the electronic signature in the message. This electronic signature is alsoknown as digital signature. Electronic signature ensures that the original messagesare not changed during the transmission process and the messages are also fromthe person which is in the sender list.

    1.4 INTERNET PROTOCOLS

    A protocol is referred to as the formal set of rules and conventions that govern howdifferent computer devices communicate with each other. Some of the protocols usedfor communication between different devices are discussed here.

    TCP/IPThe TCP/IP is a layered set of protocols that handles the way data is transmitted acrossthe Internet. The TCP/IP has two major components, namely, Transmission ControlProtocol (TCP) and Internet Protocol (IP).

    The TCP is a reliable and connection-oriented protocol that allows the data thatoriginates from source machine, to be delivered without error to the destination. Itfragments the incoming data into discrete messages called packets. TCP atreceiving the data, sends an acknowledgement that guarantees that the data isreceived and then reassembles the packets into original form.

    IP is an unreliable and connectionless protocol. It does not require a connection tobe established to transmit the data and does not guarantee the delivery of data toits destination. IP is primarily responsible for delivering the packets to the destination.

    HyperText Transfer Protocol (HTTP)HTTP is a protocol that facilitates accessing hypertext documents. It is designedspecifically for the WWW at CERN. It is based on the client/server principle that allowsthe client to make a connection with the server and then place a request. The serverservices that request and sends an appropriate reply to the client. The HTTP is used asa protocol for communication between the user agent and gateways to other IP protocolslike SMTP, FTP, etc.

    File Transfer Protocol (FTP)FTP is a set of rules that enables a user to transfer files from one system to another. Itallows the user to get access to the files stored in the directory of a remote computerthat is connected to the Internet. Using FTP, one can upload and download files from theremote computer (known as FTP Server), if he has access permission on the remotemachine.

    Some FTP servers allow users to use a method called anonymous FTP, whichallows users to access files without any specific permission to access. One can downloadFTP files using either web browser or a special software known as FTP client programsuch as Cube or Fetch.

  • Self-Instructional8 Material

    Internet

    NOTES

    Network News Transfer Protocol (NNTP)NNTP is a protocol which is used by computer clients and servers to manage the newsposted on newsgroup. It is used to transfer news messages over the Internet. NNTP isa replacement of original Usenet protocol. A copy of news messages posted by theusers can be collected from the newsgroups by NNTP server, which can later be readby other users. These users can send their own messages to the same group. NNTP hasbeen created for the efficient transmission of Netnews articles over a full duplex 8-bit-wide data stream communication channel.

    1.5 INTERNET ADDRESSING

    Every machine on the Internet is identified by a numerical address known as IP address.It is a 32 bit number which is assigned to each computer connected to the Internet. AnIP address comprises four sections that are separated by periods (.). Each section consistsof a number which ranges from 0 to 255. An example of a typical IP address is:216.27.61.137. Note that, no two computers can share the same IP address. As IPaddresses are in the form of numerical strings, they are hard to remember. Thus, thereexists a domain name that corresponds to an IP address. Domain names are human-readable addresses and are much easier to remember. A domain name consists of twoor more parts separated by periods (.). Some of the examples of domain name arewww.yahoo.com, www.nasa.org, etc. The domain name represents the name of theweb server where the desired web page or other resources resides. The last part of thedomain name is the top-level name which represents the type of organization or countryto which the server belongs. Three-letter abbreviations are used for organizations andtwo-letter abbreviations are used for countries. Some of the abbreviations which arereserved for various organizations are listed in Table 1.1.

    Table 1.1 Reserved Abbreviations for Organizations

    Domain Name Organization Type .com Commercial / profit organizations .edu Educational institutions .net Networking organizations .gov Government agencies .org Non-profit organizations .mil United states military

    Some of the abbreviations which are reserved for various countries are listed inTable 1.2.

    Table 1.2 Reserved Abbreviations for Organizations

    Domain Name Country Name .in India .uk United Kingdom .au Australia .nz New Zealand .dk Denmark .jp Japan

    Check Your Progress5.Which of the

    following methodshould be used toprevent E-mailspoofing?(a) Cryptography(b) Cyber laws(c) Firewalls(d) Digitalsignature

    6. Differentiatebetweenauthentication andauthorization.

    7. TCP is anunreliable andconnectionlessprotocol of TCP/IP. (True or False)

    8. Which of thefollowing protocolfacilitates accessinghypertextdocuments?(a) TCP/IP(b) FTP(c) HTTP(d) NNTP

    9. The mappingbetween thedomain name andits associated IPaddress isperformed by anInternet serviceknown as ______.

  • Self-InstructionalMaterial 9

    Internet

    NOTES

    The mapping between the domain name and its associated IP address is performedby an Internet service known as domain name system (DNS). It allows users to workwith domain names; however, Internet operates in IP address.

    1.6 INTERNET ROUTING PROTOCOLS

    Internet routers are specialized computers that interconnect several different networks.A computer on the Internet communicates with other computer by forwarding packetscontaining other computers IP address to the closest Internet router. The router maintainsthe information required for routing purposes in the routing table. The routing table canbe either static or dynamic. If the routing table is updated with change in the topology ofany network the routing table is said to be dynamic otherwise static. Today dynamictables are needed by the Internet. For handling dynamic routing tables, routing protocolshave been developed. A routing protocol is a set of rules and procedures which specifieshow routers share information with each other for routing purposes.

    As the Internet is so vast, the updation of routing tables cannot be handled by onerouting protocol, thus, the Internet is divided into a number of independent networksknown as autonomous systems. An autonomous system (AS) is a group of networksand routers which is controlled by a single administration. On the basis of routing insidean autonomous system or between autonomous systems, routing protocols are dividedinto types:

    Interior Gateway Protocol (IGP) Exterior Gateway Protocol (EGP)

    Interior Gateway Protocol (IGP)The Interior gateway protocol is a routing protocol which is used for routing purposewithin an AS. The two of the commonly used IGP protocols are Routing InformationProtocol (RIP) and Open Shortest Path First (OSPF).

    RIP: It is based on an algorithm known as distance vector algorithm. It useshop count as its metric (cost) which represents the number of networks passed toreach the destination. This protocol treats all the networks equally, that is, the costof passing through any of the networks is same; the hop value for passing eachnetwork is 1. In this protocol, while crossing several networks, if the hop value fora particular network reaches 16, then that network is said to be unreachable.Hence, this protocol is not suitable for very large networks.

    OSPF: It supports large networks and has become the main interior gatewayprotocol. It divides an autonomous system into areas, which is a set of routers,hosts and networks comprised in an AS. All the areas inside an AS are connectedto a special area called backbone. Routers within an area are called internalrouters and those located at area borders are known as area border routers.Area border routers summarize routing information of an area and exchange itwith neighbouring areas. This protocol allows assigning a metric to each routeand the metric or cost is based on the type of services on a particular route likeminimum delay, maximum throughput, etc. This protocol maintains several routingtables based on the different types of services. These routing tables can be usedfor selecting optimal route for sending the packets.

  • Self-Instructional10 Material

    Internet

    NOTES

    Exterior Gateway ProtocolThe exterior gateway protocol is a routing protocol which is used for routing purposeacross one or more autonomous systems. One of the most common EGP protocols isBorder Gateway Protocol (BGP).

    BGP is based on an algorithm known as path vector routing. In this algorithm,the routing table maintains the information containing details of the path used to reach adestination along with addresses of destination network and the next router. Every BGProuter evaluates the different paths used for reaching a destination and provides ratingto them. It then shares this information with other routers. The other routers, if requiredcan update their own routing tables and propagate this information to other neighbouringrouters. However, the route which is optimal for one router may not be optimal for otherrouter; therefore router has to decide whether to update its routing table.

    1.7 INTERNET MESSAGE PROTOCOL (INTERNETCONTROL MESSAGE PROTOCOL)

    The Internet Control Message Protocol (ICMP) is a network layer protocol which wasdesigned to overcome the limitations of IP. The limitations included lack of error reportingmessages and lack of procedures for handling host and management queries. An ICMPpacket is encapsulated inside an IP packet and is responsible for error free transmissionof IP packets over the network. Some of the important ICMP messages are as follows:

    Destination unreachable: This message is used when the router or subnet isnot able to reach the destination.

    Time exceeded: This message is used when the counter associated with thepacket hits zero and the packet is dropped. It indicates looping of packets due tocongestion or setting very low timer values.

    Source quench: This message is sent to the host which sends too many packetsleading to congestion in the network.

    Redirect: This message is used by the router to tell the source host about wrongrouting of a packet.

    Echo: This message is used to check whether a destination host is reachable andalive.

    Echo reply: This message is generated by the destination host in response to theEcho message received.

    Timestamp request: This message is used to determine the round trip timeneeded for an IP packet to travel between two machines.

    Timestamp reply: This message is generated in response to Timestamp Requestmessage. It is similar to Timestamp Request message except that it also containsthe arrival time of Timestamp Request message and departure time of the reply.

    1.8 INTERNET GROUP MANAGEMENT PROTOCOLSThe Internet Group Management Protocol (IGMP) protocol is designed to supportmulticasting. Multicasting is a process in which a message is sent to a large number ofhosts belonging to a group. To implement multicasting, a host must acquire a class Daddress (each class D address identifies a group of hosts). Whenever a message is sent

    Check Your Progress10. The two of the

    commonly usedIGP protocols are____________ and___________.

    11. BGP is based onan algorithmknown as______________.

    12. _____________message is sent tothe host whichsends too manypackets leading tocongestion in thenetwork.

  • Self-InstructionalMaterial 11

    Internet

    NOTES

    to the address by a process, it is sent to all the members of the group associated with thataddress. The host can join or leave the group as required by the process. Each hostmaintains the list of groups to which its processes currently belongs to.

    Each multicast router sends the queries regularly to determine the hosts runningthe processes belonging to any of the groups. Each host in turn sends a response messagefor each group currently running one or more processes. The messages sent by therouter and hosts are called IGMP query packet and IGMP response packet,respectively. Both these packets use a simple and fixed format with control information.It consists of several fields which are as follows:

    Ver: It specifies the version of the IGMP protocol. Message type: It specifies the type of message which can be a query message

    or a response message. Maximum response time: It specifies the maximum amount of time in which a

    query must be answered. Checksum: It specifies the checksum, calculated for the message. Group address: It contains the class D IP address of the group.

    1.9 INTERNET MAIL PROTOCOLS

    An Internet mail protocol is a protocol which is used by mail clients to exchange informationwith the mail servers. The three main protocols which are commonly used are SimpleMail Transfer Protocol (SMTP), Post Office Protocol Version 3 (POP3) and InternetMessage Access Protocol Version 4 (IMAP4).Simple Mail Transfer Protocol (SMTP)SMTP is used for sending a mail from one machine to another over the Internet. It is apush protocol, that is, it sends the message from source machine to destination machinewhether the destination machine wants it or not.

    When a source machine wants to send a message, it establishes a TCP connectionwith the destination machine. Once the TCP connection is established, the sending machine(that acts as client) waits for the destination machine (that acts as server) to be ready.The server initiates by sending a text message containing its id to tell the client, it isready. In case the server is not ready, the connection is released by the client and is triedagain.

    If the server is ready for receiving mail, the client tells it the sender and therecipient of the message. If that recipient exists, the server allows the client to send themessage. Once the message is received by the server, it sends the acknowledgement tothe client.

    Post Office Protocol Version 3 (POP3)POP3 is a standardized protocol that allows a user to access the mail box on the mailserver. POP3 begins when the user runs the mail reader. The mail reader establishes theTCP connection with the server. Once the connection is established, POP3 passes throughthree stages which are as follows:

    Authorization: It deals with the login of the user. After the successful login, usercan access his mail box.

  • Self-Instructional12 Material

    Internet

    NOTES

    Transaction: During this state, user can retrieve and download messages on thelocal system.

    Update: In this phase, all the messages are deleted on the server side and TCPconnection is broken.

    Internet Message Access Protocol Version 4 (IMAP4)Like POP3, IMAP4 is a protocol that allows to access the mail box. However, unlikePOP3, in which generally all the stored messages are downloaded and mail box is clearedoff, in IMAP4, all the messages remain stored on the server for indefinite period. Thisprotocol assumes that all the messages are not transferred to the local system.

    1.10 INTERNET APPLICATIONS

    Internet user has access to a wide variety of services such as electronic mail, file transfer,vast information resources, interest group membership, interactive collaboration,multimedia displays, real-time broadcasting, shopping opportunities, and much more.Some of the Internet applications are described in this section.

    E-mailE-mail or electronic mail is the most commonly used Internet service. It refers to thefacility of sending and receiving messages electronically over a network of computers.Sending and receiving e-mails requires a user to have an e-mail address (sometimescalled an e-mail account or an e-mail ID) in any of the websites that provides e-mailservice. A number of websites, such as www.yahoo.com, www.gmail.com,www.rediffmail.com and www.hotmail.com, provide the facility to create free e-mailaccount. Note that since, multiple users can access the Internet at the same time; the e-mail address must be unique for each Internet user.

    An e-mail address is divided into two parts, namely, username and the mail servername. The two parts are separated by the symbol @. The structure of an e-mail addressis as follows:

    [email protected]

    For example, [email protected] is an e-mail address where,itl.esl = the usernamegmail = the name of the mail server.com = a commercial website

    Though e-mail is a very popular service of the Internet because of its numerousadvantages, it has few disadvantages also. The advantages and disadvantages of e-mailare as follows:

    AdvantagesThe advantages of e-mail are as follows:

    It is very fast medium of communication. The messages can be sent in no timeirrespective of the distance.

    It is a very economic medium of communication. You are only charged the cost ofbeing online whether you are sending it overseas or down the road.

  • Self-InstructionalMaterial 13

    Internet

    NOTES

    Any form of data such as text, graphics, sound, or video can be sent throughe-mails.

    It is secure medium of communication, that is, no one can access anybodyse-mail account without knowing the password.

    DisadvantagesThe disadvantages of e-mail are as follows:

    A slight error in the e-mail address of the recipient is enough to prevent thedelivery of the message and even when you do everything right, there is always achance of failure in one of the links between you and your recipient.

    Sometimes viruses can enter into your system through the attachments receivedin e-mails.

    Multicast BackboneMbone (Multicast Backbone) is a kind of virtual network running over the top of Internet.Mbone finds its application in conducting audio and video conference among users locatedgeographically apart. Today, many researchers use Mbone to develop protocols andapplications for group communication. Earlier, it was almost impossible to transmit audioor video files over the Internet. However, today with Mbone, the audio or video conferencecan be conducted without any difficulty in spite of limited bandwidth available and variablepacket delivery delays on the Internet. Moreover, Mbone also compresses the data andprovides privacy by using encryption techniques.

    Usenet (Net News)On the Internet, one can also share news, views, ideas and information on any topic likepolitics, science, computers, etc. This can be accomplished using a newsgroup service.A newsgroup, also known as a Usenet, is an online discussion group on the Internetwho share a common interest. Many websites, like www.NewsOne.net, www.google.com,www.Usenet-Replayer.com, etc., provide the facility of newsgroups.

    People interested in a specific topic write articles and post them to the bulletinboard of the newsgroup server (a machine that posts the message for everyone to read)so that others can read, reply and comment on them. You can read and post newsgrouparticles using newsreader software such as Microsoft Outlook Express News or NetscapeNews or using a web browser like Internet Explorer.

    1.11 SUMMARY

    In this unit, you have learned that: The Internet is basically a network of networks that facilitates data transmission

    and exchange, across the million of domestic, academic, business and governmentnetworks.

    When ARPANET was developed, the DOD established a committee known asInternet Activities Board (IAB) to monitor and control the development of Internet.

    In 1989, the IAB committee was divided into two groups, namely, Internet ResearchTask Force (IRTF) and Internet Engineering Task Force (IETF). The ideaunderlying the reorganization is to make IRTF focus on long term research andIETF to handle short term engineering issues.

    Check Your Progress13. Which of these

    protocols isdesigned tosupportmulticasting?(a) SMTP(b) IGMP(c) ICMP(d) none of these

    14. In which of theseInternet mailprotocols do all themessages remainstored on theserver forindefinite period?(a) SMTP(b) POP3(c) IMAP4(d) none of these

    15. Which of these isused in conductingaudio and videoconference amongusers locatedgeographicallyapart?(a) Mbone(b) E-mail(c) Usenet(d) all of these

  • Self-Instructional14 Material

    Internet

    NOTES

    An ISP is an organization that provides access to the Internet. It charges a monthlyfee and subscribes you as a user to connect to the Internet.

    Internet backbone acts as interconnecting structure used to connect one or morenetworks and gateway is a device used to connect dissimilar networks.

    The process of locating information on the Internet is called Internet surfing orInternet browsing.

    Some of the ways through which Internet security can be provided areauthentication, authorization, cryptography, firewall, cyber laws, digital signature,etc.

    The TCP/IP is a layered set of protocols that handles the way data is transmittedacross the Internet.

    The File Transfer Protocol is a set of rules that enables a user to transfer filesfrom one system to another.

    Network News Transfer Protocol is a protocol, which is used by computer clientsand servers to manage the news posted on newsgroup.

    Every machine on the Internet is identified by a numerical address known as IPaddress. There exists a domain name that corresponds to an IP address. Themapping between the domain name and its associated IP address is performed byan Internet service known as domain name system (DNS).

    A routing protocol is a set of rules and procedures which specifies how routersshare information with each other for routing purposes.

    An autonomous system (AS) is a group of networks and routers which is controlledby a single administration. Interior gateway protocol is a routing protocol which isused for routing purpose within an AS. Exterior gateway protocol is a routingprotocol which is used for routing purpose across one or more autonomous systems.

    An ICMP packet is encapsulated inside an IP packet and is responsible for errorfree transmission of IP packets over the network.

    Internet Group Management Protocol (IGMP) protocol is designed to supportmulticasting. Multicasting is a process in which a message is sent to a largenumber of hosts belonging to a group.

    Simple Mail Transfer Protocol (SMTP) is used for sending a mail from one machineto another over the Internet.

    Post Office Protocol Version 3 (POP3) is a standardized protocol that allows auser to access the mail box on the mail server.

    IMAP4 is a protocol that allows accessing the mail box. In IMAP4, all the messagesremain stored on the server for indefinite period.

    E-mail or electronic mail is the most commonly used Internet service which refersto the facility of sending and receiving messages electronically over a network ofcomputers.

    Mbone (Multicast Backbone) is a kind of virtual network running over the top ofInternet. Mbone finds its application in conducting audio and video conferenceamong users located geographically apart.

    A newsgroup, also known as a Usenet, is an online discussion group on the Internetwho share a common interest.

  • Self-InstructionalMaterial 15

    Internet

    NOTES

    1.12 KEY TERMS

    Internet Service Provider (ISP): It is an organization that provides access tothe Internet.

    Internet surfing or Internet browsing: It is the process of locating informationon the Internet.

    Authentication: It is the process of determining whether the user is allowed toaccess the computer.

    Authorization: It is the process of specifying whether the user is grantedpermission to use certain resources.

    Cryptography: It is the process of encrypting or modifying the messages to hideits meaning from the unauthorized users who try to intercept it.

    Firewall: A firewall is a part of a computer system or network which is placedbetween an internal network and Internet.

    Protocol: It is referred to as the formal set of rules and conventions that governhow different computer devices communicate with each other.

    TCP/IP: It is a layered set of protocols that handles the way data is transmittedacross the Internet.

    Hypertext transfer protocol (HTTP): It is a protocol that facilitates accessinghypertext documents.

    File Transfer Protocol (FTP): It is a set of rules that enables a user to transferfiles from one system to another.

    Network News Transfer Protocol (NNTP): It is a protocol, that is used bycomputer clients and servers to manage the news posted on newsgroup.

    Routing protocol: It is a set of rules and procedures which specifies how routersshare information with each other for routing purposes.

    Autonomous System (AS): It is a group of networks and routers which iscontrolled by a single administration.

    Multicasting: It is a process in which a message is sent to a large number ofhosts belonging to a group.

    Internet mail protocol: It is a protocol which is used by mail clients to exchangeinformation with the mail servers.

    1.13 ANSWERS TO CHECK YOUR PROGRESS

    1. ARPANET2. The Internet Architecture Board was established to monitor and control the

    development of Internet. It was responsible for deciding the standards requiredand how these standards should be implemented to control the working of Internet.

    3. Gateway4. The process of locating information on the Internet is called Internet surfing or

    Internet browsing.5. (d)

  • Self-Instructional16 Material

    Internet

    NOTES

    6. Authentication is the process of determining whether the user is allowed to accessthe computer, whereas authorization is the process of specifying whether theuser is granted permission to use certain resources.

    7. False8. (c)9. Domain name system (DNS)

    10. Routing Information Protocol (RIP), Open Shortest Path First (OSPF)11. Path vector routing12. Source quench13. (b)14. (c)15. (a)

    1.14 QUESTIONS AND EXERCISESShort-Answer Questions

    1. What are the types of Internet connections provided by ISPs?2. How does the Internet work?3. What do you understand by Internet addressing?4. What is the role IGMP protocol?5. What are the various Internet routing protocols?

    Long-Answer Questions1. What are the common Internet security threats faced today? Also describe some

    of the ways through which Internet security can be provided.2. Discuss some Internet protocols used for communication between different

    devices.3. Explain various ICMP messages.4. Describe the various Internet mail protocols.5. Write short notes on the following Internet applications:

    (a) E-mail(b) Multicast Backbone(c) Usenet

  • Self-InstructionalMaterial 17

    Web: World Wide Web

    NOTES

    UNIT 2 WEB: WORLD WIDE WEB

    Structure2.0 Introduction2.1 Unit Objectives2.2 The Web: Advantages and Terminology

    2.2.1 Web Terminology2.3 Web Access Using Web Browser2.4 Locating Information on the Web2.5 Summary2.6 Key Terms2.7 Answers to Check Your Progress2.8 Questions and Exercises

    2.0 INTRODUCTION

    The concept of the Web emerged at CERN (the European Council for Nuclear Research)Geneva, Switzerland, in the year 1989. Since then, WWW is the most popularly usedInternet sub network. The CERN team developed the protocol based on hypertext thatmakes it possible to connect content on the Web with hyperlinks. Earlier, the Internetwas largely a text-based system. However, the WWW permitted access to informationusing a Graphical User Interface (GUI) and the use of hypertext links to accessinformation across the network without being a computer expert and without knowingthe exact physical location.

    2.1 UNIT OBJECTIVES

    After going through this unit, you will be able to: Understand World Wide Web and its advantages Define some Web-related terms and technologies Understand how to access Web using a Web browser Explain how to locate information on the Web

    2.2 THE WEB: ADVANTAGES AND TERMINOLOGY

    The World Wide Web (WWW) or W3 or simply the Web is a collection of linked documentsor pages, stored on millions of computers and distributed across the Internet. Some ofthe advantages of WWW that led to its popularity are as follows:

    It provides information in multimedia form, that is, in more than one medium suchas text, graphics, video and audio.

    It provides a simple and consistent way of accessing the information available onthe Internet by using hypertext. The hypertext is a system in which the documentscontain links to other pages on the Internet. These links are called hyperlinks.

    Note: The term World Wide Web is not a synonym of the Internet; it is one of theservices provided by the Internet.

  • Self-Instructional18 Material

    Web: World Wide Web

    NOTES

    2.2.1 Web TerminologySome of the terms and technologies related to the Web are discussed in this section.

    Web PageA Web page is a document on the WWW that can include text, images, audio, video, etc.A Web page is of two types, namely, static Web page and dynamic Web page. A staticWeb page sends the same information to every end-user, whereas a dynamic Web pagecustomises the information according to the end-user.

    WebsiteA collection of related Web pages stored on a Web server is known as a Website. AWebsite is owned and maintained by a person, group, company or an organisation. EachWebsite is accessed by its address known as URL (Uniform Resource Locator). Allthe Websites on the Internet constitute the World Wide Web.

    Home PageA home page (also called index page) refers to the Web page that identifies the Websiteand contains the hyperlinks to other Web pages in a Website. A Website may havehundreds of pages or may consist of one page only.

    Web PortalA Website that acts as a gateway to a broad range of other sites on the Internet isknown as Web portal or simply a portal. In other words, a portal has a catalogue ofother Websites. It may also offer various other resources and services like a searchengine, e-mail, chatting, on-line shopping, horoscopes, latest news, etc. The first Webportal was America Online (AOL). Some of the popular Web portals used today areyahoo.com, rediff.com and indiatimes.com.Web BrowserA Web browser is a software application that enables to view and navigate informationon the Web. A Web browser uses the HTTP protocol to request Web pages from theWeb. A Web browser may be text or graphical browser. For example, Lynx is the text-based Web browser whereas Netscape Navigator and Internet Explorer are commonlyused graphical Web browsers.

    Web ServerThe Web pages on the Internet are stored on the computers that are connected to theInternet. These computers are known as Web servers. Any computer that has a serversoftware installed on it and is connected to the Internet can act as a Web server. TheWeb browsers and the Web servers are linked together using the client/server architecture.

    The Client/Server ArchitectureThe client/server architecture is a network architecture in which each computer on thenetwork is either a client or a server. Servers are the computers that provide services toother computers attached to them. The services may include file transfer, printing files,sharing data, sending information, etc. On the other hand, clients are PCs or workstationsthat request for different types of services provided by the server. In terms of theInternet, Web browsers are the clients that request for the Web pages residing on the

  • Self-InstructionalMaterial 19

    Web: World Wide Web

    NOTES

    Web server and the Web server fulfills their requests by sending the Web pages. Webservers provide services to Web browser using the HTTP protocol.

    2.3 WEB ACCESS USING WEB BROWSER

    A Web browser is a software application that is used to view and browse information onthe Web. With the help of a Web browser, one can easily visit various Websites andgather competitive information, conduct market research, and stay in touch with thecurrent happenings.

    Internet Explorer is the most widely used Web browser developed by Microsoft.Let us take an example to illustrate how Web can be accessed using Internet Explorer.

    Open and Navigate a WebsiteOpen Internet Explorer by double clicking the Internet Explorer shortcut icon placed onthe desktop. After opening the Internet Explorer, enter the address of the Website, thatis, URL in the address bar and press Enter to open the Website. The home page of theWebsite is displayed. You can move around the home page using various methods, whichare as follows:

    Using the vertical or horizontal scroll bars to move around a document. Pressing the Up and Down arrow keys to move up or down one line. Pressing the Page Up key to move up one window length and Page Down to

    move down one window length. Pressing Ctrl+Home and Ctrl+End to go to the beginning of the document and

    the end of the document, respectively.The home page displays various hyperlinks which link to other Web pages or to the otherparts of the same Web page. To open a hyperlink, just click any of the hyperlinks to openthe linked document. Alternatively, right-click on the hyperlink and select the Openoption from the shortcut menu to open the Web page in the same window or select theOpen in New Window to open the Web page in a new window (see Figure 2.1).

    Figure 2.1 Home Page of a Website

    Check Your Progress1. WWW is a simple

    way of accessinginformationavailable on theInternet by using_________.

    2. Which of these is asoftwareapplication thathelps to view andnavigateinformation on theWeb?(a) Web page(b) Web portal(c) Web browser(d) Web server

    3. What is the client/server architecture?

  • Self-Instructional20 Material

    Web: World Wide Web

    NOTES

    After browsing through several pages in a window, you can move backward and forwardby clicking the Back and Forward button on the Standard toolbar.

    Save Text and ImagesInternet Explorer helps not only to find the required information from the Internet but italso allows saving the retrieved information on the local system for future reference. Tosave part of the text from a Web page, select the text that has to be saved. Right-clickthe selected text and then click Copy option from the shortcut menu that appears. Nowyou can paste the selected text in any of the word processor such as Notepad, Wordpad,MS Word, etc., and save it for future reference, as shown in Figure 2.2.

    Figure 2.2 Saving the Text

    Similarly, images can also be saved from a Web page. To save the image, right-click the image and then click the Save Picture As option from the shortcut menu. Thisdisplays the Save Picture dialog box. Select the location for the image from the Save indrop-down list box and enter a name for the image in the File name box. Click Save tosave the image at the desired location, as shown in Figure 2.3.

    Figure 2.3 Saving the Image

  • Self-InstructionalMaterial 21

    Web: World Wide Web

    NOTES

    If you want to save the entire Web page, click the File menu and the click SaveAs option to displays the Save Web Page dialog box. Select the location for the Webpage from the Save in drop-down list box and enter a name for the Web page in the Filename box. Click Save to save the Web page, as shown in Figure 2.4.

    Figure 2.4 Saving a Web Page

    Add to FavoritesInternet Explorer provides a feature called Favorites. This feature maintains a listcalled the Favorites list, of all the Web pages that you visited and want to visit again. Toadd a Web page to the Favorites list, follow these steps.

    1. Open the Web page that you want to add to your favorites. Click Add to Favoritesoption on the Favorites menu. The Add Favorite dialog box appears (see Figure2.5).

    2. Enter a different name for the Web page, if required, in the Name box.3. Select the Make available offline check box to view the page even when you

    are not connected to the Internet and click OK.

    Figure 2.5 Add Favorite Dialog Box

  • Self-Instructional22 Material

    Web: World Wide Web

    NOTES

    After the Website is added to the favorites list, you can view it by clicking on thedesired link on the Favorites menu.

    2.4 LOCATING INFORMATION ON THE WEB

    Locating information on the Web is one of the most popular services provided on theInternet. You can find information on various topics, such as science, travel, politics,education, health, etc., on the Internet. In addition, the Internet can be used to findpeople and retrieve information about them.

    A search engine is software that enables you to search information on the Internet.It displays the results of a search based on the criteria entered by the user. That is, theuser provides a keyword or a phrase that helps the search engine to start the search. Forexample, to find information about the various generations of the computer, enter thephrase generations of computer and the search engine will display a list of Web pagescontaining the desired information.

    A search engine mainlys uses three tools for searching, namely, a spider or acrawler, an indexer and a search algorithm. A crawler searches the Internet for newterms and stores the searched terms in a database. An indexer then indexes all theterms in the database to make the searching process fast. A search algorithm is simplya method by which the search engine performs a search based on the keywords enteredby the user. Google, Yahoo and Altavista are some popular search engines.To find information using a search engine, follow these steps.

    1. Start Internet Explorer.2. Open the home page of any search engine. For example, open www.google.com.

    Figure 2.6 Google Home Page

  • Self-InstructionalMaterial 23

    Web: World Wide Web

    NOTES

    3. Enter the search keyword, for example, Internet in the search text box (seeFigure 2.6).or

    Click Advanced Search if you want to perform advanced search. A page withvarious Advanced Search options appears (see Figure 2.7). Select the requiredoptions from the page to set your Advanced Search.

    Figure 2.7 Advanced Search Page

    4. Click the Advanced Search button when you finish setting the options. A Webpage with a list of hyperlinks appears (see Figure 2.8).

    Figure 2.8 List of Hyperlinks

  • Self-Instructional24 Material

    Web: World Wide Web

    NOTES

    5. Choose any hyperlink and click it to open the Web page in the same window.or

    Right-click the hyperlink and click Open in New Window from the shortcutmenu to open the Web page in a new window.

    6. Keep clicking the hyperlinks on the main search page till you find the requiredinformation.The Internet also helps you in finding the information about your friends, relatives

    and other people online. You can find and get any persons e-mail address, telephonenumber, mailing address or any other information through the Internet (if available on theInternet). To find information about a person, initially you have to provide some basicinformation about that person like the first and the last name, city, state or country name,etc. The Internet retrieves and displays a list of people from where you can search therequired information.

    Some of the Websites that provide the facility of finding people online arewww.people.yahoo.com, www.batchmates.com and www.orkut.com. To find any ofyour friends or relatives using the Internet, follow these steps.

    1. Open the Website for people search. For example, open www.people.yahoo.com.2. To make a phone and address search, enter the First name, last name, City/Town

    and State in the respective text boxes and then click the corresponding Searchbutton (see Figure 2.9). A Web page with phone numbers and address informationappears.

    Figure 2.9 Finding People

    3. To search for the e-mail address, enter the First Name and Last Name in therespective text boxes and then click the corresponding Search button (see Figure2.9). A Web page with the e-mail information appears (see Figure 2.10).

  • Self-InstructionalMaterial 25

    Web: World Wide Web

    NOTES

    Figure 2.10 Finding E-mail Address

    4. Enter the required information in the respective text boxes and click Search. AWeb page with the e-mail information appears.

    2.5 SUMMARY

    In this unit, you have learned that: The concept of the Web began at CERN (the European Center for Nuclear

    Research) Geneva, Switzerland, in the year 1989. Since then, WWW is the mostpopularly used Internet sub network.

    The hypertext is a system in which the documents contain links to other pages onthe Internet. These links are called hyperlinks.

    The World Wide Web (WWW) or W3 or simply the Web is a collection of linkeddocuments or pages, stored on millions of computers and distributed across theInternet.

    A collection of related Web pages stored on a Web server is known as a Website. A Website that acts as a gateway to a broad range of other sites on the Internet

    is known as Web portal A Web browser is a software application that enables to view and navigate

    information on the Web. A Web browser may be text or graphical browser. The Web pages on the Internet are stored on the computers that are connected to

    the Internet. These computers are known as Web servers. The client/server architecture is a network architecture in which each computer

    on the network is either a client or a server. Web servers provide services to Webbrowser using the HTTP protocol.

    Check Your Progress4. Which of these

    searches new termson Internet andstores the searchedterms in adatabase?(a) Crawler(b) Indexer(c) Searchalgorithm(d) None of these

    5. Define searchengine.

    6. What shortcutkeys can be usedto go to thebeginning of thedocument and theend of thedocument,respectively?

    7. Which feature ofInternet Explorer isused to organizethe frequentlyvisited Websites?

  • Self-Instructional26 Material

    Web: World Wide Web

    NOTES

    Locating information on the Web is one of the most popular services provided onthe Internet.

    A search engine is software that enables you to search information on the Internet.It displays the results of a search based on the criteria entered by the user. Asearch engine mainly uses three tools for searching, namely, a spider or a crawler,an indexer and a search algorithm.

    2.6 KEY TERMS

    World Wide Web (WWW) or W3: It is a collection of linked documents orpages, stored on millions of computers and distributed across the Internet.

    Web page: It is a document on the WWW that can include text, images, audio,video, etc.

    Website: It is a collection of related Web pages stored on a Web server. Home page (index page): It refers to the Web page that identifies the Website

    and contains the hyperlinks to other Web pages in a Website. Web portal (or simply a portal): It refers to a Website that acts as a gateway

    to a broad range of other sites on the Internet. Web browser: It is a software application that enables to view and navigate

    information on the Web. Client/server architecture: It is a network architecture in which each computer

    on the network is either a client or a server. Servers: They are the computers that provide services to other computers

    attached to them.

    2.7 ANSWERS TO CHECK YOUR PROGRESS

    1. Hypertext2. (c)3. The client/server architecture is a network architecture in which each computer

    on the network is either a client or a server. Servers are the computers thatprovide services to other computers attached to them. On the other hand, clientsare PCs or workstations that request for different types of services provided bythe server.

    4. (a)5. A search engine is software that enables to search information on the Internet. It

    displays the results of a search based on the criteria entered by the user.6. To go to the beginning of the document, the Ctrl + Home key is pressed, while to

    go to the end of the document, the Ctrl + End key is pressed.7. Internet Explorer provides a feature called Favorites, which maintains a list called

    the Favorites list of all the Web pages that the visited and wants to visit again.

  • Self-InstructionalMaterial 27

    Web: World Wide Web

    NOTES

    2.8 QUESTIONS AND EXERCISESShort-Answer Questions

    1. What is the reason for the popularity of WWW?2. What is the difference between a static Web page and a dynamic Web page?3. What do you understand by Web portal?4. Differentiate between a Web browser and a Web server.5. What are the main tools used by a search engine?6. What type of information can be located on the Web?

    Long-Answer Questions1. Discuss the various methods that can be used to move around the home page.2. Write short notes on:

    (i) Web page(ii) Website(iii) Web browser(iv) Client/server architecture

    3. Describe the various steps to be taken to find information using a search engine.4. Explain the various steps you would take to find any of your friends or relatives

    using the Internet.

  • Self-InstructionalMaterial 29

    Java and the Internet

    NOTES

    UNIT 3 JAVA AND THE INTERNETStructure

    3.0 Introduction3.1 Unit Objectives3.2 Basic Features of Java Programming Language3.3 Difference between Java and C++3.4 Java Applications and Applets3.5 Java Compiler3.6 Java Virtual Machine Concepts3.7 Java Development Kit (JDK)3.8 A First Look at Java Program3.9 Running Java Applications

    3.10 Command Line Arguments3.11 Summary3.12 Key Terms3.13 Answers to Check Your Progress3.14 Questions and Exercises

    3.0 INTRODUCTION

    Java, initially named as Oak, was developed by the team headed by James Gosling atSun Microsystems, USA in 1991. The first and foremost reason behind the developmentof Java was the need for a platform-independent and portable software to be embeddedin the consumers electronic devices like remote controls, microwave ovens, etc. Thesecond reason that led to the growth of Java is the Internet and World Wide Web asthese media need portable and platform-independent programs. Gosling and other teammembers developed Web applets using the new language that could run on all types ofcomputers. During 1993, first Web browser, namely HotJava was developed to locateand run applet programs. This development made Java language popular for the Internet.By the year 1996, Java became a general-purpose, object-oriented programming languagewhich was used for Internet programming. Soon, Java became popular and many Webbrowsers, such as Internet Explorer, Netscape Navigator etc., incorporated the ability torun Java applets. In this unit, you will learn about the various features of Java whichhave made it a popular language for various Internet applications.

    3.1 UNIT OBJECTIVES

    After going through this unit, you will be able to: Describe Java programming language and explain its features Differentiate between Java and C++ Explain Java applications and applets Understand the role of Java compiler Explain the features of Java Virtual Machine Identify the various tools in the Java Development Kit

  • Self-Instructional30 Material

    Java and the Internet

    NOTES

    Understand the simple Java program Run Java application Explain command line arguments

    3.2 BASIC FEATURES OF JAVA PROGRAMMINGLANGUAGE

    Java is a third generation programming language which implements most of the conceptsof OOPs. Java has become a popular language for Internet applications because ofvarious features which are as follows.

    Simple: Java inherits the syntax of C/C++ and many of the OOPs features ofC++ thus one who has understood the concepts of object-oriented language canlearn Java with least effort. Moreover Java omits the complex and unreliablecode of C and C++ like operator overloading, pointers, preprocessor header files.Java provides small and convenient ways to accomplish a given task.

    Interpreted: Unlike other languages Java uses two-stage system as it uses bothcompiler and interpreter for its program execution. First, the compiler convertsthe program code to bytecode which in turn is converted to machine code on anymachine using the interpreter. The machine code so generated can be executedirrespective of the system on which it is being executed.

    Architecture-neutral (platform-independent): This feature makes Javalanguage very special. Java programs can run on any platform that is they canrun on different CPUs and on different operating system architectures. Thebytecode produced by Java compiler can be run on any machine which has Javaruntime environment.

    Object-Oriented language: Java is an object-oriented language as everythingin Java is an object. The objects and classes contain the program code and data.The Java object model is easily extensible and classes can be used anywhere inthe program in the form of packages.

    Robust: Java is a robust language because of mainly two reasons. Firstly, it is astrictly typed language that checks the code at the compile time. Secondly, Javadoes memory management in an effective way. In C++, the programmer has tomanually deallocate the dynamic memory used by the objects. Java automaticallydeallocates free memory that is no longer referenced by the objects (with thehelp of garbage collector).

    Distributed: Since Java is platform independent, it is suitable for developingapplications for the networks. Java can handle TCP/IP protocols and henceapplications developed in Java can access remote objects on Internet like anyobject on a local system.

    Multithreaded: Java supports multithreaded programming which allows us towrite a program that can perform more than one task simultaneously. User neednot wait for one program to finish one task before starting next task. For example,user can listen to an audio clip while downloading the applet. This feature helps toimprove the performance of graphical applications.

  • Self-InstructionalMaterial 31

    Java and the Internet

    NOTES

    High Performance: As stated earlier, the Java program is converted to bytecodewhich is then converted to machine code using interpreter. Since bytecode ishighly optimized, it enables the JVM to execute programs at much faster rate.

    Dynamic: It is dynamic in nature that is Java programs can link to new classlibraries, objects, methods, etc., at the run-time. Java language also provides thefacility to include the functions of other languages like C and C++. They arereferred to as native methods. These methods are also linked dynamically atrun-time.

    3.3 DIFFERENCE BETWEEN JAVA AND C++

    Both C++ and Java are object-oriented languages but they are very different from eachother. Some of the features of C++ language were deliberately removed and some newfeatures were added to make Java more flexible and reliable language. Some of thedifferences between Java and C++ are as follows:

    Java does not support multiple inheritance of classes directly. The concept of multithreading is supported by Java. The destructor function in Java is replaced by finalize method. The keyword typedef is not supported by Java. Java does not support pointers instead it uses implicit object references. The virtual keyword is not supported in Java. Java does not support the concept of global variables. Java supports exception handling in different way than C++. It provides finally

    clause for cleanup. The non-primitive data types are allocated memory by using the new operator. Java adds many features that are necessary for object-oriented programming.

    3.4 JAVA APPLICATIONS AND APPLETS

    In recent years, Java has become popular language for the programs that are required torun on different systems. Java enables us to create three types of applications. First,Java can be used to create a normal Java application. A Java application is quitesimilar to any program written in C or C++ which gets the user input, performs calculationsand displays the result.

    Second, Java can be used to create Web-based applications called applets. Ithas completely changed the Internet programming. Applets are tiny programs that aredesigned in such a way that they can be transmitted over the Internet. They can bedownloaded on demand and executed automatically by Java compatible Web browser.They are used to handle user input, data supplied by the server and simple functions thatexecutes locally on the client machine.

    Applet is dynamic, self-executing program and is intelligent enough that can changeit with the user inputs. The dynamic programs when downloaded and executed cancause serious harms to the computer as it may contain viruses like Trojan horse and

    Check Your Progress1. Java was

    developed at SunMicrosystems in1991 by the teamheaded by______

    2. First Web browserHotJava wasdeveloped in year1993.(True or False)

    3. Java used both_______ and_________ for itsprogram execution.

    4. Bytecode isplatformindependent.(True or False)

    5. Native methodscan be linkeddynamicallyat_____.

  • Self-Instructional32 Material

    Java and the Internet

    NOTES

    malicious programs. These harmful programs may search the contents on local filesystem of the client computer and may gather private information like credit card numbers,passwords, etc. Earlier viruses were scanned before executing the downloaded program,but Java has resolved the issue by confining the Java programs to Java executionenvironment only.

    3.5 JAVA COMPILER

    In most of the programming languages, the program is converted to machine code eitherby using compiler or interpreter. The machine code so generated is machine dependentthat is it may not run on the machine other than the one on which it is generated. Unlikein case of other programming languages, the Java compiler does not convert sourcecode to machine code rather it converts source code to a special intermediate codeknown as bytecode. The bytecode so generated is in the form of class files that can beinterpreted. The command used for compilation in Java is javac which converts thecorresponding Java file into class file. The bytecode is machine independent that is it canbe run on any machine with the help of Java virtual machine (JVM), which is discussedin the next section.

    Source Code Bytecode Compiler

    .java file .class file

    Figure 3.1 Compilation of a Java Program

    3.6 JAVA VIRTUAL MACHINE CONCEPTS

    As discussed earlier, Java uses both compiler and interpreter. Source code written inJava is compiled to generate bytecode and then this bytecode is interpreted to machineinstructions for specific machine. The bytecode generated by the compiler is not machinespecific. It is generated for the virtual machine that exists only inside the computermemory known as Java Virtual Machine (JVM). This virtual machine is designed insuch a way that it can be implemented on the top of any existing processor and itselfacts as virtual processor chip. It hides the underlying operating system details from Javaapplications. The process of converting source code to machine code is shown inFigure 3.2.

    Source Code Bytecode Compiler Interpreter

    Machine Code

    JVM Figure 3.2 Conversion of Source Code to Machine Code

    JVM obtains the bytecode stream from the .class file in the form of series ofinstruction. Each instruction consists of a one-byte opcode (a valid and understandablecommand which tells the JVM what to do) and zero or more operands, which arerequired to complete the opcode.

  • Self-InstructionalMaterial 33

    Java and the Internet

    NOTES

    Some of the main components of JVM are stack, registers, garbage-collection heap andmethod area.

    Stack: JVM stacks are similar to the stacks used in C or other conventionallanguages. It consists of frames that hold the state of Java method invocation. Itholds the local variables, parameters, its return value and the intermediate results.JVM stack can not be manipulated directly and only pushing and popping offrames can take place. When a method is invoked, the JVM pushes a new frameinto the stack and after the completion of execution of the method the frame ispopped and discarded by the virtual machine. The size of the JVM stack can befixed or may dynamically increase and decrease according to the requirement.

    Registers: JVM uses different types of registers to control the stacks. Some ofthe important JVM registers are:

    o Optop: It points to the top of operand stack.o Frame: It points to the current execution environment.o Vars: It points to the local variables.o Program counter: It keeps record of the next instruction in a program to

    be executed. Garbage-collection heap: Heap is a free memory space used for allocations to

    the variables like arrays, class instances, etc., at runtime. Whenever memory isallocated with the help of new operator, that memory space is allocated from theheap. Heap provides an automatic storage management system known as garbage-collection heap. Whenever there are objects which are no longer referenced,then the runtime environment automatically reclaims the memory occupied by theobjects. Size of the heap may be fixed or may increase or decrease according tothe requirement.

    Method area: Method area is a storage area for the compiled code. Althoughthe method area is a part of heap, there is no specific area where it exists. Thisfeature makes JVM more portable and secure. Size of the method area may befixed or may increase or decrease according to the requirement. Method area isused to store:

    o Runtime constant poolo Field informationo Method informationo Code for methods and constructorso Special methods that are used in class and instance initialization.o Interface type initialization

    The primitive data types that can be handled by the JVM are byte(8 bits), char(16bits), short(16 bits), int(32 bits), float(32 bits), long(64 bits), double(64 bits).

    3.7 JAVA DEVELOPMENT KIT (JDK)JDK consists of various tools that are used to develop and execute Java programs. Thetools included in JDK are listed in Table 3.1.

  • Self-Instructional34 Material

    Java and the Internet

    NOTES

    Table 3.1 Tools in Java Development Kit

    Tool Function javac Java compiler that converts source code to Java bytecode java Java interpreter that interprets class files generated by java compiler

    and converts it to machine code javadoc Document generator which automatically generates documentation

    form source code javah Generates C headers and a stub generator used for writing native

    methods javap The class file disassembler which enables to convert bytecode files to

    a program description jdb Java debugger which helps in tracking errors in the program appletviewer Used for running and debugging Java applets without a web browser

    3.8 A FIRST LOOK AT JAVA PROGRAM

    Let us start learning Java with a simple Java program that prints a string on the screen.Example 3.1: A simple Java program

    class Sample{

    public static void main (String args[]){

    System.out.println(Welcome to Java Programming);System.out.println(Its easy and simple.);

    }}

    Though this program is the simplest one, it includes the basic features that everyJava program has. Let us now look at the features one by one.

    Class DefinitionThe first statement class Sample declares a class where class is a keyword andSample is the identifier that indicates the name of the class. The opening and closingcurly braces { } enclose the definition of a class.The Main StatementThe statement public static void main (String args[]) indicates themain method. This method is the point where the execution of Java program begins.Since, it is the startup point of any Java program, it is the most essential part of any Javaprogram.This statement has keywords, namely, public, static and void. The descriptionsof these keywords are as follows.

    public: It is an access specifier which specifies that the main method isaccessible to all other classes.

    static: The main method is declared static which specifies that this methodbelongs to the entire class. Interpreter use this method before the creation ofobjects.

    Check Your Progress6. _________method

    replaces destructorfunction in Java.

    7. Global variablesare supported inJava. (True orFalse)

    8. Applets are tinyprograms that canbe downloadedfrom the internetand can be run onJava compatibleWeb browser.(True or False)

    9. _________commandconverts the sourcecode tointermediatebytecode.

    10. Name some of theimportant JVMregisters.

    11. What is the role ofgarbage-collectionheap?

    12. JDK is a set ofvarious tools usedto develop andexecute javaprograms.(True or False)

  • Self-InstructionalMaterial 35

    Java and the Internet

    NOTES

    void: The void keyword specifies that the main method does not return avalue. The pair of parentheses contains the declaration of the parameters of themethods. In the above statement, the String args[ ] declares a parameterargs, that contains an array of objects of the class type String.

    The Output StatementThe statements System.out.println(Welcome to JavaProgramming.);and System.out.println(Its easy and simple.); are used todisplay information on the standard output device, that is the println() is a methodof the out object, which is the static member of class System. These statements willdisplay the following strings on the monitor.

    Welcome to Java Programming.Its easy and simple.

    The statements will be printed in separate lines as the method println()appends a newline character at the end of the string. However, if we use print()method instead of println() newline character is not appended at the end of thestring. Note that like C++, every statement in Java must end with a semicolon.

    3.9 RUNNING JAVA APPLICATIONS

    A program can be created using any text editor. Nowadays, there are several texteditors available for writing programs like Notepad, Jcreator, etc. After creating the file,save the file with the name .Java. The name of the file must be sameas that of the class name containing the main() method.Once the file is created, it can be compiled to generate the bytecode using Java compilerjavac as given here.

    javac Sample.javaIf the source code is error free then the compiler creates a file containing the

    bytecode and the file will be named as .class. In our example, thename of file will be Sample.class.

    Even though after compilation, the source code is converted into its equivalentbytecode, it cannot be executed. To execute this bytecode, it needs to be converted tomachine code using the interpreter. The command for converting bytecode to machinecode and run it is as follows:

    java SampleAfter giving this command, the interpreter searches for the main() method in

    the source code and starts executing the instructions written in this method and displaysthe corresponding output.

    3.10 COMMAND LINE ARGUMENTS

    Like C++, Java enables to pass arguments to the main() method also. These argumentsare passed by typing them after the program name on the command line. Hence, thesearguments are known as command line arguments. They help in providing data to theprogram.

  • Self-Instructional36 Material

    Java and the Internet

    NOTES

    As stated earlier, the argument named as args of String type is passed to themain method. It is this argument which will receive any data passed to the programthrough command line.Example 3.2: A program to demonstrate the use of command line arguments

    class CommandLineArg{

    public static void main(String args[]){

    System