Sunday, 17 August 2014

KU 5TH SEM ASSIGNMENT - BSIT (TB) - 51 GRAPHICS & MULTIMEDIA

Assignment: TB (Compulsory)

1. What is the need for computer graphics?Computers have become a powerful tool for the rapid and economical production of pictures. Computer Graphics remains one of the most exciting and rapidly growing fields. Old Chinese saying “ One picture is worth of thousand words” can be modified in this computer era into “ One picture is worth of many kilobytes of data”. It is natural to expect that graphical communication, which is an older and more popular method of exchanging information than verbal communication, will often be more convenient when computers are utilized for this purpose. This is true because one must represent objects in two-dimensional and three-dimensional spaces. Computer Graphics has revolutionized almost every computer-based application in science and technology.

2. What is graphics processor? Why it is needed?To provide visual interface, additional processing capability is to be provided to the existing CPU. The solution is to provide dedicated graphic processor. This helps in managing the screen faster with an equivalent software algorithm executed on the CPU and certain amount of parallelism can be achieved for completing the graphic command. Several manufacturers of personal computers use a proprietary graphic processor. For example, Intel 82786 is essentially a line drawing processor; Texas Instruments 43010 is a high performance general-purpose processor.

3. What is a pixel?

Pixel (picture element): Pixel may be defined as the smallest size object or color spot that can be displayed and addressed on a monitor. Any image that is displayed on the monitor is made up of thousands of such small pixels. The closely spaced pixels divide the image area into a compact and uniform two-dimensional grid of pixel lines and columns.

4. Why C language is popular for graphics programming?
Turbo C++ is for C++ and C programmers. It is also compatible with ANSI C standard and fully
supports Kernighan and Ritchie definitions. It includes C++ class libraries, mouse support, multiple overlapping windows, Multi file editor, hypertext help, far objects and error analysis. Turbo C++ comes with a complete set of graphics functions to facilitate preparation of charts and diagrams. It supports the same graphics adapters as turbo Pascal. The Graphics library consists of over 70 graphics functions ranging from high level support like facility to set view port, draw 3-D bar charts, draw polygons to bitoriented functions like get image and put image. The graphics library supports numerous objects, line styles and provides several text fonts to enable one to justify and orient text, horizontally and vertically. It may be noted that graphics functions use far pointers and it is not supported in the tiny memory model.

5. Define resolution.
Resolution: Image resolution refers as the pixel spacing i.e. the distance from one pixel to the next pixel. A typical PC monitor displays screen images with a resolution somewhere between 25 pixels per inch and 80 pixels per inch. Pixel is the smallest element of a displayed image, and dots (red, green and blue) are the smallest elements of a display surface (monitor screen). The dot pitch is the measure of screen resolution. The smaller the dot pitch, the higher the resolution, sharpness and detail of the image displayed.

6. Define aspect ratio.
Aspect ratio: The aspect ratio of the image is the ratio of the number of X pixels to the number of Y pixels. The standard aspect ratio PCs is 4:3, and some use 5:4. Monitors are calibrated to this standard so that when you draw a circle it appears to be a circle and not an ellipse.

7. Why refreshing is required in CRT?
When the electron beam strikes a dot of phosphor material, it glows for a fraction of a second and then fades. As brightness of the dots begins to reduce, the screen-image becomes unstable and gradually fades out. In order to maintain a stable image, the electron beam must sweep the entire surface of the screen and then return to redraw it number of times per second. This process is called refreshing the screen. If the electron beam takes too long to return and redraw a pixel, the pixel begins to fade results in flicker in the image. In order to avoid flicker the screen image must be redrawn sufficiently quickly that the eye cannot tell that refresh is going on. The refresh rate is the number of times per second that the screen is refreshed. Some monitor uses a technique called interlacing for refreshing every line of the screen. In the first pass, odd-numbered lines are refreshed, and in the second pass, even –numbered lines are refreshed. This allows the refresh rate to be doubled because only half the screen is redrawn at a time.

8. Name the different positioning devices.
The devices discussed so far, the mousethe tabletthe joystick are called “positioning devices”. They are able to position the curser at any point on the screen. (We can operate at that point or the chain of points) Often, one needs devices that can “point” to a given position on the screen. This becomes essential when a diagram is already there on the screen, but some changes are to be made. So, instead of trying to know its coordinates, it is advisable to simply “point” to that portion of the picture and asks for changes. The simplest of such devices is the “light pen”. Its principle is extremely simple.

9. What are pointing devices?
A pointing device is an input interface (specifically a human interface device) that allows a user to input spatial (i.e., continuous and multi-dimensional) data to a computer. CAD systems and graphical user interfaces (GUI) allow the user to control and provide data to the computer using physical gestures — point, click, and drag — for example, by moving a hand-held mouse across the surface of the physical desktop and activating switches on the mouse. Movements of the pointing device are echoed on the screen by movements of the pointer (or cursor) and other visual changes.

10. What is multimedia?
The word ‘Multimedia’ seems to be everywhere nowadays. The word multimedia is a compound
of the Latin prefix ‘multi’ meaning many, and the Latin-derived work ‘media’, which is the plural
of the world medium. So multimedia simply means ‘using more than one kind of medium’.
Multimedia is the mixture of two or more media effects-Hypertext, Still Images, sound, Animation and Video to be interacted on a computer terminal.

11. What are sound cards?
Sound cards: The first sound blaster was an 8-bit card with 22 KHz sampling, besides being equipped with a number of drives and utilities. This became a king of model for the other sound cards. Next came the Sound Blaster Pro, again 8-bit sound but with a higher sampling rate of 44 KHz, which supports a wider frequency range. Then there was Yamaha OPL3 chipset with more voices. Another development was built-in CD ROM interface through which huge files could be played directly via the sound card.

12. What is sampling?
Sampling: Sampling is like breaking a sound into tiny piece and storing each piece as a small, digital sample of sound. The rate at which a sound is “Sampled” can affect its quality. The higher the sampling rate (the more pieces of sound that are stored) the better the quality of sound. Higher quality of sound will occupy a lot of space in hard disk because of more samples.

13. What is morphing?
Morphing: The best example would be the Kawasaki advertisement, where the motorbike changes into a cheetah, the muscle of MRF to a real muscle etc.. Morphing is making an image change into another by identifying key points so that the key point’s displacement, etc. are taken into consideration for the change.

14. What is rendering?
Rendering: The process of converting your designed objects with texturing and animation into an image or a series of images is called rendering. Here various parameters are available like resolution, colors type of render, etc.

15. What is warping?
Warping: Certain parts of the image could be marked for a change and made to change to different one. For examples, the eyes of the owl had to morph into the eyes of cat, the eyes can alone be marked and warped.

16. Why we use scanner?
Photographs, illustrations, and paintings continue to be made the old fashioned way, even by visual artists who are otherwise immersed in digital imaging technology. Traditional photographs, illustrations, and paintings are easily imported into computers through the use of a device called a scanner.

          A Scanner “scans’” over an image such as photo, drawing, logo, etc, converting it into an image and it can be seen on the screen. Using a good paint programme, Image Editor we can do adding, removing colors, filtering, Masking color etc.

17. What is ganut in Photoshop?

Write yourself...



18. What is a layer?

The concept of layering is similar to that of compositing as we make the different layers by keying out the uniform color and making it transparent so that layer beneath becomes visible. In case of future modifications we will be able to work with individual layers and need not work with the image as a whole. 
 

 
19. What are editing tools? Why it is needed?
You can use the editing tools to draw on a layer, and you can copy and paste selections to a layer.
 
Many types of editing tools are:-
 
i).Eraser tool: The eraser tool changes pixels in the image as you drag through them. You can choose to change the color and transparency of the affected pixels, or to revert the affected area to its previously saved version.
 
ii).Smudge tool: The smudge tool simulates the actions of dragging a finger through wet paint. The tool picks up color from where the stroke begins and pushes it in the direction in which you drag.
 

 
20. What is file format?
 
File Format: When you create an image-either through scanning into your computer or drawing it from scratch on your monitor or captured through a camera, recorded voice or music from the two-in-one or recorded connecting a music instrument it must be saved to your disk. Otherwise it would become an ethereal artifact that could never again be seen or listened. Once the computer’s power is turned off, it’s gone forever unless it is saved. The method by which the software organizes the data in the saved file is called the file format.Assignment: TB (Compulsory)

1. What is the need for computer graphics?Computers have become a powerful tool for the rapid and economical production of pictures. Computer Graphics remains one of the most exciting and rapidly growing fields. Old Chinese saying “ One picture is worth of thousand words” can be modified in this computer era into “ One picture is worth of many kilobytes of data”. It is natural to expect that graphical communication, which is an older and more popular method of exchanging information than verbal communication, will often be more convenient when computers are utilized for this purpose. This is true because one must represent objects in two-dimensional and three-dimensional spaces. Computer Graphics has revolutionized almost every computer-based application in science and technology.

2. What is graphics processor? Why it is needed?To provide visual interface, additional processing capability is to be provided to the existing CPU. The solution is to provide dedicated graphic processor. This helps in managing the screen faster with an equivalent software algorithm executed on the CPU and certain amount of parallelism can be achieved for completing the graphic command. Several manufacturers of personal computers use a proprietary graphic processor. For example, Intel 82786 is essentially a line drawing processor; Texas Instruments 43010 is a high performance general-purpose processor.

3. What is a pixel?

Pixel (picture element): Pixel may be defined as the smallest size object or color spot that can be displayed and addressed on a monitor. Any image that is displayed on the monitor is made up of thousands of such small pixels. The closely spaced pixels divide the image area into a compact and uniform two-dimensional grid of pixel lines and columns.

4. Why C language is popular for graphics programming?
Turbo C++ is for C++ and C programmers. It is also compatible with ANSI C standard and fully
supports Kernighan and Ritchie definitions. It includes C++ class libraries, mouse support, multiple overlapping windows, Multi file editor, hypertext help, far objects and error analysis. Turbo C++ comes with a complete set of graphics functions to facilitate preparation of charts and diagrams. It supports the same graphics adapters as turbo Pascal. The Graphics library consists of over 70 graphics functions ranging from high level support like facility to set view port, draw 3-D bar charts, draw polygons to bitoriented functions like get image and put image. The graphics library supports numerous objects, line styles and provides several text fonts to enable one to justify and orient text, horizontally and vertically. It may be noted that graphics functions use far pointers and it is not supported in the tiny memory model.

5. Define resolution.
Resolution: Image resolution refers as the pixel spacing i.e. the distance from one pixel to the next pixel. A typical PC monitor displays screen images with a resolution somewhere between 25 pixels per inch and 80 pixels per inch. Pixel is the smallest element of a displayed image, and dots (red, green and blue) are the smallest elements of a display surface (monitor screen). The dot pitch is the measure of screen resolution. The smaller the dot pitch, the higher the resolution, sharpness and detail of the image displayed.

6. Define aspect ratio.
Aspect ratio: The aspect ratio of the image is the ratio of the number of X pixels to the number of Y pixels. The standard aspect ratio PCs is 4:3, and some use 5:4. Monitors are calibrated to this standard so that when you draw a circle it appears to be a circle and not an ellipse.

7. Why refreshing is required in CRT?
When the electron beam strikes a dot of phosphor material, it glows for a fraction of a second and then fades. As brightness of the dots begins to reduce, the screen-image becomes unstable and gradually fades out. In order to maintain a stable image, the electron beam must sweep the entire surface of the screen and then return to redraw it number of times per second. This process is called refreshing the screen. If the electron beam takes too long to return and redraw a pixel, the pixel begins to fade results in flicker in the image. In order to avoid flicker the screen image must be redrawn sufficiently quickly that the eye cannot tell that refresh is going on. The refresh rate is the number of times per second that the screen is refreshed. Some monitor uses a technique called interlacing for refreshing every line of the screen. In the first pass, odd-numbered lines are refreshed, and in the second pass, even –numbered lines are refreshed. This allows the refresh rate to be doubled because only half the screen is redrawn at a time.

8. Name the different positioning devices.
The devices discussed so far, the mousethe tabletthe joystick are called “positioning devices”. They are able to position the curser at any point on the screen. (We can operate at that point or the chain of points) Often, one needs devices that can “point” to a given position on the screen. This becomes essential when a diagram is already there on the screen, but some changes are to be made. So, instead of trying to know its coordinates, it is advisable to simply “point” to that portion of the picture and asks for changes. The simplest of such devices is the “light pen”. Its principle is extremely simple.

9. What are pointing devices?
A pointing device is an input interface (specifically a human interface device) that allows a user to input spatial (i.e., continuous and multi-dimensional) data to a computer. CAD systems and graphical user interfaces (GUI) allow the user to control and provide data to the computer using physical gestures — point, click, and drag — for example, by moving a hand-held mouse across the surface of the physical desktop and activating switches on the mouse. Movements of the pointing device are echoed on the screen by movements of the pointer (or cursor) and other visual changes.

10. What is multimedia?
The word ‘Multimedia’ seems to be everywhere nowadays. The word multimedia is a compound
of the Latin prefix ‘multi’ meaning many, and the Latin-derived work ‘media’, which is the plural
of the world medium. So multimedia simply means ‘using more than one kind of medium’.
Multimedia is the mixture of two or more media effects-Hypertext, Still Images, sound, Animation and Video to be interacted on a computer terminal.

11. What are sound cards?
Sound cards: The first sound blaster was an 8-bit card with 22 KHz sampling, besides being equipped with a number of drives and utilities. This became a king of model for the other sound cards. Next came the Sound Blaster Pro, again 8-bit sound but with a higher sampling rate of 44 KHz, which supports a wider frequency range. Then there was Yamaha OPL3 chipset with more voices. Another development was built-in CD ROM interface through which huge files could be played directly via the sound card.

12. What is sampling?
Sampling: Sampling is like breaking a sound into tiny piece and storing each piece as a small, digital sample of sound. The rate at which a sound is “Sampled” can affect its quality. The higher the sampling rate (the more pieces of sound that are stored) the better the quality of sound. Higher quality of sound will occupy a lot of space in hard disk because of more samples.

13. What is morphing?
Morphing: The best example would be the Kawasaki advertisement, where the motorbike changes into a cheetah, the muscle of MRF to a real muscle etc.. Morphing is making an image change into another by identifying key points so that the key point’s displacement, etc. are taken into consideration for the change.

14. What is rendering?
Rendering: The process of converting your designed objects with texturing and animation into an image or a series of images is called rendering. Here various parameters are available like resolution, colors type of render, etc.

15. What is warping?
Warping: Certain parts of the image could be marked for a change and made to change to different one. For examples, the eyes of the owl had to morph into the eyes of cat, the eyes can alone be marked and warped.

16. Why we use scanner?
Photographs, illustrations, and paintings continue to be made the old fashioned way, even by visual artists who are otherwise immersed in digital imaging technology. Traditional photographs, illustrations, and paintings are easily imported into computers through the use of a device called a scanner.

          A Scanner “scans’” over an image such as photo, drawing, logo, etc, converting it into an image and it can be seen on the screen. Using a good paint programme, Image Editor we can do adding, removing colors, filtering, Masking color etc.

17. What is ganut in Photoshop?

Write yourself...



18. What is a layer?

The concept of layering is similar to that of compositing as we make the different layers by keying out the uniform color and making it transparent so that layer beneath becomes visible. In case of future modifications we will be able to work with individual layers and need not work with the image as a whole. 
 

 
19. What are editing tools? Why it is needed?
You can use the editing tools to draw on a layer, and you can copy and paste selections to a layer.
 
Many types of editing tools are:-
 
i).Eraser tool: The eraser tool changes pixels in the image as you drag through them. You can choose to change the color and transparency of the affected pixels, or to revert the affected area to its previously saved version.
 
ii).Smudge tool: The smudge tool simulates the actions of dragging a finger through wet paint. The tool picks up color from where the stroke begins and pushes it in the direction in which you drag.
 

 
20. What is file format?
 
File Format: When you create an image-either through scanning into your computer or drawing it from scratch on your monitor or captured through a camera, recorded voice or music from the two-in-one or recorded connecting a music instrument it must be saved to your disk. Otherwise it would become an ethereal artifact that could never again be seen or listened. Once the computer’s power is turned off, it’s gone forever unless it is saved. The method by which the software organizes the data in the saved file is called the file format.

KU 5TH SEM ASSIGNMENT - BSIT TB - 52 WEB PROGRAMMING

Assignment: TB (Compulsory)

Part - A
a) What is the difference between Internet and Intranet?
Internet: Internet is global network of networks.Internet is a tool for collaborating academic research,and it has become a medium for exchanging anddistributing information of all kinds. It is aninterconnection between several computers of different types belongingto various networks all over global.
Intranet: Intranet is not global. It is a mini web that islimited to user machines and software program of  particulars organization or company

b) List any five HTML tags.
Five HTML tags are:-
i). UL (unordered list): The UL tags displays a bulleted list. You can use the tag’s TYPE attribute to change the bullet style.
ii). TYPE: defines the type of bullet used of each list item. The value can be one of the following-CIRCLE, DISC, SQUARE
iii). LI (list item): The LI tag indicates an itemized element, which is usually preceded by bullet, a number, or a letter. The LI is used inside list elements such as OL (ordered list) and UL (unordered list).
iv). TABLES (table): The TABLE tag defines a table. Inside the TABLE tag, use the TR tag to define rows in the table, use the TH tag to define row or column headings, and the TD tag to define table cells.
v). HTML (outermost tag): The HTML identifies a document as an HTML document. All HTML documents should start with the and end with the tags.

c) Write the difference between HTML and DHTML.
HTML: HTML stands for Hyper Text MarkupLanguage. It is a language. HTML can’t bedone after the page loads. HTML can be or not usedwith JavaScript.
DHTML: DHTML stands for Dynamic Hyper TextMarkup Language. DHTML isn’t really alanguage or a “thing” in itself it’s just a mix of thosetechnologies. Dynamic HTML is simply HTMLthat can change even after a page has been loaded into a browser. DHTML can be used with JavaScript.

d) Explain the different types of PERL variables.
Perl has three types of variables:
i). Scalars  
ii). Arrays
iii). Hashes.

i). Scalars: A scalar variable stores a single (scalar) value.Perl scalar names are prefixed with a dollar sign ($), so for example, $username, and $url are all examples of scalar variable names. A scalar can hold data of anytype, be it a string, a number, or whatnot. We can alsouse scalars in double-quoted strings: my $fnord = 23;my $blee = “The magic number is $fnord.”; Now if you print $blee, we will get “The magic number is 23.”Perl interpolates the variables in the string, replacingthe variable name with the value of that variable.
ii). Arrays: An array stores an ordered list of values. Whilea scalar variable can only store one value, an array canstoremany. Perl array names are prefixed with a @-sign.e.g.:my @colors = (“red”,”green”,”blue”); foreach my $i(@colors) { print “$i\n”; }
iii). Hashes: Hashes are an advanced form of array. One of the limitations of an array is that the information contained within it can be difficult to get to. For example, imagine that you have a list of people and their ages. The hash solves this problem very neatly by allowing us to access that @ages array not by an index, but by a scalar key. For example to use age of different people we can use thier names as key to define a hash.

e) How are JSPs better than servlets.
Java programming knowledge is needed todevelop and maintain all aspects of the application,since the processing code and the HTML elements are jumped together.
Changing the look and feel of theapplication,or adding support for a new type of client, requires theservlet code to be updated and recompiled.
It’s hardto take advantage of web-page development tools whendesigning the application interface. If such tools areused to develop the web page layout, the generatedHTML must then be manually embedded into theservletcode, a process which is time consuming, error prone,and extremely boring. Adding JSP to the puzzle wesolvethese problems.So JSPs better than servlets.

Part - B
1. a) Explain GET and POST method with the help of an example.
When a client sends a request to the server, theclients can also additional information with the URL todescribe what exactly is required as output from theserver by using the GET method. The additionalsequenceof characters that are appended to URL is called a querystring. However, the length of the query string islimited to 240 characters. Moreover, the query string isvisible on the browser and can therefore be a securityrisk.to overcome these disadvantages, the POST method can be used. The POST method sends the data as packetsthrough a separate socket connection. The completetransaction is invisible because to the client. Thedisadvantageof POST method is that it is slower compared to theGET method because data is sent to the server asseparate packets.

b) Explain in detail the role played by CGI programming in web programming.
CGI opened the gates of more complex Web applications. It enabled developers to write scripts,
which can communicate with server applications and databases. In addition, it enables
developers to write scripts that could also parse client's input, process it, and present it in a user
friendly way.
The Common Gateway Interface, or CGI, is a standard for external gateway
programs to interface with information servers such as HTTP servers. A plain HTML document
that the Web daemon retrieves is static, which means it exists in a constant state: a text file that
doesn't change. A CGI program, on the other hand, is executed in real-time, so that it can output
dynamic information.
CGI programming allows us to automate passing information to and from web pages. It can also
be used to capture and process that information, or pass it off to other software (such as in an
SQL database).
CGI programs (sometimes called scripts) can be written in any programming language, but the
two most commonly used are Perl and PHP. Despite all the flashy graphics, Internet technology
is fundamentally a text-based system. Perl was designed to be optimal for text processing, so it
quickly became a popular CGI tool. PHP is a scripting language designed specifically to make
web programming quick and easy.

2. a) With the help of an example explain the embedding of an image in an HTML tag.
<HTML>
<HEAD>
</HEAD>
<BODY>
<IMG SRC="Images/123.jpg" ALT="Image" />
</BODY>
</HTML>

b) Create a HTML page to demonstrate the usage of Anchor tags.
<HTML>
<HEAD></HEAD>
<BODY>
<A NAME=section2>
<H2>A Cold Autumn Day</H2></A>
If this anchor is in a file called "nowhere.htm," you could define a link that jumps to the
anchor as follows:
<P>Jump to the second section <A HREF="nowhere.htm#section2">
A Cold Autumn Day</A> in the mystery "A man from Nowhere."
</BODY>
</HTML>

3. a) Explain the usage of script tags.
Using the SCRIPT Tag: The following example uses the SCRIPT tag to define a JavaScript script in the HEAD tag. The script is loaded before anything else in the document is loaded. The JavaScript code in this example defines a function, changeBGColor(), that changes the document’s background color.
The body of the document contains a form with two buttons. Each button invokes the changeBGColor()
function to change the background of the document to a different color.

<HTML>
<HEAD><TITLE>Script Example</TITLE>
</HEAD>
<SCRIPT language="JavaScript">
function changeBGColor (newcolor) {
document.bgColor=newcolor;
return false;
}
</SCRIPT>
<BODY >
<P>Select a background color:</P>
<FORM>
<INPUT TYPE="button" VALUE=blue onClick="changeBGColor('blue');">
<INPUT TYPE="button" VALUE=green onClick="changeBGColor('green');">
</FORM>
<NOSCRIPT><I>Your browser is not JavaScript-enabled.
These buttons will not work.</I>
</NOSCRIPT>

b) What is Java script? List the use of Java script.
JavaScript is a scripting language (like a simple programming language). It is a language that can be used for client-side scripting. JavaScript is only usedinside of HTML documents. With JavaScript, we can make text scroll across the screen like ticker tape.
The uses of JavaScript are:
i). Control DocumentAppearance and Content
ii). Control the Browser 
iii). Interact with Document Control
iv). Interact withUser 
v). Read and Write Client State with Cookies
vi). Interact with Applets
vii). JavaScript is only usedinside of HTML documents.

4. a) With the help of an example explain any five CGI environment variables.
i). SERVER_NAME : The server's host name or IP address.
ii). SERVER_PORT : The port number of the host on which the server is running.
iii). SERVER_SOFTWARE : The name and version of the server software that is answering the client request.
iv). SERVER_PROTOCOL : The name and revision of the information protocol that request came in with.
v). GATEWAY_INTERFACE : The revision of the common gateway interface that the server uses.

Example:-
#!/usr/local/bin/perl
print "Content-type: text/html", "\n\n";
print "<HTML>", "\n";
print "<HEAD><TITLE>About this Server</TITLE></HEAD>", "\n";
print "<BODY><H1>About this Server</H1>", "\n";
print "<HR><PRE>";
print "Server Name: ", $ENV{'SERVER_NAME'}, "<BR>", "\n";
print "Running on Port: ", $ENV{'SERVER_PORT'}, "<BR>", "\n";
print "Server Software: ", $ENV{'SERVER_SOFTWARE'}, "<BR>", "\n";
print "Server Protocol: ", $ENV{'SERVER_PROTOCOL'}, "<BR>", "\n";
print "CGI Revision: ", $ENV{'GATEWAY_INTERFACE'}, "<BR>", "\n";
print "<HR></PRE>", "\n";
print "</BODY></HTML>", "\n";
exit (0);


b) Write a CGI application which accepts three numbers from the used and display biggest number using GET and POST methods.
#!/usr/bin/perl
#print "Content-type:text/html\n\n";
#$form = $ENV{'QUERY_STRING'};
use CGI;
$cgi = new CGI;
print $cgi->header;
print $cgi->start_html( "Question Ten" );
my $one = $cgi->param( 'one' );
my $two = $cgi->param( 'two' );
my $three = $cgi->param( 'three' );
if( $one && $two && $three )
{
$lcm = &findLCM( &findLCM( $one, $two ), $three );
print "LCM is $lcm";
}
else
{
print '
';
print 'Enter First Number  
';
print 'Enter Second Number  
';
print 'Enter Third Number  
';
print ' 
';
print "
";
}
print $cgi->end_html;
sub findLCM(){
my $x = shift;
my $y = shift;
my $temp, $ans;
if ($x < $y) {
$temp = $y;
$y = $x;
$x = $temp;
}
$ans = $y;
$temp = 1;
while ($ans % $x)
{
$ans = $y * $temp;
$temp++ ;
}
return $ans;
}

5. a) List the differences between web server and application server.
The main differences between Web servers and application servers :-
A Web server is where Web components are deployed and run. An application server is where
components that implement the business logic are deployed. For example, in a JSP-EJB Web
application, the JSP pages will be deployed on the Web server whereas the EJB components will
be deployed on the application servers.
A Web server usually supports only HTTP (and sometimes SMTP and FTP). However, an
application server supports HTTP as well as various other protocols such as SOAP.

In other word :-
Difference between AppServer and a Web server :-
i). Webserver serves pages for viewing in web browser, application server provides exposes
businness logic for client applications through various protocols
ii). Webserver exclusively handles http requests.application server serves bussiness logic to
application programs through any number of protocols.
iii). Webserver delegation model is fairly simple,when the request comes into the webserver,it
simply passes the request to the program best able to handle it(Server side program). It may not
support transactions and database connection pooling.
iv). Application server is more capable of dynamic behaviour than webserver. We can also
configure application server to work as a webserver.Simply applic! ation server is a superset of
webserver.

b) What is a war file? Explain its importance.
WAR or Web Application Archive file is packaged servlet Web application. Servlet applications
are usually distributed as a WAR files.
WAR file (which stands for "web application_ archive" ) is a JAR_ file used to distribute a collection of JavaServer Pages_ , servlets_ , Java_ classes_ , XML_ files, tag libraries and static Web pages ( HTML_ and related files) that together constitute a Web application.

6. a) Explain implicit objects out, request response in a JSP page.
Following are the implicit objects in a JSP page:-
out: This implicit object represents a JspWriter that provides a stream back to the requesting client. The most common method of this object is out.println(),which prints text that will be displayed in the client's browser request: This implicit object represents the javax.servlet.HttpServletRequest interface. The request object is associated with every HTTP request. One common use of the request object is to access request parameters. You can do this by calling the request object's getParameter() method with the parameter name you are seeking. It will return a string with the values matching the named parameter. response: This implicit object represents the javax.servlet.HttpServletRequest object. The response object is used to pass data back to the requesting client. A common use of this object is
writing HTML output back to the client browser.

b) With the help of an example explain JSP elements.
JSP elements are of 3 types:-
Directive: Specifies information about the page itself that remains the same between requests.
For  example,  it  can  be  used  to  specify  whether  session  tracking  is  required  or  not,  buffering
requirements, and the name of the page that should be used to report errors.
<%@ page/include/taglib …%>
Action: Performs some action  based on information that is required at the exact  time  the JSP
page is requested by a  browser. An action, for instance,  can  access parameters  sent  with  the
request to lookup a database.
Scripting: Allows you to add small pieces of code in JSP page.