ST Lab Manual1
ST Lab Manual1
ST Lab Manual1
Subject Code-322863(22)
1. Develop and demonstrate a XHTML file that includes Javascript script for the following problems:
a) Input: A number n obtained using prompt
Output: The first n Fibonacci numbers
b) Input: A number n obtained using prompt
Output: A table of numbers from 1 to n and their squares using alert
2. a) Develop and demonstrate, using Javascript script, a XHTML document that collects the USN ( the valid
format is: A digit from 1 to 4 followed by two upper-case characters followed by two digits followed by two
upper-case characters followed by three digits; no embedded spaces allowed) of the user. Event handler
must be included for the form element that collects this information to validate the input. Messages in the
alert windows must be produced when errors are detected.
b) Modify the above program to get the current semester also (restricted to be a number from 1 to 8)
3. a) Develop and demonstrate, using Javascript script, a XHTML document that contains three short
paragraphs of text, stacked on top of each other, with only enough of each showing so that the mouse cursor
can be placed over some part of them. When the cursor is placed over the exposed part of any paragraph, it
should rise to the top to become completely visible.
b) Modify the above document so that when a paragraph is moved from the top stacking position, it returns
to its original position rather than to the bottom.
4. a) Design an XML document to store information about a student in an engineering college affiliated to
VTU. The information must include USN, Name, Name of the College, Brach, Year of Joining, and e-mail
id. Make up sample data for 3 students. Create a CSS style sheet and use it to display the document.
b) Create an XSLT style sheet for one student element of the above document and use it to create a display
of that element.
5. a) Write a Perl program to display various Server Information like Server Name, Server Software, Server
protocol, CGI Revision etc.
b) Write a Perl program to accept UNIX command from a HTML form and to display the output of the
command executed.
6. a) Write a Perl program to accept the User Name and display a greeting message randomly chosen from a
list of 4 greeting messages.
b) Write a Perl program to keep track of the number of visitors visiting the web page and to display this
count of visitors, with proper headings.
7. Write a Perl program to display a digital clock which displays the current time of the server.
8. Write a Perl program to insert name and age information entered by the user into a table created using
MySQL and to display the current contents of this table.
9. Write a PHP program to store current date-time in a COOKIE and display the ‘Last visited on’ date-time on
the web page upon reopening of the same page.
10. Write a PHP program to store page views count in SESSION, to increment the count on each refresh, and to
show the count on web page.
11. Create a XHTML form with Name, Address Line 1, Address Line 2, and E-mail text fields. On submitting,
store the values in MySQL table. Retrieve and display the data based on Name.
12. Build a Rails application to accept book information viz. Accession number, title, authors, edition and
publisher from a web page and store the information in a database and to search for a book with the title
specified by the user and to display the search results with proper headings.
Laboratory Manual
Introduction
This lab is intended to give the students a sound knowledge in the
Web side programming. Before going in to the details of the lab, the pre-
requisites are the basic knowledge in HTML, XHTML, CSS, XML,
JavaScript, Perl, PHP and MySql. Let‟s look at some of these topics in brief
now.
Basics of HTML: -
Hyper Text Markup Language (HTML) is a markup language
developed by the W3C people. This can be used as an interface for working
our programs. We submit all our requests in the HTML form. It is basically
a markup language which describes how the documents are to be
formatted.
HTML has two basic entities, the “Tags” (Formatting commands) and
the strings within the tags called as the “Directives”. Most of the tags have
the following syntax: - <something> that indicates the beginning of the tag
and a </something> that indicates the end of the tag.
NOTE:
Tags can either be in lower case or upper case, i.e. there is no
difference between <html> and <HTML>
The order in which parameters of the tag are given is not significant
since each of these parameters is named.
HTML Essentials
An HTML file should be written in the following format and should be
saved with .html file extension.
<html>
<head>
<title> New Page </title>
1
</head>
2
<body>
TYPE YOUR TEXT HERE
</body>
</html>
The “New Page” title comes on the top of the Browser Window.
To create a Form
<form method=[GET/POST] action=[url]>
</form>
3
To create a Text Area
<textarea rows=2 name=S1 cols=20></textarea>
To create a Marquee (The Marquee tag ensures that the text scrolls
horizontally across the screen. It is usually used by advertisement sites to
catch the user‟s attention
<marquee align=middle>Type your text here</marquee>
(The basics colors can be given literally here. For a more elaborate set if colors,
Hex code of the colors can be given. Refer to the possible ranges of the Hex
codes in the Text Book)
2) <pre> - Preformatted text, ensures that the text appears exactly the
way it appears in the HTML code thereby preserving the white spaces
as well.
4
6) Tables:
<table>
<caption> Your Caption here </caption> [Optional Tag]
<tr>
<th> Row 1, Col 1 </th> [th implies Table Header]
<th> Row 2, Col 2 </th>
</tr>
<tr>
<td> Table Definition here </td>
<td>...............................</td>
</tr>
</table>
7) Comments:
< ! - - Your Comments here - - >
8) Background Images:
<body background = “pathname/abc.gif”>
…………………….
</body>
Before we move on further, we need to know how the web exactly works.
5
Serving Static Data – The server does not do any kind of the
processing. It merely obtains the data present on its local hard disk
and sends it back to the client.
Serving Dynamic Data – The Server does some processing in this case
like executing a program and then outputs the result of the program
back to the client as a response.
Serving Content with Embedded HTML – Here, an executable code is
present with the HTML file. It‟s not quite static or dynamic.
Hyper links to
heythere.com
Browser
abcd
TCP Connection
The Server: -
The Internet
Basics of CGI: -
CGI stands for Common Gateway Interface. It 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 the program. The program then processes that data and the server
passes the program‟s response back to the web browser.
6
Gateways are programs or scripts used to access information that is not
directly readable by the client.
Basics of Perl: -
1. It is an object-oriented language.
3. Perl is free format – white space can be scattered about to make the
code more readable.
7. Perl scripts are stored as Text files. When executed, the source text
file is first compiled into a “Byte Code”, an intermediate form, not text
or binary. Perl then interprets the byte code, executing it.
7
Basics of MySQL: -
For some of the programs in the Lab course, the MySQL database is to be
used. For that, the MySQL Server is to be started. The following steps are
to be performed in the same sequence on the Linux shell to start the server
and create the database along with the table.
# mysql
mysql> exit;
About PHP:
PHP is a server-side scripting language. The concept of php is
very similar to the JavaScipts or VBScipts. PHP server-side scripting
language is similar to JavaScript in many ways, as they both allow you
to embed little programs (scripts) into the HTML of a Web page.
8
The key difference between JavaScript and PHP:
The key difference between JavaScript and PHP is that, while the Web
browser interprets JavaScript once the Web page containing the script has
been downloaded, server-side scripting languages like PHP are interpreted
by the Web server before the page is even sent to the browser. Once
interpreted, the PHP code is replaced in the Web page by the results of the
script, so all the browser sees is a standard HTML file. The script processed
entirely by the server. Thus the designation: server-side scripting language.
HOW TO EMBED PHP INTO HTML:
Let‟s look at the example today.php shown below.
<html>
<head><title>Today's date</title></head>
<body>
<p>Today's date (according to this web server) is
<?php
Echo( date("l, f ds y.") );
?>
</body>
</html>
The above program shows the PHP code embeded in the HTML. Lines
between
<?php and ?> indicates the php code.
1. <?php means “begin php code”.
2. ?> means “end php code”.
The Web server is asked to interpret everything between these two
delimiters (<?php and ?>) and convert it to regular HTML code before
sending the Web page to a
browser that requests it. The browser is presented with something like this:
<html>
<head><title>Today's date</title></head>
<body>
<p>today's date (according to this web server)
is Wednesday, june 7th 2000.</p>
</body>
</html>
9
Apache Http Server:
The web server we are using here is Apache Http Server. It is freely
downloadable from the site www.apache.org. Once you have downloaded the
installer, double click on that and install it in to your system. Then go to start
menu programs Apache HTTP Server Control Apache Server. Then click on
start to start your server. Then open an Internet explorer and type
http://localhost:80/. The port number 80 is optional in the URL. If you have
successfully installed the server then you will get a screen shown below:
1
1)Develop and demonstrate a XHTML file that includes JavaScript for the
following problems:
Lab1a.html
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<body>
<script type="text/javascript">
var fib1=0,fib2=1,fibsum=0;
if(n>0)
if(n==1)
else
for(i=3;i<=n; i++)
1
fib1=fib2;
fib2=fibsum;
else
</script>
</body></html>
OUTPUT:Lab1a.html
1
Lab1b.html
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
if(n >0)
str=str+" \n"
alert(str)
else
</script>
</body></html>
1
OUTPUT:Lab1b.html
1
2)(a)Develop and demonstrate using java script, a XHTML document that
collects the USN (the valid format is :a digit from 1 to 4 followed by 2
upper case characters followed by 2 digits followed by 2 upper case
characters followed by 3 digits. No embedded spaces allowed) of the user.
Event handler must be included for the form element that collects this
information to validate the input. Messages in the alert windows must be
produced when errors are detected.
(b) Modify the above program to get the current semester also (Restricted
to be a no. from 1 to 8).
Lab2a.html
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script type="text/javascript">
var usn,regexp;
function formValidator()
usn = document.getElementById("field1");
regexp=/[1-4][A-Z][A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9][0-9]$/;
if(usn.value.length == 0)
alert("USN is empty");
return;
else if(!usn.value.match(regexp))
1
{
return;
</script>
<head><title>USN validator</title></head>
<body>
Where D stands for digit and U stands for upper case letter
</form>
</body>
</html>
1
OUTPUT:Lab2a.html
Run 1:
Run 2:
1
Lab2b.html
<?xml version = "1.0" encoding = "utf-8" ?>
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script type="text/javascript">
function formValidator()
var regexp1=/[1-4][A-Z][A-Z][0-9][0-9][A-Z][A-Z][0-9][0-
9][0-9]$/;
if(usn.value.length == 0||sem.value.length==0)
return;
if(usn.value.match(regexp1)&&sem.value.match(regexp2))
return;
if(!usn.value.match(regexp1))
return;
1
if(!sem.value.match(regexp2))
return;
</script>
<body>
</form>
</body>
</html>
1
OUTPUT:Lab2b.html
2
3) Develop and demonstrate, using javascript script, a XHTML document
that contains 3 short paragraphs of text, stacked on top of each other,
with only enough of each showing so that the mouse cursor can be placed
over some part of them. When the cursor is placed over exposed part of
any paragraph, it should rise to the top to become completely visible.
Lab3a.html
"http://www.w3.org/TR?xhtml11/DTD/xhtml11.dtd">
<html>
<script type="text/javascript">
var stack1="stack1";
function toTop(curStack)
var oldStack=document.getElementById(stack1).style;
oldStack.zIndex="0";
var newStack=document.getElementById(curStack).style;
newStack.zIndex="10";
stack1=curStack;
</script>
<style type="text/css">
.para1
2
{
position:absolute;top:30%;left:30%;z-index:0; width:200;
border:solid;padding:100;background-color:aqua;
.para2
position:absolute;top:35%;left:35%;z-index:0; width:200;
.para3
position:absolute;top:40%;left:40%;z-index:0;width:200;
</style>
<body>
</body>
</html>
2
OUTPUT: Lab3a.html: Stacking element shown without placing the mouse cursor.
Lab3b.html
"http://www.w3.org/TR?xhtml11/DTD/xhtml11.dtd">
<html>
<script type="text/javascript">
var stack1="stack1";
function toTop(curStack)
var oldStack=document.getElementById(stack1).style;
oldStack.zIndex="0";
var newStack=document.getElementById(curStack).style;
2
newStack.zIndex="10";
stack1=curStack;
</script>
<style type="text/css">
.para1
position:absolute;top:30%;left:30%;z-index:0; width:200;
border:solid;padding:100;background-color:aqua;
.para2
position:absolute;top:35%;left:35%;z-index:0;width:200;
.para3
position:absolute;top:40%;left:40%;z-index:0;width:200;
</style>
<body>
</body>
</html>
2
OUTPUT:Lab3b.html : Stacking elements without placing the mouse cursor
Even after placing the cursor on the element the stacked elements placed to their original place
b) Create an XSLT style sheet for one student element of the above
document and use it to create a display of that element.
2
Lab4a.xml
<student>PROGRAM 4a
<stud-info>Student Information</stud-info>
<stud1>
<usn>USN:4MH09IS058</usn>
<name>Name:Vishu</name>
<noc>COLLEGE:MIT</noc>
<branch>Branch:ISE</branch>
<yoj>YOJ:2009</yoj>
<eid>EID:[email protected]</eid>
</stud1>
<stud2>
<usn>USN:4MH09IS059</usn>
<name>Name:Aditya</name>
<noc>COLLEGE:MIT</noc>
<branch>Branch:ISE</branch>
<yoj>YOJ:2009</yoj>
<eid>EID:[email protected]</eid>
</stud2>
<stud3>
2
<usn>USN:4MH09IS062</usn>
<name>Name:Samarth</name>
<noc>COLLEGE:MIT</noc>
<branch>Branch:ISE</branch>
<yoj>YOJ:2009</yoj>
<eid>EID:[email protected]</eid>
</stud3>
</student>
Lab4a.css
stud-info
student
stud1
stud2
2
display : block; color:red;
stud3
usn,name,noc,branch,yoj,eid
{ display : block; }
OUTPUT: Lab4a.xml
Lab4b.xml
<stud>
<title>prog 6b</title>
<usn>4MH09IS058</usn>
2
<name>Vishwesh M</name>
<coll>MIT</coll>
<branch>ISE</branch>
<yoj>2009</yoj>
<eid>[email protected]</eid>
</stud>
Lab4b.xsl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<span style="font-size:20pt;color:blue">college:</span>
2
<span><xsl:value-of select="stud/coll" /><br /></span>
</xsl:template>
</xsl:stylesheet>
OUTPUT: Lab4b.xml
3
5a) Write a Perl program to display various server information like Server
Name, Server Software, Server protocol, CGI Revision etc.
To display the server information, five environment variables,
SERVER_NAME, SERVER_PORT, SERVER_SOFTWARE, SERVER_PROTOCOL,
and CGI_REVISION are used to print the name of the machine where the
server is running, the port the server is running on, the server software,
and the CGI revisions.
Perl Script: Lab5a.cgi
#!"C:\xampp\perl\bin\perl.exe"
use strict;
use CGI':standard';
header(),
start_html(-bgcolor=>"pink"),
hr(),
h2("Server Information"),
hr(),
hr(),
hr(),
hr(),
hr(),
hr(),
end_html();
3
OUTPUT: lab5a.cgi
OR
use strict;
use CGI':standard';
header(),
start_html(-bgcolor=>"yellow"),
hr(),h2("Server Information"),hr();
foreach my $parm(keys(%ENV))
print "$parm=$ENV{$parm}";
print "<hr>";
print end_html();
3
OUTPUT: lab5aa.cgi
3
5b) Write a Perl program to accept UNIX command from a HTML form and
to display the output of the command executed.
The HTML Page provides a simple interface to accept the UNIX command
from the user. After the command is entered, the Perl program is invoked.
The command entered by the user is sent via the Query String .
The Perl program has a “use CGI „: standard‟”. This “use” pragma ensures
that the program has access to all the methods that CGI.pm (Perl Module)
provides. The “standard” signifies that only appropriate functions are used
for the wide range of browsers. An alternate of this could be “use CGI „:
all‟”
The param() function is used to capture the parameters that are received
from the HTML page. This value is stored in a variable called “$comm”. To
execute the command, the back ticks (`) are used. An alternate approach to
this would be to use the system ( ) function
#!"C:\xampp\perl\bin\perl.exe"
use CGI':standard';
$c=param('com');
system($c);
exit(0);
Html : Lab5b.html
3
</form>
3
</body>
</html>
OUTPUT: Lab5b.html
3
6a) Write a Perl program to accept the username and display greeting
message randomly chosen from a list of greeting messages.
#!"C:\xampp\perl\bin\perl.exe"
use CGI':standard';
$n = int(rand($len));
if (param)
print header( );
print start_html(-bgcolor=>"pink");
$name=param("name");
print start_form();
print submit(-value=>"Back");
print end_form();
print end_html();
else
print header();
3
print start_form();
print textfield(-name=>"name"),br();
print end_form();
print end_html();
OUTPUT: lab6a.cgi
3
6b) Write a Perl program to keep track of number of visitors visiting the
web page and to display this count of visitors , with proper headings.
#!"C:\xampp\perl\bin\perl.exe"
$count=<FILE>;
close(FILE);
open(FILE, ">visit.txt");
$count++;
close(FILE);
Html : Lab6b.html
<html><body bgcolor="pink">
<form action="/cgi-bin/Lab6b.cgi">
</form>
</body>
</html>
3
OUTPUT: Lab6b.html
OR
#!"C:\xampp\perl\bin\perl.exe"
use CGI':standard';
print header();
print start_form();
open(FILE, "<visit.txt");
$count=<FILE>;
close(FILE);
4
open(FILE, ">visit.txt");
$count++;
close(FILE);
print end_form();
print end_html();
OUTPUT: Lab6b.cgi
4
7) Write a Perl program to display a digital clock which displays the
current time of the server.
In this program a digital clock which displays current time of the server has
to be displayed.
NOTE: Without using the meta tag, the time is displayed on the page and the
“Refresh” button is to be clicked each time to see the updated time. But by
making use of the meta tags, the time is updated automatically by the
browser. Since the page gets refreshed every second, the “Stop” button in
4
the browser may not be accessible. Hence close the Browser window to
stop the program.
4
Perl Script: Lab7.cgi
#!"C:\xampp\perl\bin\perl.exe"
use strict;
use CGI':standard';
my $ampm;
my($sec,$min,$hour)=localtime();
print header;
print start_html(-bgcolor=>"orange");
if($hour>12)
$hour=$hour-12;
$ampm="PM";
else
$ampm="AM";
print h2("$hour:$min:$sec:$ampm");
print end_html( );
4
OUTPUT: Lab7.cgi
4
8) Write a Perl program to insert name & age information entered by the
user into a table created using MySQL & to display the current contents
of this table.
4
The fetchrow ( ) function is used to loop through each record of the
table and the records are stored in the variables “$a” and “$b” and
these values are printed.
After this, ensure that you finish the statement handler and
disconnect from the server by making use of the finish ( ) and
disconnect ( ) functions respectively.
Html:Lab8.html
<html><body bgcolor="lightgreen">
</center></form>
</body></html>
Perlscript: Lab8.cgi
#!"C:\xampp\perl\bin\perl.exe"
use CGI':standard';
use DBI;
print "Content-type:text/html \n\n";
$nam=param("name");
$age=param("age");
$con=DBI->connect("DBI:mysql:college","root","");
$res=$con->prepare("insert into student values('$nam','$age')");
$res->execute();
$res=$con->prepare("select * from student");
$res->execute();
print "<html><body bgcolor=lightgreen>";
print "<center>THE CONTENTS OF THE DATABASE TABLE IS SHOWN
BELOW<br><br><table border=1>";
print "<tr><th>NAME</th><th>AGE</th></tr>";
while(@a=$res->fetchrow_array())
4
{
print "<tr><td>$a[0]</td><td>$a[1]</td></tr>";
}
print "</table></center>";
print res->finish();
print $con->disconnect();
print "</body></html>";
OUTPUT: Lab8.html
4
They house the client‟s state information. We can set cookies using
the setcookie() or setrawcookie() function. Cookies are part of the HTTP
header, so setcookie() must be called before any output is sent to the
browser.
Syntax:
setcookie (name,value,expire,path,domain);
<html>
<body bgcolor="aqua" text="red">
<?php
$duration=time()+60*60*24*60;
$found=0;
$visit=0;
if(isset($_COOKIE[$visit]))
{
$found=1;
$lastvisit=$_COOKIE[$visit];
}
setcookie($visit,date("m/d/y-G:i:s"),$duration);
print "<center>";
if($found==1)
{
print "<h2>Welcome back, You have visited on
$lastvisit</h2>";
}
else
{
print "<h3>Welcome to this website</h3>";
}
print "</center>";
?>
</body>
</html>
4
OUTPUT:Lab9.php
5
10) Write a PHP program to store page views count in SESSION, to
increment the count on each refresh, and to show the count on web page.
A PHP session variable is used to store information about, or change
settings for a user session. Session variables hold information about
one single user, and are available to all pages in one application.
A Session provides a mechanism to store the state information
between multiple interactions between a Client and a Server. They
are used as HTTP is a “Stateless Protocol”, i.e. each request is
independent of other.
Here we try to get the current session first. If there is no session
currently, server will automatically create a session when you
request.
PHP Script: Lab10.php
<?php
session_start();
print "<center>";
if(!isset($_SESSION))
$_SESSION["count"]=0;
else
$_SESSION["count"]++;
print "</center>";
5
?>
5
OUTPUT:Lab10.php
5
11) Create an XHTML form with Name, Address Line 1, Address Line 2
and E-mail text fields. On submitting, store the values in MySQL table.
Retrieve and display the data based on Name.
Html:Lab11.html
<html>
<body bgcolor="blue">
</form>
5
</body></html>
5
PHP script:Lab11.php
<html>
<body>
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
mysql_select_db("college");
VALUES ('$_POST[name]','$_POST[addr1]','$_POST[addr2]',
'$_POST[email]')";
if (!mysql_query($sql,$con))
mysql_close($con)
?>
</form>
</body>
</html>
5
PHP script:Lab11a.php
<html><body><?php
$con = mysql_connect("localhost","root","");
if (!$con)
mysql_select_db("college");
if(!$result)
<tr><th>Name</th><th>Addr1</th><th>Addr2</th><th>Email</th></tr>";
while($row = mysql_fetch_array($result))
echo "<tr>";
echo
"</tr>";
echo "</table>";
mysql_close($con);
?> </body></html>
5
OUTPUT:Lab11.html
Lab11.php
Lab11a.php
5
12)Build a Rails application to accept book information viz. Accession
number, title, authors, edition and publisher from a web page and store
the information in a database and to search for a book with the title
specified by the user and to display the search results with proper
headings.
Steps to be followed:
Step 1:Open Ruby console window from Instant Rails. In the command
prompt use the below code and create databases/tables and quit from
mysql.
mysql -u root
use lab12_development;
create table books (id int not null auto_increment, accno int not null, title
varchar(30) not null, author varchar(30) not null, edition int not null,
publisher varchar(30) not null,primary key(id));
After creating the database and table exit from mysql,by typing the command
exit
Step 2: In the command prompt type the below command to create a new
project named lab12.
rails -d mysql lab12 //database name and this should be same Step
3:Goto the lab12 folder by typing the command cd lab12.
Step 4:Type the below command to create the scaffold.
Note: Name in scaffold command should be singular of table name with first
letter caps.
http://localhost:3000/books
5
6
Step 7: Open one more Ruby console window using Instant Rails and
navigate to the lab12 folder.
Step 8: Inside the lab12 folder type the below command for creating a
controller named main.
ruby script/generate controller main
Step 9: Open the file main_controller.rb from C:\InstantRails-2.0-win\
rails_apps\lab12\app\controllers folder and replace the contents with the
below code.
def welcome
@num_books = Book.count
end
def result
@booktitle = params[:stitle]
end
end
<html>
<body>
<table border=1>
<tr><th>BookId</th><th>AccNo</th><th>Title</th><th>Author</th>
<th>Edition</th><th>Publisher</th></tr>
@id = bk.id
@accno=bk.accno
6
@title=bk.title
@edition=bk.edition
@publisher=bk.publisher %>
</tr>
</table>
</body>
</html>
<html>
</form>
</body>
</html>
following http://localhost:3000/main/welcome
6
6
VIVA QUESTIONS
4. What does the <br> and the <p> tag in HTML do?
6. What is the difference between Dynamic HTML and Dynamic Web Pages?
11. How do you declare arrays in Perl? Comment on how the print ( ) works
with arrays.
6
26. What do you mean by URI? Is it the same as URL?
29. What does the “-w” option in the Interpreter line in Perl Programs do?
32. What does the “short-circuit” logic operator used in languages like Perl,
Java do?
33. Why do you have to “use” a database that you have created in MySQL
before you perform other operations?
do?
39. Why is that the CGI Programs are also stored with a “.pl” extension?
Can the extension be changed to “.cgi”?
41. What do you mean by the “here” document? Comment on its uses.
44. What is the difference between doGet ( ) and doPost ( ) methods used in
Servlet Programming?
uses?
6
Viva Questions with answers:
As: The <hr /> tag is used to create an horizontal rule (line).
As: <b> for bold, <i> for italic, <u> for underline etc.
The <img> tag is empty, which means that it contains attributes only and it
has no closing tag.
To display an image on a page, you need to use the src attribute. Src stands
for "source". The value of the src attribute is the URL of the image you
want to display on your page. The syntax of defining an image: <img
src=”url/”>
6
12. Explain <table> tag used in HTML?
As: Tables are defined with the <table> tag. A table is divided into rows
(with the <tr> tag), and each row is divided into data cells (with the <td>
tag). The letters td stands for "table data," which is the content of a data
cell. A data cell can contain text, images, lists, paragraphs, forms,
horizontal rules, tables, etc.
As: three types of lists are available <ul> for unordered list, <ol> for
ordered list, <dl> for definition lists.
Form elements are elements that allow the user to enter information (like
text fields, textarea fields, drop-down menus, radio buttons, checkboxes,
etc.) in a form.A form is defined with the <form> tag.
As: HTML colors are defined using a hexadecimal (hex) notation for the
combination of Red, Green, and Blue color values (RGB). The lowest value
that can be given to one of the light sources is 0 (hex 00). The highest value
is 255 (hex FF). Hex values are written as 3 double digit numbers, starting
with a # sign.
As: With frames, you can display more than one HTML document in the
same browser window. Each HTML document is called a frame, and each
frame is independent of the others.The disadvantages of using frames are:
As: When a browser reads a style sheet, it will format the document
according to it. There are three ways of inserting a style sheet:
An external style sheet is ideal when the style is applied to many pages.
With an external style sheet, you can change the look of an entire Web site
by changing one file. Each page must link to the style sheet using the
<link> tag. The <link> tag goes inside the head section.
6
Internal Style Sheet
As: The CSS syntax is made up of three parts: a selector, a property and a
value:
data –
6
As: XML stands for EXtensible Markup
store data.
6
XML is important to know, and very easy to learn.
XML tags are not predefined, user has to define the tags
XML was designed to transport and store data, with focus on what data is.
HTML was designed to display data, with focus on how data looks.
XML documents must contain a root element. This element is "the parent"
of all other elements.
The elements in an XML document form a document tree. The tree starts at
the root and branches to the lowest level of the tree.
The terms parent, child, and sibling are used to describe the relationships
between elements. Parent elements have children. Children on the same
level are called siblings (brothers or sisters).
All elements can have text content and attributes (just like in HTML).
7
28. What are the syntax rules for XML document?
Element
As: An XML element is everything from (including) the element's start tag to
(including) the element's end tag.
<bookstore><book
category="CHILDREN">
<title>Harry Potter</title>
<author>J
Rowling</author>
<year>2005</year>
<price>29.99</price>
</book> <bo
category="WEB">
<title>Learning XML</titl
<author>Erik
Ray</author>
<year>2003</year>
<price>39.95</price>
</book> </bookstore>
7
XML tags are case sensitive
7
XML elements must be properly nested
XML attribute values must be quoted
31. What is a valid XML document?
As: A "Valid" XML document is a "Well Formed" XML document, which also
conforms to the rules of a Document Type Definition (DTD):
<?xml version="1.0" encoding="ISO-
8859-1"?> <!DOCTYPE note SYSTEM
"Note.dtd"> <note> <to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this
weekend!</body> </note>
The DOCTYPE declaration in the example above, is a reference to an external
DTD file. The content of the file is shown in the paragraph below.
32. What is the purpose of XML DTD?
As: The purpose of a DTD is to define the structure of an XML document. It
defines the structure with a list of legal elements:
33. What is PHP?
As: PHP is a powerful tool for making dynamic and interactive Web pages.
PHP is the widely-used, free, and efficient alternative to competitors such as
Microsoft's ASP.
PHP stands for PHP: Hypertext Preprocessor
PHP is a server-side scripting language, like ASP
PHP scripts are executed on the server
PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid,
PostgreSQL, Generic ODBC, etc.)
PHP is an open source software
PHP is free to download and use
34. Why PHP is popular than ASP?
As: PHP runs on different platforms (Windows, Linux, Unix, etc.)
PHP is compatible with almost all servers used today (Apache, IIS,
etc.) PHP is FREE to download from the official PHP resource:
www.php.net PHP is easy to learn and runs efficiently on the server
side
7
35. What is basic PHP syntax?
As: A PHP scripting block always starts with <?php and ends with ?>. A
PHP scripting block can be placed anywhere in the document.On servers
with shorthand support enabled you can start a scripting block with <? and
end with ?>.For maximum compatibility, we recommend that you use the
standard form (<?php) rather than the shorthand form.
36. Expand Perl?
As: Perl (Practical Extraction and Reporting Language) A scripting
language for web servers. Most often used on Unix servers
37. What is CGI script?
As: CGI scripts are executables that will execute on the server to produce
dynamic and interactive web pages. Most ISPs offer some kind of CGI
capabilities. ISPs often offer preinstalled, ready to run, guest-books, page-
counters, and chat-forums solutions in CGI.CGI is most common on Unix or
Linux servers.
38. Who developed PHP?
As: Rasmus Lerdorf
39. Who developed HTML and World Wide Web?
As: Tim Berners Lee
40. What is the use of HTTP protocol?
As: application-level protocol for distributed, collaborative, hypermedia
information systems
generic, stateless, object-oriented
can be used for many tasks, such as name servers & distributed object
management systems