Beruflich Dokumente
Kultur Dokumente
Internet: the network of networks connected via the public backbone and communicating using TCP/IP
communication protocol
Global Communication Network
Commercial Internet dial-up access offered
Economic
Increase network usage
Reduced unit cost
Backbone initially supplied by NSFNET, privately funded (ISP fees) beginning in 1995
Private telecommunication firms
TCP/IP:
TCP/IP Single Protocol
TCP/IP actually two different protocols.
TCP-transport Layer IP-Network layer
Treated as one some bulk of services are built on the top of both the TCP and IP protocols
-> e-mail, Web browsing, File downloads, accessing remote databases
INTERNET PROTOCOL:
IP is the fundamental protocol defining the Internet (as the name implies!)
network
Gateway is a device that is connected to the source computers network as well as to at least one
other network.
The sequence of computers that a packet travels through from source to destination is known as
its route.
How does the computer choose the next computer in the route for a packet?
A separate protocol BGP-4 is used to pass network connectivity information between
gateways so that each computer can choose a good next hop for each packet it receives.
IP software adds error detection information ( a checksum) to each packet
Limitations of IP:
No guarantee of packet delivery (packets can be dropped)
Unreliable
Communication is one-way (source to destination)
machine.
TCP header contains port number representing an application program on the destination
computer
Some port numbers have standard meanings
Example: port 25 is normally used for email transmitted using the Simple Mail
Transfer Protocol (SMTP)
Other port numbers are available first-come-first served to any application
Assigned by IANA(Internet Assigned numbers Authority)
0-1023 requested only by the applications that are run by the system at boot-up
1024-65535 used by the first application on a system
Some examples:
SMTP (email)
FTP (file transfer)
HTTP (transfer of Web documents)
Primary TCP-based protocol used for communication between web servers and
browsers called HTTP
IP is key component in the definition of Internet
HTTP - WWW
before it
Normally implemented over a TCP connection (80 is standard port number for HTTP)
Typical browser-server interaction:
User enters Web address in browser
Browser uses DNS to locate IP address
Browser opens TCP connection to server
Browser sends HTTP request over connection
Server sends HTTP response to browser over connection
Browser displays body of response in the client area of the browser window
Value
Delim
HTTP REQUEST
Connect to 67.228.171.112 on port 80 ... ok
GET / HTTP/1.0[CRLF] ----------------start line
Host: www.stjosephs.ac.in[CRLF]
request uri
HEADER FIELDS
Connection: close[CRLF]
User-Agent: Web-sniffer/1.0.46 (+http://web-sniffer.net/) [CRLF]
Accept-Encoding: gzip[CRLF]
Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7[CRLF]
Cache-Control: no-cache[CRLF]
Accept-Language: de,en;q=0.7,en-us;q=0.3[CRLF]
Referer: http://web-sniffer.net/ [CRLF]
Each request message begins with a request line (START LINE), which contains three critical
pieces of information: After the start line come a set of message headers related to the request, followed
by a blank line and then optionally, the message body of the request as shown below
Structure of Request:
start line
header field(s)
blank line
optional body
Start line
A start line (which contains the method the client is requesting; the URI of the resource
upon which the client wishes the action to be performed and the version of HTTP that the client
is using).
Example: GET / HTTP/1.1
Three space-separated parts:
HTTP request method
Request-URI
HTTP version
Request methods:
HEAD
Used to ask only for information about a document, not for the
document itself. It's often used by clients who use caching, to see
GET
POST
PUT
DELETE
TRACE
OPTIONS
servers.
Returns the HTTP methods that the server supports for specified
URL
Request URI:
URIs are of two types:
Uniform Resource Name (URN)
Can be used to identify resources with unique names, such as books (which have
unique ISBNs)
Uniform Resource Locator (URL)
Specifies location at which a resource can be found
In addition to http, some other URL schemes are https, ftp, mailto, and file
MIME Type
text/plain
text/html
image/gif
image/jpeg
application/octet-
stream
binary.
HTTP RESPONSE :
After receiving and interpreting a request message, a server responds with an HTTP response message.
Name
Value
Server:
Last-Modified:
ETag:
"1f02cce-4644-4ec6176bf4b9f"
Accept-Ranges:
bytes
Content-Length:
17988
Connection:
close
Content-Type:
text/html
Status line: The first line of a Response message is the Status-Line, consisting of the protocol
version followed by a numeric status code and its associated textual phrase.
Example: HTTP/1.1 200 OK
It has three space-separated parts:
HTTP version
status code
reason phrase in text (intended for human use)
Status code: to display the status of the response message
is a three-digit number
Classified into five classes. First digit is class of the status code:
1xx:
Informational
2xx: Success
3xx: Redirection
and accepted
Further action must be taken in order to complete the
request
The request contains bad syntax or cannot be
5xx:
fulfilled
The server failed to fulfill an apparently valid request
Server
Error
Some common status codes:
200: OK.
302: This code indicates that a page has been temporarily redirected to another
URL. This means that the page is still active, just temporarily moved to another
URL.
403: Some of you may have come across this, also known as the Forbidden
Request. Basically it means that you have made a legal request, but the server is
refusing to respond to it.
404: The most common of the Broken Site Errors! Basically this is where the URL
no longer exists or cannot be found, so you will be redirected to a broken holding
page.
500: Just a generic Server error message, this comes up when there is nothing else
to explain a problem.
501: This is where the Server you a requesting information from does not
understand the method in which you are requesting the information, or there is not
a fulfilled request.
502: Simply an invalid response was received by the server, from the request that
you have made.
ETag
Location
old
A hash code of the resource returned
Used in redirection, or when a new resource has been
created
Server
Links:
Hyperlinks are produced by the anchor element <a>
Clicking on a hyperlink causes browser to issue GET request to URL specified in href attribute
and render response in client area
<a href="http://www.motive.co.nz">Motive</a>
<a> element called anchor. Link has two ends : anchors and direction
Anchors can be used as source (previous example) or destination
Source anchors
A source anchor is created in an HTML document (webpage) by adding an anchor
element (<a>) with a hypertext reference (href) containing a uniform resource identifier (URI).
Eg:<a href="http://www.motive.co.nz">Motive</a>
Destination anchors
To link to a point within a webpage, for example to link to content below the first fold, a
destination anchor must be added.
A destination anchor is created by adding a fragment identifier, this is either:
An anchor element, with a name attribute, or
Any other element, with an id attribute.
Eg:
<html>
<A href="#section1">Introduction</A><BR>
<A href="#section2">Some background</A><BR>
<A href="#section2.1">On a more personal note</A><BR>
..
<H2 id="section1">Introduction</H2>
...section 1...
<H2 id="section2">Some background</H2>
...section 2...
<H3 id="section2.1">On a more personal note</H3>
...section 2.1...
</html>
ABSOLUTE URL AND RELATIVE URL
Absolute URL
An Absolute URL is, thus, something that is independent or free from any relationship. When you
use an absolute URL, you point directly to a file. Hence, an absolute URL specifies theexact location of a
file/directory on the internet. It also follows that each absolute URL is unique
Eg: http://www.webdevelopersnotes.com/images/email.gif
specifies an image file email.giflocated in the images directory, under
www.webdevelopersnotes.com domain name.
Relative URL
A relative URL points to a file/directory in relation to the present file/directory
XHTML DTD:
XML is used to define the syntax of XHTML
Set of XML files that define a language are known as the document type definition (DTD)
DTD primarily consists of declarations:
Element type: name and content of elements
Attribute list: attributes of an element
Entity: define meaning of, e.g., >
Eg:
<!ELEMENT html (head, body)>
<!ATTLIST html
lang
NMTOKEN
xml:lang
NMTOKEN
dir
(ltr|rtl)
id
ID
xmlns
CDATA
<!ENTITY gt >>
#IMPLIED
#IMPLIED
#IMPLIED
#IMPLIED
#FIXED 'http://www.w3.org/1999/xhtml' >
1) Element type:
Used to specify the set of all valid elements in the language defined by DTD
Eg: <!ELEMENT element-name (element-content)(iterators)>
Content Specification:
Eg:
<!ELEMENT html (head, body)>
<!ELEMENT br EMPTY>
-> Sequence
-> Empty
Eg:
<!ELEMENT select (option|optgroup)*>
2) Attribute List Declaration:
NMTOKEN
NMTOKEN
(ltr|rtl)
ID
CDATA
#IMPLIED
#IMPLIED
#IMPLIED
#IMPLIED
#FIXED 'http://www.w3.org/1999/xhtml' >
Eg 1:
<!ATTLIST person number CDATA #REQUIRED>
Valid XML:
<person number="5677" />
Invalid XML:
<person />
Eg 2:
<!ATTLIST sender company CDATA #FIXED "Microsoft">
Valid XML:
<sender company="Microsoft" />
Invalid XML:
<sender company="W3Schools" />
3) ENTITY DECLARATION:
<!ENTITY %lang
NMTOKEN>
Eg:
<p> if a>b </p>-> Prints a>b
UNIT-2
SELECTOR STRING:
Selector Strings
Type selector :Each of the selector simply the name of an element type
h1,h2,h3,h4,h5,h6 { background-color : purple }
Universal selector : Every possible element type
* { font-weight : bold }
ID selector :
#p1, #p3 { background-color : aqua }
<p id="P1" class="takeNote">
Paragraph with id="P1" and class="takeNote".
</p>
.
.
.
<p id="p3">
This paragraph (id="p3") contains a
<a href="http://www.example.net">hyperlink</a>.
Class selector :
#p1, .takeNote { font-style : italic }
span.special { font-size : x-large }
The difference between an ID and a class is that an ID can be used to identify one
element, whereas a class can be used to identify more than one.
Descendant selector : used to select elements that are descendants of another element in the
document tree.
ul span { font-variant : small-caps }
ul ol li { letter-spacing : lem }
<head>
<link rel="stylesheet" type="text/css" href="ext.css"/><!-- Links External Style Sheet ext.css-->
</head>
<body>
<h1>EXTERNAL STYLE SHEET</h1>
<h3>a white header</h3>
<ul class="b">
<li>liststyletype-circle</li>
<li>liststyletype-circle</li>
<li>liststyletype-circle</li>
</ul>
<ol class="c">
<li>upper-roman</li>
<li>upper-roman</li>
</ol>
<ol class="d">
<li>lower_alpha</li>
<li>lower_alpha</li>
</ol>
<p class="date">
This paragraph has a blue font .the back ground colour is green because of external style sheet</p>
</body>
</html>
INTERNAL.HTML
<html>
<head>
<style>
body{background-color:grey;}
p{color:white;}
ul.a {list-style-type: circle;}
ul.b {list-style-type: square;}
#p1{font-family:"Times New Roman",Times,serif;}
</style>
</head>
<body><!--Type Selector-->
<center>
<h2>INTERNAL STYLE SHEET</h2>
</center>
<ul class="b"><!--Desendent Selector Element ul followed by class (.b)-->
<li>liststyletype:square</li>
<li>liststyletype:square</li>
</ul>
<p id="p1">This page USES internal css using style tag</p><!-- ID Selector-->
</body>
</html>
INLINE.HTML
<html>
<head>
<title>inline css</title>
</head>
<BODY style="background-color:red";><!-- INLINE Stylesheet style keyword as an attribute-->
<center>
<h2>INLINE STYLE SHEET</h2>
</center>
<p style="color:blue;margin-left:20px"><!-- INLINE Stylesheet style keyword as an attribute-->
This page uses inline css using style attribute<BR/>
Inline Style Sheet has the highest priority amomg all style sheets<BR/>
Text color is blue and margin left width is 20px.
</p>
</body>
</html>
STYLE RULE CASCADING:
*{ font-weight : bold } applies to every element of HTML
#p1, #p3 { background-color : aqua }
#p3{ font-weight : normal }
What if more than one style declaration applies to a property of an element?
Multiple declaration
Browser applies rule cascading
A multistage sorting process that selects a single declaration that supply the property value
The CSS rule cascade determines which style rules declaration applies
Once declaration identified, associate origin and weight with every declaration
o PERSON WHO WROTE THE DOCUMENT
style options
o User can explicitly create a style sheet file the browser will input when it is started
o Features provided by IE6
o Tools|Internet Options
Two weight values
o Normal
o Important
User/important highest priority in CSS to accommodate users with special needs
o Rules made important by adding !important:
Cascading order
What style will be used when there is more than one style specified for an HTML element?
All the styles will "cascade" into a new "virtual" style sheet by the following rules, where number
four has the highest priority:
Browser default
External style sheet
Internal style sheet (in the head section)
Inline style (inside an HTML element)
So, an inline style (inside an HTML element) has the highest priority, which means that it
will override a style defined inside the <head> tag, or in an external style sheet, or in a browser (a
default value).
Note: If the link to the external style sheet is placed after the internal style sheet in HTML
<head>, the external style sheet will override the internal style sheet!
STYLE INHERITANCE:
Cascading based on structure of style sheets
Inheritance based on tree structure of document
What if no style declaration applies to a property of an element?
Generally, the property value is inherited from the nearest ancestor element that has a value forthe
property
If no ancestor has a value (or the property does not inherit) then CSS defines an initial value that
is used
Property values:
o Specified: value contained in declaration
Absolute: value can be determined without reference to context (e.g., 2cm)
Relative: value depends on context (e.g., larger)
o Computed: browser performs calculation depends on particular relative value
o absolute representation of relative value (e.g., larger might be 1.2 x parent font size)
o Actual: value actually used by browser (e.g., computed value might be rounded)
CSS property names corresponding to 12 distances between adjacent edges in the box model
BORDER:
p.pos_fixed
{
position:fixed;
top:30px;
right:5px;}
Note: Internet Explorer supports the fixed value only if a !DOCTYPE is specified.Fixed positioned
elements are removed from the normal flow. The document and other elements behave like the fixed
positioned element does not exist. Fixed positioned elements can overlap other elements.
Relative Positioning
A relative positioned element is positioned relative to its normal position.
Example
h2.pos_left
{
position:relative;
left:-20px;
}
h2.pos_right
{
position:relative;
left:20px;
}
The content of a relatively positioned elements can be moved and overlap other elements, but the reserved
space for the element is still preserved in the normal flow.
Example
h2.pos_top
{
position:relative;
top:-50px;
}
Relatively positioned element are often used as container blocks for absolutely positioned elements.
Absolute Positioning
An absolute position element is positioned relative to the first parent element that has a Position other
than static. If no such element is found, the containing block is <html>: Example
h2
{
position:absolute;
left:100px;
top:150px;
}
Absolutely positioned elements are removed from the normal flow. The document and other elements
behave like the absolutely positioned element does not exist.Absolutely positioned elements can overlap
other elements.
Float positioning
Float property none, left, and right
Moves the element box to far left or right
OBJECTS:
Array notation
To print the values of those properties
The JavaScript object dot notation is actually shorthand for a more general associative array
notation in which Strings are array indices:
Expressions can supply property names:
Two different notations for accessing properties
Dot notation
Array reference syntax index is viewed as string value hash
Object can be viewed as a sort of array in which the elements are indexed by strings called
associative array
Object reference
StringBuffer s1 = new StringBuffer(Hello);
StringBuffer s2 = s1;
Single StringBuffer is created and both s1 and s2 will be references to it
Copies the reference from s1 to s2
If code followed by s2. append(World!);
System.out.println(s1);
Output: Hello World!.
Methods
JavaScript functions are stored as values of type Object
A function declaration creates a function value and stores it in a variable (property of
window) having the same name as the function
A method is an object property for which the value is a function
ARRAY
An array is a special variable, which can hold more than one value at a time.
If you have a list of items (a list of car names, for example), storing the cars in single variables
could look like this:
var car1 = "Saab";
var car2 = "Volvo";
var car3 = "BMW";
Creating an Array
Using an array literal is the easiest way to create a JavaScript Array.
Syntax:
var array-name = [item1, item2, ...];
Example:
var cars = ["Saab", "Volvo", "BMW"];
Using the JavaScript Keyword new
The following example also creates an Array, and assigns values to it:
Example:
var cars = new Array("Saab", "Volvo", "BMW");
Access the Elements of an Array
You refer to an array element by referring to the index number.
This statement access the value of the first element in myCars:
var name = cars[0];
This statement modifies the first element in cars:
cars[0] = "Opel";
Note [0] is the first element in an array. [1] is the second. Array indexes start with 0.
Different Objects in One Array
JavaScript variables can be objects. Arrays are special kinds of objects.
Because of this, you can have variables of different types in the same Array.
You can have objects in an Array. You can have functions in an Array. You can have arrays in an
Array:
myArray[0] = Date.now;
myArray[1] = myFunction;
myArray[2] = myCars;
Arrays are Objects
Arrays are a special type of objects. The typeof operator in JavaScript returns "object" for
arrays.But, JavaScript arrays are best described as arrays. Arrays use numbers to access its
"elements". In this example, person[0] returns John:
Array: var person = ["John", "Doe", 46];
Object: var person = {firstName:"John", lastName:"Doe", age:46};
Array Properties and Methods
The real strength of JavaScript arrays are the built-in array properties and methods:
Examples
var x = cars.length;
// The length property returns the number of elements in cars
var y = cars.sort();
// The sort() method sort cars in alphabetical order
The length Property
The length property of an array returns the length of an array (the number of array
elements).Example
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.length;
// the length of fruits is 4
Adding Array Elements
The easiest way to add a new element to an array is to use the length property:
Example
</form>
</body>
</html>
Regular Expression:
1. Checking first char is a digit
Var name=3abc;
var re=new RegExp("^[0-9]");
if(re.test(name))
{
xyz.innerText="User name should not start with a digit";
f1=0;
}
2. Checking valid email id
Var name=aa@a.c;
var re2=new RegExp("/^[a-zA-Z0-9][a-zA-Z0-9-_\s]+@[a-zA-Z0-9-\s].+\.[a-zA-Z]{2,5}$/");
if(!re2.test(name))
{
def.innerText="invalid id";
f1=0;
}
3. Checking given i/p is number.
Var name=abc;
var ae=new RegExp("[0-9]");
if(!ae.test(name))
{
hij.innerText="Field should contain only number";
f1=0;
}
4. Checking given i/p is CHAR.
Var name=123;
var ae=new RegExp("^[a-zA-Z ]");
if(!ae.test(name))
{
hij.innerText="Field should contain only char";
f1=0;
}