Welcome

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.

Don't Forget to  or Comment..



-- get membership if you want more from this blog --

7 comments:

  1. thanks bro but what about 53&54 TB part

    ReplyDelete
  2. Thanks a lot brother...but plz upload the remaining part also.... Thanks again

    ReplyDelete
  3. thanks a lot sir

    ReplyDelete
  4. hi Bro plz upload 54 ta and tb

    ReplyDelete
  5. explain the relation between a servlet its servlet container and servlet API

    ReplyDelete

Leave Comments