You are on page 1of 10

W.E.B! 1. Explain the following: a) Internet The Internet is a huge collection of computers connected in a communications network.

These computers are of every imaginable size, configuration, and manufacturer. Transmission control protocol / Internet protocol (TCP/IP) is the single low level protocol, which allows these devices to communicate with each other. It provides a low level interface that allows all computers connected to the Internet as exactly the same. Instead of connecting every computer to every other, these devices are connected to each other locally, and only one node on this network is physically connected to the Internet. So, the Internet is actually a network of networks. b)MIME MIME = Multipurpose Internet Mail Extensions. A browser needs to determine the format of a document it receives from a web server. The forms of these documents are specified with the MIME. MIME was developed to allow different kinds of documents to be sent through internet mail. A web server attaches the MIME format document specification at the beginning of the document that it is about to provide to a browser. MIME specifications have the following form: type/subtype c)www www= World Wide Web. The Web is a collection of softwares and protocols that has been installed in most, if not all of the computers on the internet. Internet is still useful without the web, but most of the internet use now is through the web. d)URL Uniform Resource Locators. URLs are used to identify documents on the internet. There are different kinds of resources identified by different forms of URLs. All URLs have the same general format: scheme:object-address Scheme is often a communications protocol. Ex: http, ftp,file, telnet,mailto, etc. HTTP is used to support the web. File means the document is residing in the machine running the web browser. The hostname is the name of the server computer that stores the document. The default port number of the web server process is 80 in such host systems. URLs can never have embedded spaces attached.

2. What is HTTP? Briefly explain HPPT phases. HTTP: Hyper Text Transfer Protocol. All web communications transactions use HTTP as the main protocol. The current version of HTTP is 1.1. HTTP consists of two phases, the request and the response. Each HTTP between a browser and a web server consists of two parts: header and the body. Header contains the information of the communication and the body contains the data. A) THE REQUEST PHASE.

Among the above methods, get and post are the most commonly used. Following the first line of the HTTP communication is a number of header fields, most of which are optional. The format of the field is the field name followed by a colon and the value of the field. The header of a request should be separated by a blank line, which is used to separate the header from the body of the request. Requests that use GET, HEAD and DELETE do not have bodies. Telnet can also be used to communicate with a web server instead of a browser. THE RESPONSE PHASE:

The status line includes HTTP version used, a 3 digit status code for the response, and a short textual explanation of the status code. The status codes begin with 1, 2, 3, 4, or 5. The general meanings of the codes are 1: Informational, 2: Success, 3: Redirection, 4: Client error, 5:

Server error. One of the most common status error codes is 404: Not found, which means the file cannot be found on the server. 500 means the server has encountered a problem and was not able to fulfill the request. The response headers must be followed by a blank line, 3. a) Briefly explain the most commonly used tools in web programming. The most commonly used tools are XHTML, XML, JavaScript, Java, Perl, PHP, and Ruby. Ajax which is a web technology uses Javascript and XML. Rails is a development framework for web based database access systems. Web programs or scripts are divided into two categories based on where they are executed/interpreted: server side, and client side. XHTML and XML are client side languages. Perl, PHP, Ruby are server side languages. JavaScript and Java can be used for both. OVERVIEW OF XHTML -XHTML is not a programming language, it cannot be used for computations. -Its purpose is to describe the general form and layout of documents to be displayed in the browser. -An XHTML document is a mixture of content and controls. -The controls are specified by the tags of XHTML. -The name of a tag specifies the category of its content. -Most tags contain a pair of syntatic markers. Ex: <p> and </p> for a paragraph. XML -XML(eXtensible Markup Language) is a simplified version of Standard Generalized markup language (SGML). -XHTML is defined using XML. XHTML users must use a predefined set of tags and attributes, when a user creates his or her own markup language using XML. -XML based markup languages describe data and its meaning through their individualized tags and attributes. It does not specify any presentation details. -The great advantage of XML is that application programs can be written to use the meanings of the tags given in the to find specific kinds of data and process it accordingly. This greatly simplifies development of application programs that process data in XML. JAVASCRIPT -JavaScript is a client side scripting language whose primary uses in web programming are to validate form data and to create dynamic XHTML documents. -JavaScript programs are usually embedded in the xhtml documents. -One of the most important application of javascript is to dynamically create and modify documents. JAVA -Java is based on C++ but differs from it in several ways. -Java was designed by sun Microsystems, which controls its continuing development. -Rather than running java programs on the web server to provide computational capabilities, a special kind of java program called an applet can be resident on the server, but a compiled version of the applet can be downloaded on to the browser, when requested by a xhtml document. -Compiled java is represented in an idealized machine language called the bytecode. -Java can also be used as a server side scripting language.

PERL -CGI is a standard way in which a browser and a server communicate to run a program on the server and and return the output to the browser. The most commonly used programming language for CGL is perl. -Perl is highly portable and has several capabilities that are needed for this kind of programming. -Features of perl: CGI capabilities, direct access to operating system functions, powerful character string pattern matching functions, and its ability to include database operations. -Perl's syntax is similar to C but its code is not compiled to a machine level language, instead it is compiled into an intermediate language and interpreted. PHP -PHP is a server side scripting language specifically designed for web applications. -PHP code is embedded in XHTML documents. -The code however is interpreted on the server before the XHTML document is delivered to the user. -The browser never sees a PHP code! -PHP is very similar to javascript. Both of them use dynamic data typing. -PHP allows simple access to XHTML form data, so form processing is easy with PHP. //page 26 RUBY RAILS AJAX b) Write a note on std XHTML document statement. -Every XHTML document must begin with an xml declaration element that simply identifies the document as being one based on XML. This element includes an attribute that includes a version number, and encoding. Ex: <?xml version=1.0 encoding=utf-8 ?> -Immediately following this declaration is an SGML doctype command. The most commonly used one is:

-XHTML tags must include four tags, <html>,<head>,<title>,and <body>. -Therefore every xhmtl document consists of two parts, head and body. The head part contains the information about the document rather than its content. All content is stored in the body part. 4. Explain the following xhtml tags: a) Block quote Sometimes we want a block of the text to be set off from the normal flow of text in the document. The <blockquote> tag is designed for this situation. The content of this tag is made to look different from the rest of the text. b) sub & sup Subscripts and superscripts can be identified by <sub> and <sup> tags respectively.

c) meta The meta element is used to provide additional information about a document. It has no content, rather all of the information is specified through attributes. The two attributes used to provide information are name and content. Ex: <meta name=keywords content= binary trees, linked lists, stacks /> d) img The image tag, <img /> which is the inline tag, specifies an image that is to appear in a document. Most commonly, it has two attributes, src which his the file containing the image and alt which shows the alternate text to be displayed when the image can't load. Two optional tags are width and height which can be included to specify the size of the image in pixels. e) hypertext links -Links can be either addresses to a file or a complete URL itself. Links are specified as an attribute of an anchor tag <a>, which is an inline tag. -for creating links, only one tag <href> is required. The value assigned to href specifies the target of the link. 5. What are the three categories of perl variables? Explain them briefly with an example. PERL has 3 categories of variables: scalars, arrays, and hashes. Each are identified by the first characters in their names. SCALARS ($) -Scalars can store 3 different kinds of values: numbers, character strings, and references. -Numeric values are stored in double precision floating point numbers. -Integer literals can be written in hexadecimal by preceding 1st digit with 0x. -Strings can be either single quoted or double quoted. Single quoted strings cannot include escape charecters. -Double quoted strings can have escape characters and have embedd variable names. -Null string: '' or . The names of scalar variables begin with a $. -no limit for the length of the variable name. -letters are case sensitive. ARRAYS (@) -Used to denote a variable that stores lists. -Ex:

-in case of array assignments, a new array is created. -If an array is used in a scalar context, the length of the array is used. -Subscripts [value] can be used to access individual elements in an array. HASHES(%) -The two major differences between arrays and hashes are: 1. arrays use numeric subscripts to address specific elements, whereas hashes use string values. 2. Elements in the arrays are ordered by subscripts, but the elements in hashes are not.

-The actual arrangement of the elements of a hash memory is determined by the internal hash function used to insert and access them. -Name of the hash variables begin with a % sign. -Arrays can also be assigned to hashes with sensible semantics. When it is done so, subsequent changes to the hash will not affect the array. 6. Explain the following w.r.t perl a) pattern matching

b) file input and output Files are referenced through programs called filehandles, whose names do not begin with special charecters. They're often spelled using all upper case letters. -open function opens a file for use and assigns it to the filehandle. -files can be opened for either input or two kinds of outputs. -the first parameter of the open function is the filehandle, second specifies both the external file name and how it will be used. File's usage is specified by appending one or two of the following special charecters to the beginning of the file.

-Every file has an internal file pointer that points to the position in the file where the next read or write takes place. -Files are closed with the close function. -One line can be written to a file using print function and file handle as the first parameter. Ex: print OUTDAT The result is: $result \n; -Lines can be read using line input operator by using angled brackets for the filehandle. Ex: $next_line = <INDAT> -Multiple lines can also be read. Ex: read(filehandle, buffer, length [,offset ]); offset is optional. 7 a) explain selection and looping statements in perl. A control statement is a control statement and the block whose execution it controls. :/ -Perl's if statement is similar to other languages, only thing is it's both then or else statements must be in blocks. Ex: if($a>10) { $b=$a; } -An if construct can include elsif and else. Similarly. (NOT ELSEIF, ELSIF) -perl has an unless statement, which is the inverse of an if statement.

-While and for statements are similar to its C counterparts. The bodies of these statements must still be in blocks. -The until statement is something similar to while statement but its inverse. b) write a note on references in perl. A reference is a scalar variable that references other variables or a literal. So the value of reference variable is an address. Less flexible than C's pointers but much safer. The address

8 a) Write a perl program to check if the given string is palindrome.


print "\nEnter word : \n"; chomp(my $str = <>);

if ( $str eq reverse($str) ) { print "PALINDROME!\n"; } else { print "NOT A PALINDROME! \n"; }

b) Briefly explain perl string functions.

9. lab programs 5a/5b/6a. 6a:

You might also like