Académique Documents
Professionnel Documents
Culture Documents
B.Sc.(I.T.)5th SEMESTER
WEB PROGRAMMING
CHITRANGADA CHAKRABORTY Roll Number: 131B1020
Today, the Internet and intranets are exploding like wildfire. The article, "VISA Moves to Intranet System," in the January 29, 1996, issue of Information Week states that "two thirds of all large companies either have an internal Web server installed or are thinking about it, and industry analysts believe that soon internal Web servers will outnumber external servers by a margin of 10 to 1. Forrester Research predicts the intranet server business will hit $1 billion by the year 2000." The daily announcements about new venture agreements, new application products, and new technology validate this prediction. In the nearly 30 years that I have worked in the computer industry, I cannot remember such an explosiveperiod.With all the excitement, one tends to forget that individuals laid the foundation for today's events in the late 1960s. The next three sections of this chapter look at the history, future, and fundamentals of the Internet, networks, and intranets. Then we devote four sections to the basics of TCP/IP networking. The chapter ends with a brief discussion of various applications, plug-ins, and applets.
Assignment: TA
1. What is the meaning of Web? Explain in detail the building elements of web
Web is a complex network of international, cross platform, 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 tha n 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.
WEB PROGRAMMING
Page 2
3. Give the different classification of HTML tags with examples for each category LIST OF HTML TAGS :Tags for Document Structure HTML: <HTML> <BODY> This is a small HTML file. </BODY> </HTML> HEAD:
<HEAD> <TITLE> Mozilla speaks out</TITLE> <BASE HREF="http://www.mozilla.com"> </HEAD>
WEB PROGRAMMING
Page 3
Heading Tags .TITLE: <html> <head> <title>HTML Reference</title> </head> <body> The content of the document...... </body> </html> BASE: <head> <base href="http://www.w3schools.com/images/" target="_blank"> </head> <body> <img src="stickman.gif" width="24" height="39" alt="Stickman"> <a href="http://www.w3schools.com">W3Schools</a> </body> META: <head> <meta name="description" content="Free Web tutorials"> <meta name="keywords" content="HTML,CSS,XML,JavaScript"> WEB PROGRAMMING Page 4
BLOCKQUOTE:
<BLOCKQUOTE> Bob Lisbonne, vice president of client product marketing at Netscape said: <BLOCKQUOTE> "Networked enterprises can begin to deploy Webtops as consistent corporate computing interfaces that span all platforms and can be updated dynamically." </BLOCKQUOTE> </BLOCKQUOTE>
DIV:
<DIV
WEB PROGRAMMING
Page 5
H1 through H6:
<H1 <H2 <H3 <H4 <H5 ALIGN="LEFT"|"CENTER"|"RIGHT">...</H1> ALIGN="LEFT"|"CENTER"|"RIGHT">...</H2> ALIGN="LEFT"|"CENTER"|"RIGHT">...</H3> ALIGN="LEFT"|"CENTER"|"RIGHT">...</H4> ALIGN="LEFT"|"CENTER"|"RIGHT">...</H5> <H6 ALIGN="LEFT"|"CENTER"|"RIGHT">...</H6>
P:
<P ALIGN="LEFT"|"CENTER"|"RIGHT" CLASS="styleClass" ID="namedPlaceOrStyle" LANG="ISO" STYLE="style" > ... </P>
PRE: <pre> Text in a pre element is displayed in a fixed-width font, and it preserves spaces and line breaks </pre> Lists: DD: <dl> <dt>Coffee</dt> <dd>Black hot drink</dd> <dt>Milk</dt> <dd>White cold drink</dd> </dl> DIR: <dir> <li>html</li> <li>xhtml</li>
WEB PROGRAMMING
Page 6
WEB PROGRAMMING
Page 9
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;
WEB PROGRAMMING
Page 11
WEB PROGRAMMING
Page 12
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
WEB PROGRAMMING
Page 13
8. What is PERL? Explain PERl control structures with the help of an example
Perl is a programming language which can be used for a large variety of tasks. A typical simple use of Perl would be for extracting information from a text file and printing out a report or for converting a text file into another form. But Perl provides a large number of tools for quite complicated problems, including systems programming. Programs written in Perl are called Perl scripts, whereas the term the perl program refers to the system program named perl for executing Perl scripts If you have used shell scripts or awk or sed or similar (Unix) utilities for various purposes, you will find that you can normally use Perl for those and many other purposes, and the code tends to be more compact. And if you haven't used such utilities but have started thinking you might have need for them, then perhaps what you really need to learn is Perl instead of all kinds of futilities. Perl is implemented as an interpreted (not compiled) language. Thus, the execution of a Perl script tends to use more CPU time than a corresponding C program, for instance. On the other hand, computers tend to get faster and faster, and writing something in Perl instead of C tends to save your time.
PERL control structures include: 1. If-else and unless condition: This construct performs a Boolean test on an expression and performs actions based on the results of the Boolean test. For example: If($var==1) { $out = "This was one"; } elseif($var==0) { $out = "This was zero"; } else { $out = "Was neither 0 nor 1"; } print "$out"; The above code will print, "This was one" if the variable $var is 1. Otherwise, if $var is equal to 0, it will print "This was zero". If $var is nether 1 nor 0, it will print "Was neither 0 nor 1". Note that the
WEB PROGRAMMING
Page 14
PART - A
WEB PROGRAMMING
Page 15
HTML
DHTML
HTML site work slowly upon client-side DHTML sites works faster upon clienttechnologies. side technologies
HTML is static in nature HTML files are saved with .htm extension
DHTML is dynamic in nature DHTML files are saved with .dhtm extension
HTML does not make use of any DHTML uses events, methods and methods for making it dynamic. HTML much more for providing dynamism for content is always static HTML pages HTML pages does not require any processing from browser DHTML requires processing from browser which changes its look and feel
WEB PROGRAMMING
Page 17
If such tools are used to develop the Web page layout, the generated HTML must then be manually embedded into servlet code. This process is time consuming and error prone.
PART - B II. Answer any FIVE full questions : 1. a) Explain GET and POST method with the help of an example. The GET Method
The foundation of HTTP/0.9 (the first implementation of the HTTP protocol) was the definition of the GET method that was used by a web browser to request a specific document. For example, the following HTTP request would return the document index.html that was located in the web servers root directory called webdocs. GET /webdocs/index.html CRLF Notice that the GET request began with the GET keyword, included a document to retrieve, and ended with a carriage return and line feed combination. Page 18
WEB PROGRAMMING
If you would like, you can try making a GET request by connecting to your favorite web server and sending the GET request yourself (as if you were a web browser).
WEB PROGRAMMING
Page 19
2. a)
With the help of an example explain the embedding of an image in an HTML tag.
To embed an image in an HTML page, you can use the <IMG> tag. The <IMG> tag includes various attributes, for embedding and formatting images in an HTML page. The most common attributes of the <IMG> tag are: SRC: Absolute or relative path of the image to be embedded LOWSRC: The path of the low resolution version the image ALT: Alternate text to be displayed in case the image cannot be loaded. ALIGN : Alignment of the image in the page HEIGHT: Height of the image WIDTH: Width of the image You can use the above tags to load an image from a URL or a relative path. For example, if the image (suppose image_filename.gif) that you want to embed resides in the same folder as the HTML page, you can embed it as: <IMG SRC="image_filename.gif" ALT = "this is an image loaded from a relative path"> The above will display the image in the file image_filename.gif. In case this image cannot be loaded, the text "this is an image loaded from a relative path" will be displayed. Similarly, to load an image from a URL, you can specify the URL in the SRC attribute. b) Create
The following HTML page, demonstrates the usage of anchor tags: <html> <head> WEB PROGRAMMING Page 20
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) { WEB PROGRAMMING Page 21
b) What
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 used inside of HTML documents. With JavaScript, we can make text scroll across the screen like ticker tape. The uses of JavaScript are: i). Control Document Appearance and Content ii). Control the Browser iii). Interact with Document Control iv). Interact with User v). Read and Write Client State with Cookies vi). Interact with Applets vii). JavaScript is only used inside of HTML documents
WEB PROGRAMMING
Page 22
b) Write a CGI application which accepts three numbers from the used and display biggest number using GET and POST methods.
#!/usr/bin/perl
WEB PROGRAMMING
Page 23
easy development, testing and deployment the version of the deployed application is easily identified all Java EE containers support .WAR files
One disadvantage of web deployment using WAR files in very dynamic environments is that minor changes cannot be made during runtime. Any change whatsoever requires regenerating and redeploying the entire WAR file. The following sample web.xml file demonstrates how a servlet is declared and associated. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" WEB PROGRAMMING Page 26
WEB PROGRAMMING
Page 27