Wednesday, September 25, 2013

JavaScript: Functions

JavaScript Functions

A function is a group of reusable code which can be called anywhere in your programme. This eliminates the need of writing same code again and again. Functions help programmers to write modular code. We can divide our programme into a number of small and manageable functions. Like any other advance programming language, JavaScript also supports all the features necessary to write modular code using functions.
Functions that are provided by JavaScript are called built-in functions and those defined by the user are called user-defined functions. alert(), confirm() etc. are examples for built-in functions.

Function Definition
Before we use a function we need to define that function. A function is defined as a code block (inside curly { } braces), preceded by the function keyword and name of the function.
A function can receive a list of values on which it can operate, known as the parameters of the function.
 The basic syntax is:
<script type="javascript">
      function functionname(parameter-list){
                              statements
      }
</script>
Example:
<script type="javascript">
      function helloWorld(){
                              alert("Hello World");
      }
</script>

Calling a Function
The function can be called directly when an event occurs (like when a user clicks a button), and it can be called from anywhere by JavaScript code.
To invoke a function we should simply write the name of that function as follows:
<script type="javascript">
      helloWorld();
</script>

Function Parameters
JavaScript allows the programmers to pass different parameters while calling a function.
These passed parameters can be captured inside the function and any manipulation can be done over them.
A function takes multiple parameters specified as a comma separated list.
<script type="javascript">
      function sayHello(name){
                              alert( "Hello "+name);
      }
</script>
Example:
<script type="javascript">
      sayHello("Vinod");
</script>
When the function is called as shown, it displays an alert dialog box with message 'Hello Vinod'.

Returning values
A JavaScript function can have an optional return statement. This is required if we want to return a value from a function. This statement should be the last statement in a function.
For example we can pass two numbers as parameters to function sum() and we can expect the function to return their sum to the point where it is called.
<script type="javascript">
      function sum(x, y){
                              var s;
                              s = x + y;
                              return  s;
      }
</script>
Now we can call this function as follows:
<script type="javascript">
      var result;
      result = sum(8, 6);
      alert("Sum:"+result );
</script>
The output of the above code will be an alert dialog box displaying 'Sum:14'
Scope of Variables
With respect to their scope variables can be classified into two as local variables and global variables.
A variable declared within a JavaScript function becomes local variable and can only be accessed from within that function. It is said to have local scope. We can have local variables with the same name in different functions, because local variables are only recognized by the function in which they are declared. Local variables are deleted as soon as the function is completed.
Variables declared outside a function, become global variable, and all scripts and functions on the web page can access it. They are deleted only when the page closes
Example:
<script  type="javascript">
      var x;
      function sum(a,b){
                              x=a+b
      }
      function displaySum(){
                              alert("Sum:"+x)
      }
</script>
In the above example x is a global variable while a and b are local to the function sum(). So x can be easily accessed by the function displaySum() which displays the sum calculated in sum().

Tuesday, September 24, 2013

Microsoft FrontPage

Microsoft FrontPage

Introduction
Microsoft FrontPage (full name Microsoft Office FrontPage) is a WYSIWYG(What-You-See-Is-What-You-Get) HTML editor and web site administration tool from Microsoft. It was a part of the Microsoft Office suite from 1997 to 2003. It has since been replaced by Microsoft Expression Web and Sharepoint Designer, which were first released in December 2006 alongside Microsoft Office 2007. FrontPage was initially created by the Cambridge, Massachusetts company Vermeer Technologies Incorporated. Vermeer was acquired by Microsoft in January 1996.
As a WYSIWYG editor, FrontPage is designed to hide the details of pages' HTML code from the user, making it possible for novices to easily create web pages and sites.
In 2006, Microsoft announced that FrontPage would eventually be superseded by two products. Microsoft SharePoint Designer will allow business professionals to design SharePoint-based applications. Microsoft Expression Web is targeted at the web design professional for the creation of feature-rich web sites. Microsoft announced that FrontPage will be discontinued from December 2006.

Advantages
  1. FrontPage 2003 consists of a Split View option to allow the user to code in Code View and preview in Design View without the hassle of switching from the Design and Code View tabs for each review
  2. Dynamic Web Templates (DWT) allows the users to create a single template that could be used across multiple pages and even the whole Web site
  3. Interactive Buttons give users a new easy way to create web graphics for navigation and links, eliminating the need for a complicated image-editing package such as Adobe Photoshop
  4. The accessibility checker gives user the ability to check if their code is standards compliant and that their Web site is easily accessible for people with disabilities. An HTML optimizer is included to aid in optimizing code to make it legible and quicker to process
  5. Intellisense, which is a form of auto completion, is a key feature that assists the user while typing in Code View. When working in Code View, Intellisense will suggest tags and/or properties for the code that the user is entering which significantly reduces the time to write code. 
  6. Code Snippets give users the advantage to create snippets of their commonly used pieces of code allowing them to store it for easy access whenever it is next needed
  7. FrontPage includes support for programming in ASP.NET, a server-side scripting language, that adds interactivity to Web sites and Web pages
  8. FrontPage includes support for macros in Visual Basic.


Sunday, September 22, 2013

Programming in Java: AWT classes 02

Working with Graphics, Colours and Fonts

Working with Graphics
The AWT supports a rich assortment of graphics methods. All graphics are drawn relative to a window. This can be the main window of an applet, a child window of an applet, or a stand-alone application window. The origin of each window is at the top-left corner and is (0,0). Coordinates are specified in pixels.
The Graphics class defines a number of drawing functions. Each shape can be drawn edge-only or filled. Objects are drawn and filled in the currently selected graphics colour, which is black by default. When a graphics object is drawn that exceeds the dimensions of the window, output is automatically clipped. Let’s take a look at several of the drawing methods.

Drawing Lines
Lines are drawn by means of the drawLine() method, shown here:
void drawLine(int x1, int y1, int x2, int y2)
It displays a line in the current drawing colour that begins at (x1, y1) and ends at (x2, y2).

Drawing Rectangles
The drawRect() and fillRect() methods display an outlined and filled rectangle, respectively. The signature is:
void drawRect(int top, int left, int width, int height)
void fillRect(int top, int left, int width, int height)
The upper-left corner of the rectangle is at top, left. The dimensions of the rectangle are specified by width and height.
To draw a rounded rectangle, use drawRoundRect() or fillRoundRect(), The signature is:
void drawRoundRect(int top, int left, int width, int height, int xArc, int yArc)
void fillRoundRect(int top, int left, int width, int height, int xArc, int yArc)
A rounded rectangle has rounded corners. The upper-left corner of the rectangle is at top, left. The dimensions of the rectangle are specified by width and height. The diameter of the rounding arc along the X axis is specified by xArc. The diameter of the rounding arc along the Y axis is specified by yArc.

Drawing Ellipses and Circles
To draw an ellipse, use drawOval( ). To fill an ellipse, use fillOval( ). The signature is:
void drawOval(int top, int left, int width, int height)
void fillOval(int top, int left, int width, int height)
The ellipse is drawn within a bounding rectangle whose upper-left corner is specified by top, left and whose width and height are specified by width and height. To draw a circle, specify a square as the bounding rectangle.

Drawing Arcs
Arcs can be drawn with drawArc( ) and fillArc( ) methods. The signature is:
void drawArc(int top, int left, int width, int height, int startAngle, int sweepAngle)
void fillArc(int top, int left, int width, int height, int startAngle, int sweepAngle)
The arc is bounded by the rectangle whose upper-left corner is specified by top, left and whose width and height are specified by width and height. The arc is drawn from startAngle through the angular distance specified by sweepAngle. Angles are specified in degrees. Zero degrees is on the horizontal, at the three o’clock position. The arc is drawn counter-clockwise if sweepAngle is positive, and clockwise if sweepAngle is negative. Therefore, to draw an arc from twelve o’clock to six o’clock, the start angle would be 90 and the sweep angle 180.

Drawing Polygons
It is possible to draw arbitrarily shaped figures using drawPolygon( ) and fillPolygon( ). The signature is:
void drawPolygon(int x[ ], int y[ ], int numPoints)
void fillPolygon(int x[ ], int y[ ], int numPoints)

The polygon’s endpoints are specified by the coordinate pairs contained within the x and y arrays. The number of points defined by x and y is specified by numPoints.

Working with colour
Java supports colour in a portable, device-independent fashion. The AWT colour system allows you to specify any colour you want. It then finds the best match for that colour, given the limits of the display hardware currently executing your program or applet. Colour is encapsulated by the Color class.
You can also create your own colours, using one of the colour constructors. Three commonly used forms are:
Color(int red, int green, int blue)
Color(int rgbValue)
Color(float red, float green, float blue)
The first constructor takes three integers that specify the colour as a mix of red, green, and blue. These values must be between 0 and 255
The second colour constructor takes a single integer that contains the mix of red, green, and blue packed into an integer. The integer is organized with red in bits 16 to 23, green in bits 8 to 15, and blue in bits 0 to 7.
The final constructor, Color(float, float, float), takes three float values (between 0.0 and 1.0) that specify the relative mix of red, green, and blue.
Once you have created a colour, you can use it to set the foreground and/or background colour by using the setForeground( ) and setBackground( ) methods.

Color Constatnts
The class Color defines the constants shown here that can be used to specify colours:

Color.black
Color.magenta
Color.blue
Color.orange
Color.cyan
Color.pink
Color.darkGray
Color.red
Color.gray
Color.white
Color.green
Color.yellow
Color.lightGray



Color Methods
You can obtain the red, green, and blue components of a colour independently using the methods shown below:
int getRed( )
int getGreen( )
int getBlue( )
Each of these methods returns the RGB colour component found in the invoking Color object in the lower 8 bits of an integer.
To obtain a packed, RGB representation of a colour, use getRGB( ), shown here:
int getRGB( )
The return value is organized as described earlier.

Setting the Current Graphics Color
By default, graphics objects are drawn in the current foreground colour. You can change this colour by calling the Graphics method setColor( ):
void setColor(Color newColor)
Here, newColor specifies the new drawing colour. You can obtain the current colour by calling getColor(), as shown:
Color getColor( )

Working with fonts
The AWT supports multiple type fonts. The AWT provides flexibility by abstracting font-manipulation operations and allowing for dynamic selection of fonts. Fonts have a family name and a face name. The family name is the general name of the font, such as Courier. The face name specifies a specific font, such as Courier Italic. Fonts are encapsulated by the Font class.

Font variables
The Font class defines the following variables:
String name: Name of the font
float pointSize: Size of the font in points
int size: Size of the font in points
int style: Font style

Font methods
The most commonly used methods defined by Font are listed below:
Method
Description
static Font decode(String str)
Returns a font given its name.
boolean equals(Object FontObj)
Returns true if the invoking object contains the same font as that specified by FontObj. Otherwise, it returns false.
String getFamily( )
Returns the name of the font family to which the invoking font belongs.
String getFontName()
Returns the face name of the invoking font.
int getSize( )
Returns the size, in points, of the invoking font.
int getStyle( )
Returns the style values of the invoking font.
boolean isBold( )
Returns true if the font includes the BOLD style value. Otherwise, false is returned.
boolean isItalic( )
Returns true if the font includes the ITALIC style value. Otherwise, false is returned.
boolean isPlain( )
Returns true if the font includes the PLAIN style value. Otherwise, false is returned.
String toString( )
Returns the string equivalent of the invoking font.

Determining the Available Fonts
When working with fonts, often we need to know which fonts are available on your machine. To obtain this information, we can use the getAvailableFontFamilyNames( ) method defined by the GraphicsEnvironment class as shown here:
String[ ] getAvailableFontFamilyNames( )
This method returns an array of strings that contains the names of the available font families. In addition, the getAllFonts( ) method is defined by the GraphicsEnvironment class as shown:
Font[ ] getAllFonts( )
This method returns an array of Font objects for all of the available fonts. Since these methods are members of GraphicsEnvironment, we need a GraphicsEnvironment reference to call them. We can obtain this reference by using the getLocalGraphicsEnvironment() static method, which is defined by GraphicsEnvironment as shown:
static GraphicsEnvironment getLocalGraphicsEnvironment( )

Creating and Selecting a Font
To select a new font, we must first construct a Font object that describes that font. One Font constructor has this general form:
Font(String fontName, int fontStyle, int pointSize)
Here, fontName specifies the name of the desired font. The name can be specified using either the logical or face name. All Java environments will support the following fonts: Dialog, DialogInput, Sans Serif, Serif, and Monospaced. Dialog is the font used by your system’s dialog boxes. Dialog is also the default if we don’t explicitly set a font. We can also use any other fonts supported by your particular environment. The style of the font is specified by fontStyle. It may consist of one or more of these three constants: Font.PLAIN, Font.BOLD, and Font.ITALIC.
To combine styles, OR them together. For example, Font.BOLD | Font.ITALIC specifies a bold, italics style.
The size, in points, of the font is specified by pointSize.
To use a font that we have created, we must select it using, which is defined by Component. as:
void setFont(Font fontObj)
Here, fontObj is the object that contains the desired font.

Obtaining Font Information
Suppose we want to obtain information about the currently selected font. To do this, we must first get the current font by calling getFont( ). This method is defined by the Graphics class, as shown:
Font getFont( )

Once we have obtained the currently selected font, we can retrieve information about it using various methods defined by Font.

Saturday, September 21, 2013

Programming in Java: AWT classes 01

AWT classes
The Abstract Window Toolkit (AWT) contains numerous classes and methods that allow you to create and manage windows. It is also the foundation upon which Swing is built. The AWT classes are contained in the java.awt package. It is one of Java’s largest packages. Although a common use of the AWT is in applets, it is also used to create stand-alone windows that run in a GUI environment, such as Windows.

Window Fundamentals
Window Hierarchy
The two most common windows are those derived from Panel, which is used by applets, and those derived from Frame, which creates a standard application window. Figure shows the class hierarchy for Panel and Frame.
A short description of these classes is given below:

Component
At the top of the AWT hierarchy is the Component class. Component is an abstract class that encapsulates all of the attributes of a visual component. All user interface elements that are displayed on the screen and that interact with the user are subclasses of Component. A Component object is responsible for remembering the current foreground and background colours and the currently selected text font.

Container
The Container class is a subclass of Component. It has additional methods that allow other Component objects to be nested within it. A container is responsible for laying out (that is, positioning) any components that it contains. It does this through the use of various layout managers.

Panel
The Panel class is a concrete subclass of Container. It doesn’t add any new methods; it simply implements Container. Panel is the superclass for Applet. When screen output is directed to an applet, it is drawn on the surface of a Panel object.  In essence, a Panel is a window that does not contain a title bar, menu bar, or border.
Other components can be added to a Panel object by its add( ) method (inherited from Container). Once these components have been added, you can position and resize them manually using the setLocation( ), setSize( ), setPreferredSize( ), or setBounds( ) methods defined by Component.

Window
The Window class creates a top-level window. A top-level window is not contained within any other object; it sits directly on the desktop. Generally, you won’t create Window objects directly. Instead, you will use a subclass of Window called Frame.

Frame
Frame encapsulates what is commonly thought of as a “window.” It is a subclass of Window and has a title bar, menu bar, borders, and resizing corners.

Creating Frame window
The following are the three steps to be followed in creating any Frame window:
1.      Create an object of any class derived from Frame
2.      Set the dimensions of the window using the object created
3.      Set the visibility of the window

Creating the Object
First we need to create a class extending Frame. Then the object of this class needs to be created from the main method. Here are two of Frame’s constructors:
Frame( )
Frame(String title)
The first form creates a standard window that does not contain a title. The second form creates a window with the title specified by title. They can be used in the constructor of our class using super().

Setting the dimensions
The setSize( ) method is used to set the dimensions of the window. Its signature is shown here:
void setSize(int newWidth, int newHeight)
void setSize(Dimension newSize)
The new size of the window is specified by newWidth and newHeight, or by the width and height fields of the Dimension object passed in newSize. The dimensions are specified in terms of pixels.
The getSize( ) method is used to obtain the current size of a window. Its signature is shown here:
Dimension getSize( )
This method returns the current size of the window contained within the width and height fields of a Dimension object.

Setting the visibility
After a frame window has been created, it will not be visible until you call setVisible( ).
Its signature is shown here:
void setVisible(boolean visibleFlag)
The component is visible if the argument to this method is true. Otherwise, it is hidden.

Setting a Window’s Title
You can change the title in a frame window using setTitle( ), which has this general form:
void setTitle(String newTitle)
Here, newTitle is the new title for the window.

Closing a Frame Window
When a Frame window is closed it can be removed from the screen by calling setVisible(false). But this does not close the window instead makes it invisible.
To intercept a window-close event, we need to implement the windowClosing() method of the WindowListener interface.
Inside windowClosing(), the program can be terminated by calling System.exit(0).
The example below illustrates this.

Simple Frame Example:
import java.awt.*;
import java.awt.event.*;

class Frame1 extends Frame implements WindowListener{
    Frame1(){
                  super();
    }
    Frame1(String title){
                  super(title);
                  setSize(800,400);                     // Set dimensions
                  setVisible(true);                       // Set Visibility
                  addWindowListener(this);
    }

    /* **Implement all the methods of WindowListener Interface** */
    public void windowClosing(WindowEvent we){
                  System.exit(0);
    }
    public void windowActivated(WindowEvent we){
    }
    public void windowClosed(WindowEvent we){
    }
    public void windowDeactivated(WindowEvent we){
    }
    public void windowIconified(WindowEvent we){
    }
    public void windowDeiconified(WindowEvent we){
    }
    public void windowOpened(WindowEvent we){
    }
}

class Frame1Demo{
    public static void main(String[] args){
                  Frame1 f1 = new Frame1("My First Frame");
    }

}

This program can be compiled and run like any other java program. When run it produces the following output.

Handling events
Since Frame is a subclass of Component, it inherits all the capabilities defined by Component. This means that you can use and manage a frame window just like you manage an applet’s main window. For example, you can override paint( ) to display output, call repaint( ) when you need to restore the window, and add event handlers.

Following example demonstrates this:
import java.awt.*;
import java.awt.event.*;

class FrameEvent2 extends Frame{
         String msg = "Welcome";
    FrameEvent2(){
    }
    FrameEvent2(String title){
                  super(title);
                  addWindowListener(new MyWindowAdapter());
                  addMouseListener(new MyMouseListener(this));
                  setSize(600,300);
                  setVisible(true);
                  repaint();
    }
    public void paint(Graphics g){
                  g.drawString(msg,300,150);
    }
}

class FrameEventDemo{
    public static void main(String[] args){
                  FrameEvent2 fe1 = new FrameEvent2("Frame Events Demo");
    }
}

class MyWindowAdapter extends WindowAdapter{
    MyWindowAdapter(){
    }
    public void windowClosing(WindowEvent we){
                  System.exit(0);
    }
}

class MyMouseListener implements MouseListener{
    FrameEvent2 fr;
    MyMouseListener(FrameEvent2 f){
                  fr = f;
    }
    public void mouseClicked(MouseEvent me){
                  fr.msg = "Mouse Clicked";
                  fr.repaint();
    }
         public void mouseEntered(MouseEvent me){
                  fr.msg = "Mouse Entered";
                  fr.repaint();
         }
         public void mouseExited(MouseEvent me){
                  fr.msg = "Mouse Exited";
                  fr.repaint();
         }
         public void mousePressed(MouseEvent me){
                  fr.msg = "Mouse Pressed";
                  fr.repaint();
         }
         public void mouseReleased(MouseEvent me){
                  fr.msg = "Mouse Released";
                  fr.repaint();
         }
}
The above code creates a Frame window which detects the user’s mouse actions and displays the appropriate message. Here we have used four classes. 
FrameEvent2: which is derived from Frame. This represents our window.
FrameEventDemo: which contains the main() method. This method just creates an object of the FrameEvent2 class.
MyMouseListener:The class that implements the MouseListener Interface. All mouse events are handled by this class. We can see the statement addMouseListener(new MyMouseListener(this)); Here we register the Mouse Listener saying that the methods are implemented in MyMouseListener class. this is passed as an argument to the constructor of MyMouseListener because we need an object of the current frame window to call the repaint() method of that window.
MyWindowAdapter: This class is used to implement the windowClosing() method so that the window gets closed when user tries for it.


The output of the above program is:


Tuesday, September 17, 2013

Web Fundamentals

History of the Internet


The invention of the telegraph, telephone, radio, and computer set the stage for the unprecedented revolution of communication. The Internet is at once a world-wide broadcasting capability. The Internet today is a widespread information infrastructure, the initial prototype of what is often called the National (or Global or Galactic) Information Infrastructure. Its history is complex and involves many aspects - technological, organizational, and community. And its influence reaches not only to the technical fields of computer communications but throughout society.
The first recorded description of the social interactions that could be enabled through networking was a series of memos written by J.C.R. Licklider of MIT in August 1962 discussing his "Galactic Network" concept. He envisioned a globally interconnected set of computers through which everyone could quickly access data and programs from any site.  Licklider was the first head of the computer research program at DARPA, starting in October 1962. The public was first introduced to the concepts that would lead to the Internet when a message was sent over the ARPANet from computer science Professor Leonard Kleinrock's laboratory at University of California, after the second piece of network equipment was installed at Stanford Research Institute (SRI). By the end of 1969, four host computers were connected together into the initial ARPANET, and the budding Internet was off the ground.
Computers were added quickly to the ARPANET during the following years, and work proceeded on completing a functionally complete Host-to-Host protocol and other network software. Packet switched networks such as ARPANET were developed in the late 1960s and early 1970s using a variety of protocols. The ARPANET in particular led to the development of protocols for internetworking, in which multiple separate networks could be joined together into a network of networks.
In 1982, the Internet protocol suite (TCP/IP) was standardized, and consequently, the concept of a world-wide network of interconnected TCP/IP networks, called the Internet, was introduced. Access to the ARPANET was expanded in 1981 when the National Science Foundation (NSF) developed the Computer Science Network (CSNET) and again in 1986 when NSFNET provided access to supercomputer sites in the United States from research and education organizations. Commercial Internet service providers (ISPs) began to emerge in the late 1980s and early 1990s. The ARPANET was decommissioned in 1990. The Internet was commercialized in 1995 when NSFNET was decommissioned, removing the last restrictions on the use of the Internet to carry commercial traffic.
Since the mid-1990s, the Internet has had a revolutionary impact on culture and commerce, including the rise of near-instant communication by electronic mail, instant messaging, Voice over Internet Protocol (VoIP) "phone calls", two-way interactive video calls, and the World Wide Web with its discussion forums, blogs, social networking, and online shopping sites. The research and education community continues to develop and use advanced networks such as NSF's very high speed Backbone Network Service (vBNS), Internet2, and National LambdaRail. Increasing amounts of data are transmitted at higher and higher speeds over fibre optic networks operating at 1-Gbit/s, 10-Gbit/s, or more. The Internet's takeover over the global communication landscape was almost instant in historical terms: it only communicated 1% of the information flowing through two-way telecommunications networks in the year 1993, already 51% by 2000, and more than 97% of the telecommunicated information by 2007. Today the Internet continues to grow, driven by ever greater amounts of online information, commerce, entertainment, and social networking.

Basic Services
Some of the basic services available to Internet users are:
  • Email: A fast, easy, and inexpensive way to communicate with other Internet users around the world.
  • Telnet: Allows a user to log into a remote computer as though it were a local system.
  • FTP: Allows a user to transfer virtually every kind of file that can be stored on a computer from one Internet-connected computer to another.
  • Usenetnews: A distributed bulletin board that offers a combination news and discussion service on thousands of topics.
  • World Wide Web (WWW): A hypertext interface to Internet information resources.
  • Social Networking
  • E Commerce
  • Online examinations
Search engines
Search engines are the primary tools people use to find information on the web. Today, you perform searches with keywords, but the future of web search will use natural language. Currently, when you enter a keyword or phrase, the search engine finds matching web pages and show you a search engine results page (SERP) with recommended web pages listed and sorted by relevance. People-assisted search engines have also emerged, such as Mahalo, which pays people to develop search results.
A search engine operates in the following order:
  • Web crawling
  • Indexing
  • Searching
Web search engines work by storing information about many web pages, which they retrieve from the page's HTML. These pages are retrieved by a Web crawler (sometimes also known as a spider) — an automated Web browser which follows every link on the site. The contents of each page are then analysed to determine how it should be indexed (for example, words can be extracted from the titles, page content, headings, or special fields called meta tags).
Data about web pages are stored in an index database for use in later queries. The index helps find information relating to the query as quickly as possible. When a user enters a query into a search engine (typically by using keywords), the engine examines its index and provides a listing of best-matching web pages according to its criteria, usually with a short summary containing the document's title and sometimes parts of the text.
Currently Google is the leading search engine followed by Yahoo and Microsoft.

Google Search
Google is the leading search and online advertising company, founded by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University. Google’s success in search is largely based on its PageRank algorithm (patented by Larry Page) and its unique infrastructure of servers that uses linked PCs to achieve faster responses and increased scalability at lower costs. Estimates on the number of Google servers range over one million.
The PageRank algorithm considers the number of links into a web page and the quality of the linking sites (among other factors) to determine the importance of the page.
In addition to its regular search engine, Google offers speciality search engines for images, news, videos, blogs and more.

Vertical search engines
Vertical search engines are specialists (focusing on specific topics) in comparison to generalists like Google and Yahoo. They enable us to search for resources in a specific area, with the goal of providing you with a smaller number of more relevant results.

Location-based search

Location-based search (offered by most major search engines as well as some smaller specialized ones) uses geographic information about the searcher to provide more relevant search results. For example, search engines can ask the user for a ZIP code or estimate the user’s general location based on IP address. The engine can then use this information to give higher priority to search results physically located near the user. This is particularly useful when searching for businesses such as restaurants or car services.

e-mail
One of the most popular Internet services is electronic mail (e-mail). At the beginning of the Internet era, the messages sent by electronic mail were short and consisted of text only; they let people exchange quick memos. Today, electronic mail is much more complex. It allows a message to include text, audio, and video. It also allows one message to be sent to one or more recipients.
An e-mail system has three main components: user agent, message transfer agent, and message access agent.
User Agent: It provides service to the user to make the process of sending and receiving a message easier. A user agent is a software package (program) that composes, reads, replies to, and forwards messages. It also handles mailboxes.
Message Transfer Agent: The actual mail transfer is done through message transfer agents. The process of transferring a mail message occurs in three phases: connection establishment, mail transfer, and connection termination. It uses SMTP protocol.
Message Access Agent: Mail access starts with the client when the user needs to download e-mail from the mailbox on the mail server. The client opens a connection to the server on TCP port. It then sends its user name and password to access the mailbox. The user can then list and retrieve the mail messages, one by one. it uses protocols like POP3, IMAP etc.
Web-Based Mail
E-mail is such a common application that some websites today provide this service to anyone who accesses the site. Two common sites are Gmail, Hotmail and Yahoo. Mail transfer from browser to mail server is done through HTTP.

WWW
The World Wide Web (abbreviated as WWW or W3, commonly known as the web) is a system of interlinked hypertext documents accessed via the Internet. A broader definition comes from the organization that Web inventor Tim Berners-Lee helped found, the World Wide Web Consortium (W3C):
The World Wide Web is the universe of network-accessible information, an embodiment of human knowledge.
The WWW project was initiated by CERN (European Laboratory for Particle Physics) to create a system to handle distributed resources necessary for scientific research.
The WWW today is a distributed client-server service, in which a client using a browser can access a service using a server. However, the service provided is distributed over many locations called sites. Each site holds one or more documents, referred to as Web pages. Each Web page can contain a link to other pages in the same site or at other sites. The pages can be retrieved and viewed by using browsers.
In simple terms, The World Wide Web is a way of exchanging information between computers on the Internet, tying them together into a vast collection of interactive multimedia resources.

Web Server
Web servers is a specialized software that responds to client requests (typically from a web browser) by providing resources such as HTML/XHTML documents. For example, when users enter a Uniform Resource Locator (URL) address, such as graduatingcs.blogspot.in, into a web browser, they are requesting a specific document from a web server. The web server maps the URL to a resource on the server (or to a file on the server’s network) and returns the requested resource to the client. During this interaction, the web server and the client communicate using the platform-independent Hypertext Transfer Protocol (HTTP), a protocol for transferring requests and files over the Internet.
Multitier Application Architecture
Web-based applications are multitier applications that divide functionality into separate tiers (i.e., logical groupings of functionality). Although tiers can be located on the same computer, the tiers of web-based applications often reside on separate computers. Figure presents the basic structure of a three-tier web-based application.
3 Tier Architecture
The bottom tier (also called the data tier or the information tier) maintains the application’s data. This tier typically stores data in a relational database management system (RDBMS). They may reside on one or more computers.
The middle tier implements business logic, controller logic and presentation logic to control interactions between the application’s clients and its data. The middle tier acts as an intermediary between data in the information tier and the application’s clients. The middle-tier controller logic processes client requests and retrieves data from the database. The middle-tier presentation logic then processes data from the information tier and presents the content to the client. Web applications typically present data to clients as XHTML documents.
Business logic in the middle tier enforces business rules and ensures that data is reliable before the application updates a database or presents data to users. Business rules dictate how clients access data, and how applications process data. For example, a business rule in the middle tier of a retail store’s web-based application might ensure that all product quantities remain positive. A client request to set a negative quantity in the bottom tier’s product information database would be rejected by the middle tier’s business logic.

The top tier, or client tier, is the application’s user interface, which gathers input and displays output. Users interact directly with the application through the user interface, which is typically a web browser, keyboard and mouse, or a mobile device. In response to user actions (e.g., clicking a hyperlink), the client tier interacts with the middle tier to make requests and to retrieve data from the information tier. The client tier then displays the data retrieved for the user. The client tier never directly interacts with the information tier.

The Apache HTTP Server
The Apache HTTP Server, commonly referred to as Apache, is a web server software program playing a key role in the growth of the World Wide Web. Apache has consistently been the most popular web server on the Internet since 1996. Typically Apache is run on a Unix-like operating system, and was developed for use on Linux.
Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation. The application is available for a wide variety of operating systems, including Unix, Linux, Solaris, Novell NetWare, Microsoft Windows etc. Released under the Apache License, Apache is open-source software.
Since April 1996 Apache has been the most popular HTTP server software in use. As of June 2013, Apache was estimated to serve 54% of all active websites.
Apache supports a variety of features, many implemented as compiled modules which extend the core functionality.  These can range from server-side programming language support to authentication schemes like password authentication. It also features configurable error messages. Some common language interfaces supported are Perl, Python and PHP.

Internet Information Services (IIS)
Internet Information Services (IIS) – formerly called Internet Information Server – is a Microsoft web server software application created by Microsoft for use with Microsoft Windows. IIS 7.5 supports HTTP, HTTPS, FTP, FTPS, SMTP and NNTP. It is part of certain editions of Windows XP, Windows Vista and Windows 7. IIS is not turned on by default. The IIS Manager is accessed through the Administrative Tools in the Control Panel.
All versions of IIS prior to 7.0 running on client operating systems supported only 10 simultaneous connections and a single web site.
With IIS 8 you can share information with users on the Internet, an intranet, or an extranet. IIS 8 is a unified web platform that integrates IIS, ASP.NET, FTP services, PHP, and Windows Communication Foundation (WCF).

IIS is the second most popular web server in the world with 20% market share.

Protocols
In computer networks, communication occurs between entities in different systems. An entity is anything capable of sending or receiving information. However, two entities cannot simply send bit streams to each other and expect to be understood. For communication to occur, the entities must agree on a protocol. A protocol is a set of rules that govern data communications. A protocol defines what is communicated, how it is communicated, and when it is communicated.

The key elements of a protocol are syntax, semantics, and timing.


  • Syntax: The term syntax refers to the structure or format of the data, meaning the order in which they are presented.
  • Semantics: The word semantics refers to the meaning of each section of bits. How is a particular pattern to be interpreted, and what action is to be taken based on that interpretation?
  • Timing: The term timing refers to two characteristics: when data should be sent and how fast they can be sent.

Hyper Text Transfer Protocol (HTTP)
The Hypertext Transfer Protocol (HTTP) is a protocol used mainly to access data on the World Wide Web. HTTP functions as a combination of FTP and SMTP. The client initializes the transaction by sending a request message. The server replies by sending a response. A request message consists of a request line, a header, and sometimes a body. A response message consists of a status line, a header, and sometimes a body.

File Transfer Protocol (FTP)
File Transfer Protocol (FTP) is the standard mechanism provided by TCP/IP for copying a file from one host to another. Transferring files from one system to another need to deal with some problems. For example, two systems may use different file name conventions. Two systems may have different ways to represent text and data. Two systems may have different directory structures. All these problems have been solved by FTP in a very simple and elegant approach.
FTP differs from other client/server applications in that it establishes two connections between the hosts. One connection is used for data transfer, the other for control information (commands and responses). Separation of commands and data transfer makes FTP more efficient.
We need to transfer only a line of command or a line of response at a time. The data connection, on the other hand, needs more complex rules due to the variety of data types transferred.
The control connection remains connected during the entire interactive FTP session. The data connection is opened and then closed for each file transferred. It opens each time commands that involve transferring files are used, and it closes when the file is transferred.

TELNET
In the Internet, users may want to run application programs at a remote site and create results that can be transferred to their local site. For example, students may want to connect to their university computer lab from their home to access application programs for doing homework assignments or projects.
TELNET is general-purpose client-server program that lets a user access any application program on a remote computer; in other words, allow the user to log on to a remote computer. After logging on, a user can use the services available on the remote computer and transfer the results back to the local computer.
TELNET is an abbreviation for TErminaL NETwork. TELNET enables the establishment of a connection to a remote system in such a way that the local terminal appears to be a terminal at the remote system.
When a user wants to access an application program or utility located on a remote machine, he performs remote log-in using a user-name and password. TELNET uses only one TCP connection. The same connection is used for sending both data and control characters. TELNET accomplishes this by embedding the control characters in the data stream.
Most TELNET implementations operate in one of three modes: default mode, character mode, or line mode.
  • Default Mode: The default mode is used if no other modes are invoked through option negotiation. In this mode, the echoing is done by the client. The user types a character, and the client echoes the character on the screen (or printer) but does not send it until a whole line is completed.
  • Character Mode: In the character mode, each character typed is sent by the client to the server. The server normally echoes the character back to be displayed on the client screen.
  • Line Mode: A new mode has been proposed to compensate for the deficiencies of the default mode and the character mode. In this mode, called the line mode, line editing (echoing, character erasing, line erasing, and so on) is done by the client. The client then sends the whole line to the server.