IT1451 –WEB TECHNOLOGY–Unit II (COMMON GATEWAY INTERFACE PROGRAMMING)–2 Marks with Answers–Reg 2004

Anna University

DEPARTMENT OF INFORMATION TECHNOLOGY

IT1451 –WEB TECHNOLOGY

Regulation 2004

UNIT – II Two Marks with Answers

COMMON GATEWAY INTERFACE PROGRAMMING


SUBJECT CODE : IT1451

SUBJECT NAME:WEB TECHNOLOGY


UNIT II

COMMON GATEWAY INTERFACE PROGRAMMING


25. Define CGI -Common Gateway Interface.

A specification for transferring information between a World Wide Web server and a CGI program. ACGI program is any program designed to accept and return data that conforms to the CGI specification. The program could be written in. any programming language, including C, Perl, Java, or Visual Basic.


26. Write a note on Internet Information Server (IIS).

Microsoft’s Web server that runs on Windows NT platforms, In fact, IIS comes bundled with Windows NT 4.0. Because IIS is tightly integrated with the operating system, it is relatively easy to administer. However, currently IIS is available only for the Windows NT platform, whereas Netscape’ s Web servers run on all major platforms, including Windows NT platform, OS/2 and UNIX.


27. What are ISAPI (Internet Server API) and NSAPI (Netscape Server API)

ISAPI (Internet Server API): An API for Microsoft’s IIS (Internet Information Server) Web server. ISAPI enables programmers to develop Web-based applications that run much faster than conventional CGI programs because they’re more tightly integrated with the Web server. In addition to IIS, several Web servers from companies other than Microsoft support ISAPI.

NSAPI -Netscape Server API: An API for Netscape’s Web servers. NSAPI enables programmers to create Web-based applications that are more sophisticated and run much faster than applications based on CGI scripts.


28. What is API -Application Program Interface?

A set of routines, protocols, and tools for building software applications. A good API makes it easier to develop a program by providing all the building blocks. A programmer puts the blocks together.

Most operating environments, such as MS- Windows, provide an API so that programmers can write applications consistent with the operating environment. Although APIs are designed for programmers, they are ultimately good for users because they guarantee that all programs using a common API will have similar interfaces. This makes it easier for users to learn new programs.


29. What are Servlets?

A small program that runs on a server, the term usually refers to a Java applet that runs within a Web server environment. This is analogous to a Java applet that runs within a Web browser environment.

Java servlets are becoming increasingly popular as an alternative to CGI programs. The biggest difference between the two is that a Java applet is persistent. This means that once it is started, it stays in memory and can fulfill multiple requests. In contrast, a CGI program disappears once it has fulfilled a request. The persistence of Java applets makes them faster because there’s no wasted time in setting up and tearing down the process.


30. What are Applets?

A program designed to be executed from within another application. Unlike an application, applets cannot be executed directly from the operating system. With the growing popularity of OLE (object linking and embedding), applets are becoming more prevalent. A well-designed applet can be invoked from many different applications.

Web browsers, who are often equipped with Java virtual machines, can interpret applets from Web servers. Because applets are small in files size, cross-platform compatible, and highly secure (can’t be used to access users' hard drives), they are ideal for small Internet applications accessible from a browser.


31. What do you mean by Server-side?

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


32. What is a protocol?

An agreed-upon format for transmitting data between two devices. The protocol determines the following:

1.The type of error checking to be used

2.Data Compression method, if any

3.How the sending device will indicate that it has finished sending a message

4.How the receiving device will indicate that it has received a message


33. What is ActiveX?

A loosely defined set of technologies developed by Microsoft for sharing information among different applications. ActiveX is an outgrowth of two other Microsoft technologies called OLE (Object Linking and Embedding) and COM (Component Object Model). As a moniker, ActiveX can be very confusing because it applies to a whole set of COM-based technologies. Most people, however, think only of ActiveX controls, which represent a specific way of implementing ActiveX technologies.


34. Write a note on ActiveX controls.

A control using ActiveX technologies. An ActiveX control can be automatically downloaded and executed by a Web browser. ActiveX is not a programming language, but rather a set of rules for how applications should share information. Programmers can develop ActiveX controls in a variety of languages, including C, C++, Visual Basic, and Java.

An ActiveX control is similar to a Java applet. Unlike Java applets, however, ActiveX controls have full access to the Windows operating system. This gives them much more power than Java applets, but with this power comes a certain risk that the applet may damage software or data on your machine. To control this risk, Microsoft developed a registration system so that browsers can identify and authenticate an ActiveX control before downloading it. Another difference between Java applets and ActiveX controls is that Java applets can be written to run on all platforms, whereas ActiveX controls are currently limited to Windows environments. Related to ActiveX is the scripting language VBScript that enables Web authors to embed interactive elements in HTML documents.


35.Explain about HTTP Connection.

It is a communication channel between web browser and web server. It begins on the client side with the browser sending a request to the web server for a document.

Request Header Fields are

1. From

2. Reference

3. If_modified_since

4. Pragma

5. User Agent


36. What is meant by Stateless Connection?

When a web server receives a HTTP request from a web browser it evaluates the request and returns the requested document, if it exists, and then breaks the HTTP connection. This document is preceded by the response header, which has details about how to display the document that will be sent by the server. Each time a request is made to the server, it is as if there was no prior connection and each request can yield only a single document. This is known as Stateless Connection.


37. Write a note on Environment variables.

In CGI, the server prepares the environment variables before it launches the CGI script. These represent the current state of the server that is asking for the information. The environment variables are not set from the command line but are created on the fly, and lasts only until that particular script is finished. Each script gets its own unique set of variables and multiple scripts can be executed at once, each in its own environment.


38. What are STDIN and STDOUT?

These are mnemonics for standard input and standard output, two predefined stream

/ file handles. Each process already inherits these two handles already open. From the script’s point of view, STDIN is what comes from the browser via the server when the post method is used, and the STDOUT is where it writes its output back to the browser. The script picks up the environment variables and reads STDIN as appropriate. It then does whatever it was designed to do and writes its output to STDOUT.


39. What are the two commonly used Request methods?

The request methods tell the script how it was invoked. Based on this information, the script decides how to act. The request method is passed to the script using environment

variable called REQUEST- METHOD. The two most common request methods used are GET

and POST.

GET

GET is a request for data, the same method used for obtaining static documents. The GET method sends request information as parameter tacked onto the end of the URL. These parameters are passed to the CGI program in the environment variable QUERY-STRING.

E.g.: If the script is called myprog.exe and is invoked from a link with the form

<A HREF="cgi-bin/myprog.exe? lname=blow&fname=joe"> The REQUEST_METHOD will be the string GET, and the QUERY_STRING will contain lname=blow & fname=joe.

A mandatory question mark separates the name of the script from the beginning of the QUERY_STRING. If a slash is used instead of the question mark; the server passes the information to script using the PATH_INFO variable instead of the QUERY_STRING variable.

POST

POST operation occurs when the browser sends data from a fill-in form to the server.

With POST, the QUERY_STRING mayor may not be blank, depending on the server.The data from a POSTed query gets passed from the server to the script using STDIN. Because STDIN is a stream and the script needs to know how much valid data is waiting, the server also Supplies another variable, CONTENT_LENGTH, to indicate the size in bytes of the incoming "data.

The format for POSTed data is

Variable1=value1 & variable2=value2 &etc.

After the required data is available, the script executes and writes its output to the STDOUT. The MIME code that the server sends to the browser indicates the type of the file that is being sent. This information that precedes the file is usually called the header. Since the script generates the output on the fly the server will not be able to create a header for that information. Hence this information has to be supplied by the script itself. Failure will result in the browser receiving information that it does not know how to display.


40. Explain about URL Encoding.

HTTP specification requires that the URL data should be encoded in such a way that it can be used on almost any hardware and software platforms. Information specified in this way is called URL encoded. If parameters are passed as a part of query string or path information, they will take the form of ‘Name-Value’ pairs.

variablel=valuel&variable2=value2& so on for each variable defined in the form.

The variables or name value pairs are separated by '&'. Real ampersand is escaped -that is, encoded as a two-digit hexadecimal value representing the character. Escaped characters are indicated in URL-encoded string by the percent (%) sign. Blank spaces are replaced by '+' sign. Before the script can deal with the data it has to parse and decode it. The script scans through the string looking for an ampersand. When it is found the string is broken from that point. The variable's name is every thing up to the equal sign in the string and the value is every thing

after the equal sign. The script continues to parse the original string for the next ampersand, and so on until the original string is exhausted. After the variables are separated, they are decoded as follows.

1. Replace all plus signs with blank spaces.

2. Replace all %## (Percent sign followed by two hexadecimal digits) with the corresponding

ASCII character.

Separate the name-value pairs from the URL and store the values separately.


41. List the advantages of CGI scripting?

I. CGI programs are relatively safe to run.

2. A CGI program can crash without damaging the server, since it only has limited access to the server.

3. Reduces the burden of server

a. Sends prepared messages / mails e customer reply

b. Capability to process forms and prepares output based on form input. c . Hit counts / Page counters.


42. Explain about Session tracking.

A session is basically a conversation between a browser and a server. All the above technologies can save information for the current session for a particular user visiting a site. The session is important, as H1TP is a stateless protocol. This means that the connection between web server and a web browser is not automatically maintained, and that the state of a web session is not saved.

State is a general term that includes "everything about your situation" and the specifics vary based on the application. In a word processor, the state of the application would include which windows are open, where they are on the screen, and what files you most recently used. In a web application, the state would include any data that you had entered, the results of any queries that you had run, and your security access information (e.g. whether you have logged in to the site).