0% found this document useful (0 votes)
82 views

Assignment B52

This document contains assignments for web programming courses at Kuvempu University. It includes questions about HTML, the web, JavaScript, CSS, CGI, and Perl. The questions cover topics such as: - Defining the web and its building blocks like HTML and HTTP - Explaining how HTML is the language of the web - Classifying different types of HTML tags - Writing a CGI program to find the largest of three numbers - Describing JavaScript and its importance - Briefly explaining Cascading Style Sheets - Defining CGI and listing common environment variables - Explaining Perl with examples of control structures

Uploaded by

dattagi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views

Assignment B52

This document contains assignments for web programming courses at Kuvempu University. It includes questions about HTML, the web, JavaScript, CSS, CGI, and Perl. The questions cover topics such as: - Defining the web and its building blocks like HTML and HTTP - Explaining how HTML is the language of the web - Classifying different types of HTML tags - Writing a CGI program to find the largest of three numbers - Describing JavaScript and its importance - Briefly explaining Cascading Style Sheets - Defining CGI and listing common environment variables - Explaining Perl with examples of control structures

Uploaded by

dattagi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 13

Kuvempu University Assignments for B.Sc.(IT) & M.Sc.

(IT) Courses Subject: Web Programming Subject Code: BSIT - 52 Assignment: TA (Compulsory) 1. What is the meaning of Web? Explain in detail the building elements of web 2. HTML is the Language of the Web Justify the statement 3. Give the different classification of HTML tags with examples for each category 4. Write CGI application which accepts 3 numbers from the user and displays biggest number using GET and POST methods 5. What is Javascript? Give its importance in web. 6. Explain briefly Cascading Style Sheets 7. What is CGI? List the different CGI environment variables 8. What is PERL? Explain PERl control structures with the help of an example

1. What is the meaning of Web? Explain in detail the building elements of web Web is a complex network of international , cross plateform, and cross cultural communicating devices, connected to each other without any ordering or pattern. There are two most important building blocks of web: HTML and HTTP. HTML: - HTML stands for Hyper Text Markup Language. HTML is a very simple language used to describe the logical structure of a document. Actually, HTML is often called programming language it is really not. Programming languages are Turing-complete, or computable. That is, programming languages can be used to compute something such as the square root of pi or some other such task. Typically programming languages use conditional branches and loops and operate on data contained in abstract data structures. HTML is much easier than all of that. HTML is simply a markup language used to define a logical structure rather than compute anything.

HTTP: - HTTP is a request-response type protocol. It is a language spoken between web browser (client software) and a web server (server software) so that can communicate with each other and exchange files. Now let us understand how client/server system works using HTTP. A client/server system works something like this: A big piece of computer (called a server) sits in some office somewhere with a bunch of files that people might want access to. This computer runs a software package that listens all day long to requests over the wires. 2. HTML is the Language of the Web Justify the statement HTML is often called a programming language it is really not. Programming languages are Turing-complete, or computable. That is, programming languages can be used to compute something such as the square root of pi or some other such task. Typically programming languages use conditional branches and loops and operate on data contained in abstract data structures. HTML is much easier than all of that. HTML is simply a markup language used to define a logical structure rather than compute anything. For example, it can describe which text the browser should emphasize, which text should be considered body text versus header text, and so forth. The beauty of HTML of course is that it is generic enough that it can be read and interpreted by a web browser running on any machine or operating system. This is because it only focuses on describing the logical nature of the document, not on the specific style. The web browser is responsible for adding style. For instance emphasized text might be bolded in one browser and italicized in another. it is up to the browser to decide 3. Give the different classification of HTML tags with examples for each category LIST OF HTML TAGS :Tags for Document Structure HTML HEAD BODY

Heading Tags TITLE BASE META STYLE LINK Block-Level Text Elements ADDRESS BLOCKQUOTE DIV H1 through H6 P PRE XMP Lists DD DIR DL DT LI MENU OL UL Text Characteristics B BASEFONT BIG BLINK CITE CODE EM FONT I KBD PLAINTEXT S SMALL 4. Write CGI application which accepts 3 numbers from the user and displays 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. What is Javascript? Give its importance in web.

JavaScript is an easy to learn way to Scriptyour web pages that is have them to do actions that cannot be handled with HTML alone. With JavaScript, you can make text scroll across the screen like ticker tape; you can make pictures change when you move over them, or any other number of dynamic enhancement. JavaScript is generally only used inside of HTML document. i) JavaScript control document appearance and content. ii) JavaScript control the browser. iii) JavaScript interact with document content. iv) JavaScript interact with the user. v) JavaScript read and write client state with cookies. vi) JavaScript interact with applets. vii) JavaScript manipulate embedded images. 6. Explain briefly Cascading Style Sheets Cascading Style Sheet (CSS) is a part of DHTML that controls the look and placement of the element on the page. With CSS you can basically set any style sheet property of any element on a html page. One of the biggest advantages with the CSS instead of the regular way of changing the look of elements is that you split content from design. You can for instance link a CSS file to all the pages in your site that sets the look of the pages, so if you want to change like the font size of your main text you just change it in the CSS file and all pages are updated. 7. What is CGI? List the different CGI environment variables CGI or Common Gateway Interface is a specification which allows web users to run program from their computer.CGI is a part of the web server that can communicate with other programs running on the server. With CGI, the web server can call up a program, while passing user specific data to a program. The program then processes that data and the server passes the programs response back to the web browser. When a CGI program is called, the information that is made available to it can be roughly broken into three groups:i). Information about client, server and user. ii). Form data that are user supplied. iii). Additional pathname information. Most Information about client, server and user is placed in CGI environmental variables. Form data that are user supplied is incorporated in environment variables. Extra pathname information is placed in environment variables. i). GATEWAY_INTERFACE T he revision of the common Gateway interface that the server uses. ii). SERVER_NAME The Servers hostname or IP address. iii). SERVER_PORT The port number of the host on which the server is running.

iv). REQUEST_METHOD The method with which the information request is issued. v). PATH_INFO Extra path information passed to the CGI program 8. What is PERL? Explain PERl control structures with the help of an example Perl control structures include conditional statement, such as if/elseif/else blocks as well as loop like for each, for and while. i). Conditional statements - If condition The structure is always started by the word if, followed by a condition to be evaluated, then a pair the braces indicating the beginning and end of the code to be executed if the condition is true. If(condition) {condition to be executed } - Unless Unless is similar to if. You wanted to execute code only if a certain condition were false. If($ varname! = 23) { #code to execute if $ varname is not 23 } - The same test can be done using unless: Unless ($ varname== 23) { #code to execute if $ varname is not 23 } ii). Looping Looping allow you to repeat code for as long as a condition is met. Perl has several loop control structures: foreach, for, while and until. - While Loop A while loop executes as long as a particular condition is true: While (condition) { #code to run as long as condition is true. } - Until Loop A until loops the reverse of while. It executes as long as a particular condition is not true: While (condition) { #code to run as long as condition is not true. }

PART - A
I. Answer all the questions: 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 tags 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 cant bedone after the page loads. HTML can be or not usedwith JavaScript. DHTML: DHTML stands for Dynamic Hyper TextMarkup Language. DHTML isnt really alanguage or a thing in itself its 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. Its 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 II. Answer any FIVE full questions : 1. a) Explain GET and POST method with the help of an example. b) Explain in detail the role played by CGI programming in web programming. 2. a) With the help of an example explain the embedding of an image in an HTML tag. b) Create a HTML page to demonstrate the usage of Anchor tags. 3. a) Explain the usage of script tags. b) What is Java script? List the use of Java script. 4. a) With the help of an example explain any five CGI environment variables. b) Write a CGI application which accepts three numbers from the used and display biggest number using GET and POST methods. 5. a) List the differences between web server and application server. b) What is a war file? Explain its importance. 6. a) Explain implicit objects out, request response in a JSP page. b) With the help of an example explain JSP elements. 7. a) Draw a class diagram to show the relationships between the major classes in the servlet API. b) Explain servlet life cycle. 8. Write a short notes on : i) Sessions ii) Cookies iii) XML.

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 documents 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.

You might also like