Two Mark Questions
Two Mark Questions
B.Tech IT – IV SEM
TWO MARKS QUESTIONS AND ANSWERS
CODE / SUBJECT : IT3401/WEB ESSENTIALS
Unit -1
1. What is the difference between node and host?
A node is any addressable device connected to a network whereas the host is a more
specific descriptor that refers to a networked general-purpose computer rather than a single
purpose device (such as a printer).
3. Define protocol.
A protocol is a formal set of rules that must be followed in order to communicate.
5. Define encapsulation.
Placing the data inside a package of headers is known as encapsulation.
6. Define port.
A port is a logical channel to an application running on a host. ie., The applications
running on the host machines are uniquely identified by port numbers.
http://faculty.uscupstate.edu/atzacheva/lect
The
documen Host Path to File Denotes
t can be Name - the Web Name that the File
obtained The Page is Written in
using the Name HTML
1 of 2Web 3 HyperText
Hypertext
Protoco Server
Host Name File Name
Markup
Transfer
l
Protocol Language
(HTTP)
The components are host, an optional port, path, filename, and section and query string.
20. What are the sequences of steps for each HTTP request from a client to the server?
Making the connection
Making a request
The response
Closing the connection
Audio
Video
Model
Application
27. What are ISAPI (Internet Server API) and NSAPI (Netscape Server API)
ISAPI (Internet Server API): An API for Microsoft's IIS (Internet Information Server)
Web server. ISAPI enables programmers to develop Web-based applications that run much faster
than conventional CGI programs because they're more tightly integrated with the Web server. In
addition to IIS, several Web servers from companies other than Microsoft support ISAPI.
NSAPI -Netscape Server API: An API for Netscape's Web servers. NSAPI enables
programmers to create Web-based applications that are more sophisticated and run much faster
than applications based on CGI scripts.
The request methods tell the script how it was invoked. Based on this information, the
script decides how to act. The request method is passed to the script using environment variable
called REQUEST- METHOD. The two most common request methods used are GET and POST.
GET
GET is a request for data, the same method used for obtaining static documents. The
GET method sends request information as parameter tacked onto the end of the URL. These
parameters are passed to the CGI program in the environment variable QUERY-STRING.
E.g.: If the script is called myprog.exe and is invoked from a link with the form
POST
POST operation occurs when the browser sends data from a fill-in form to the server.
With POST, the QUERY_STRING mayor may not be blank, depending on the server. The data
from a POSTed query gets passed from the server to the script using STDIN. Because STDIN is
a stream and the script needs to know how much valid data is waiting, the server also supplies
another variable, CONTENT_LENGTH, to indicate the size in bytes of the incoming "data. The
format for POSTed data is
After the required data is available, the script executes and writes its output to the
STDOUT. The MIME code that the server sends to the browser indicates the type of the file that
is being sent. This information that precedes the file is usually called the header. Since the script
generates the output on the fly the server will not be able to create a header for that information.
Hence this information has to be supplied by the script itself. Failure will result in the browser
receiving information that it does not know how to display.
The variables or name value pairs are separated by '&'. Real ampersand is escaped –that
is, encoded as a two-digit hexadecimal value representing the character. Escaped characters are
indicated in URL-encoded string by the percent (%) sign. Blank spaces are replaced by '+' sign.
Before the script can deal with the data it has to parse and decode it. The script scans
through the string looking for an ampersand. When it is found the string is broken from that
point. The variable's name is everything up to the equal sign in the string and the value is
everything after the equal sign. The script continues to parse the original string for the next
ampersand, and so on until the original string is exhausted. After the variables are separated, they
are decoded as follows.
In addition to basic connectivity, many ISP’s also offer related Internet services like
email, web hosting and access to software tools
45. Define client and server system. Write any two examples for a client server
Web server
Web client 2
Web client 3
The server waits for a client to connect and then it provides a service. Webserver sends the
browser the files it requests.
Application Server:
This server acts an independent or an interface unit along with database server
application servers holds all the business logic within it.
Database Server:
The server is the key server for all business services. The organization day-to-day
Transactions are stored here.
The success of any online business is the communication link between consumer,
producer, management and employers which are mainly supported by the server.
Client-side scripts are often embedded within an HTML document (hence known as an
"embedded script"), but they may also be contained in a separate file, which is referenced by the
document (or documents) that use it (hence known as an "external script"). Upon request, the
necessary files are sent to the user's computer by the web server (or servers) on which they
reside. The user's web browser executes the script, then displays the document, including any
visible output from the script. Client-side scripts may also contain instructions for the browser to
follow if the user interacts with the document in a certain way, e.g., clicks a certain button. These
instructions can be followed without further communication with the server, though they may
require such communication.
47. Name the four services offered by internet and specify their default port number
It is a Network:
It is a loose organization:
It’s a relaxing place
It is a Business tool:
It is a Mail box:
It is an information pool:
Default port number is 80
replace the network ID with all zeroes but leave the host ID alone, the resulting address
means “the device with the host ID given, on this network”. Or alternatively, “the device
with the host ID specified, on the default network or the current network”.
o All Ones: When the network ID or host ID bits are replaced by a set of all ones, this has
the special meaning of “all”. So replacing the host ID with all ones means the IP address
refers to all hosts on the network. This is generally used as a broadcast address for
sending a message to “everyone”.
50. What are the components of web? What is the communication protocol between them?
A web server us a computer that is connected to the Internet that has software capable of storing,
retrieving and distributing some of the web application files.
A web client (web browser) is a computer that requests file, from the web. When a client is
requesting for a file is the web the network directs the request to the web server where the file
has been available Web server by accepting requests sends the file to the client.
Web Client / web Web Server
Browser Internet
The web server and client may be running different Operating System, software and
hardware so that a well defined set of languages and protocols are required that are independent
of the hardware or operating system on which they run.
3. Web Pages:
A Webpage is a HTML document that is stored in a web server and that has an URL so
that it can be accessed via the web.
Website: www.annauniv.org
Webpage: www.annauniv.org/index.html
4. Home Page:
A Home page is the front door of the web site. Sometimes homepage may not be visible
to the user. It can be configured in the web browser.
5. Web Browser:
A web browser is a software tool that computers use to communicate with web servers on
the Internet.
It enables to download and display the web pages that user requests.
A web browser should be capable of understanding HTML and display text.
It supports pictures, video, sound and even 3d images.
In the address bar of the browser, type of URL and it will display the web pages.
6. Offline Browser:
It is a pull product that enables the users to retrieve web pages automatically from their
websites during the prescribed time.
7. Web Sites:
Absolute paths are called that because they refer to the very specific location, including
the domain name. The absolute path to a Web element is also often referred to as the URL. For
example, the absolute path to this Web page is:
http://webdesign.about.com/library/weekly/aa040502a.htm
Relative Path URLs
Relative paths change depending upon what page the links are located on. There are several rules
to creating a link using the relative path:
links in the same directory as the page have no path information listed
filename
sub-directories are listed without any preceding slashes
weekly/filename
links up one directory are listed as
../filename
52. List out the devices used to form Internet work and specify each one of its purpose
(Apr/May 2008)
IP ADDRESSES DOMAIN NAMES
Every device
Human
connected has a DNS
Readable
unique 32-bit
cnn.com
address
Translation Every device
Machine connected
Between domain
Readable has an
e.g. Names and IP
Addresses alphanumeric
151.196.19.22 address
Each host computer on the has a unique number and it is called as Internet Protocol Address (IP
Address)
Format: A.B.C.D
A container tag is one that activates an effect and that has a companion tag that
discontinues the effect. For example, <I> is a container tag that, together with its
companion closing tag </I>, causes all text found between them to be rendered in italic.
The <I> tag turns on the italic effect and the </I> tag turns it off.
A standalone tag or empty tags is one that does not have a companion tag. For
example, the <IMG> tag simply places an image on a page. <IMG> has no effect that
was turned on and needs to be turned off, so no closing tag is needed.
10. What is meant by attribute? List out the some of the Global HTML attributes.
Although most tag attributes tend to be unique to the tag, some are almost universal and
usable with any tag. Table 3.1 summarizes these attributes, showing which tags do take
the attributes and how each attribute is used.
TABLE 3.1 Global HTML Attributes
Attribute Purpose Used With
Thus, when a user clicks the Submit button, the scripted function named "validate" fires
and checks the data the user is submitting for appropriate formatting, content, or other
validation checks.
12. How we can classify the text level formatting tags?(refer table)
13. List out the tags used for font formatting. (refer table)
14. List out the tags used for phrase formatting. (refer table)
15. List out the tags used for block level formatting. (refer table)
16. Enumerate the different types of List created by the list tag.
Definition lists
Directory lists (deprecated)
Menu lists (deprecated)
Ordered (numbered) lists
Unordered (bulleted) lists
1. <A>
Type: Container
Function: This helps make navigating a large document easier because we can set up anchors
at the start of major sections and then place a set of links at the top of the document that
points to the anchors at the beginning of each section.
Syntax:
18. Explain the attributes used with image and imagemap tags.
<IMG SRC="URL_of_image_file"
WIDTH="width_in_pixels" HEIGHT="height_in_pixels"
ALT="text_description" BORDER="thickness_in_pixels"
ALIGN="TOP|MIDDLE|BOTTOM|LEFT|RIGHT"
HSPACE="horizontal_spacing_in_pixels"
VSAPCE="vertical_spacing_in_pixels"
LONGDESC="URL_of_long_description"
ISMAP USEMAP="map_name">
19. State about the different usage of HTML frames. (APR/MAY 2008)
Framed layouts are ones in which the browser window is broken into multiple regions called
frames. Each frame can contain a distinct HTML document, enabling you to display several
documents at once, rather than just one screen all the time, while other parts of the page
change.
20. Write the HTML code for creating multi – line text box with necessary
parameters(May/June 2009)
<TEXTAREA NAME="field_name" ROWS="number_of_rows"
COLS="number_of_columns"
DISABLED READONLY
ACCESSKEY="shortcut_key_letter" TABINDEX="tab_position">
... default text to appear in window ...
</TEXTAREA>
21. What is meant by CSS? (Nov/Dec 2008)
CSS stands for Cascading Style Sheets
Styles define how to display HTML elements
Styles are normally stored in Style Sheets
Styles were added to HTML 4.0 to solve a problem
External Style Sheets can save you a lot of work
External Style Sheets are stored in CSS files
Multiple style definitions will cascade into one
To use inline styles we use the style attribute in the relevant tag.
The style attribute can contain any CSS property. The example shows how to change
the color and the left margin of a paragraph:
<p style="color: sienna; margin-left: 20px">
This is a paragraph
</p>
26. What are the keyboards events can be designed on a page using DHTML?
Keyboard events
onhelp Fires when the user initiates help (i.e., by pressing the F1 key).
onkeydown Fires when the user pushes down a key.
onkeypress Fires when the user presses a key.
27. What are the mouse events can be designed on a page using DHTML?
Mouse events
oncontextmenu Fires when the context menu is shown (right-click).
ondblclick Fires when the mouse is double clicked.
ondrag Fires during a mouse drag.
ondragend Fires when a mouse drag ends.
ondragenter Fires when something is dragged onto an area.
ondragleave Fires when something is dragged out of an area.
ondragover Fires when a drag is held over an area.
ondragstart Fires when a mouse drag begins.
ondrop Fires when a mouse button is released over a valid target
during a drag.
onmousedown Fires when a mouse button is pressed down.
onmouseup Fires when a mouse button is released.
29. Which function can be used to create an Alert popup dialog box? Write an example
to create an Alert popup box. (NOV/DEC 2007)
<HTML>
<HEAD>
<TITLE>Object Model</TITLE>
</HEAD>
</BODY>
</HTML>
30. State the commands in cascading style sheet used for grouping of elements.
(NOV/DEC 2007)
We can group selectors. Separate each selector with a comma. In the example below we
have grouped all the header elements. Each header element will be green:
h1,h2,h3,h4,h5,h6
{
color: green
}
Object Description
Window The window object is the top level object in the DHTML DOM. It
contains information about the window and the frames
Document The document object represents the HTML document, and is used
to access the HTML elements inside the document
Navigator The navigator object contains information about the user's browser
Event The event object contains information about events that occurs
UNIT-III
1. What is the difference between Vbscript and Java script?
JavaScript is case sensitive and also it is used on client side mainly for checking form
validations.. vbscript is mainly used on the server side.. i.e. for server side validations.. along
with asp code.. also vbscript is the default language for asp.. most of the tasks which are
complicated or based on some logic are very easy in vbscript like .. to check the blank field
validation we just need to use trim function and pass the value as parameter in vbscript which is
not possible in JavaScript
JavaScript
==============
Javascript case sensitive.
Javascript will be run on client side.
VBScript
==============
VBScript not case sensitive.
VBScript will be run on server side.
Arithmetic
Logical
Conditional
Comparison
Assignment
3. Write a script code to call a function with argument using java script.
<html>
<head>
<script type="text/javascript">
function myfunction(txt)
{
alert(txt)
}
</script>
</head>
<body>
<form>
<input type="button"
onclick="myfunction('Hello')"
value="Call function">
</form>
<p>By pressing the button, a function with an argument will be called. The function will
alert
this argument.</p>
</body>
</html>
<html>
<head>
<script language=javascript>
function openwindow()
{
window.open("http://www.microsoft.com/")
window.open("http://www.w3schools.com/")
}
</script>
</head>
<body>
<form>
<input type=button value="Open Windows" onclick="openwindow()">
</form>
</body>
</html>
6. Write down the benefits of java script code in an HTML document (NOV/DEC
2007)
JavaScript gives HTML designers a programming tool - HTML authors are normally not
programmers, but JavaScript is a scripting language with a very simple syntax! Almost
anyone can put small "snippets" of code into their HTML pages
JavaScript can put dynamic text into an HTML page - A JavaScript statement like this:
document.write("<h1>" + name + "</h1>") can write a variable text into an HTML page
JavaScript can react to events - A JavaScript can be set to execute when something
happens, like when a page has finished loading or when a user clicks on an HTML
element
JavaScript can read and write HTML elements - A JavaScript can read and change the
content of an HTML element
JavaScript can be used to validate data - A JavaScript can be used to validate form data
before it is submitted to a server, this will save the server from extra processing
7. For the following form, write down the JavaScript code to swap the contents of the
two text boxes
<FORMNAME=”DaForm”>
Input text 1: <INPUT TYPE=”TEXT” NAME=”A”>
Inputtext 2: <INPUT TYPE=”TEXT” NAME=”B”>
</FORM> (NOV/DEC 2007)
<html>
<head>
<title>swapAJN.html</title>
<script type="text/javascript">
function swap(oField1, oField2){
onchange="this.value=this.value.toUpperCase();" />
<input type="text" name="caps2" size="40" value=""
onchange="this.value=this.value.toUpperCase();" />
<input type="button" value="Swap" onclick="swap(this.form.caps1, this.form.caps2)" />
</form>
</body>
</html>
8. List out the objects involved in Java Script with its purpose. (APR/MAY 2008)
(refer java script objects)
10. Comment on the statement “ each object of a class has its own instance of static
member variable(Nov/Dec 2008)
Member variables are declared within the opening and closing braces of the class
body and outside of any method declarations for the class. Typically they are declared as
the first thing in the class body, but they don’t have to be. Some programmers’ put all
their variable declarations at the end of the class body. Member variables fall in to two
groups: instance variables and static variables
Instance variables hold data which is unique for each object instance. Each
instance has its own copy of the variable. For example, if we created a human class, we
might have an instance variable called name. As we created instances of the class, we
would assign each instance a name which would be held in the name variable
Static variables should be thought of as belonging to the class as a whole. Every
instance that accesses a given static variable will see the same data because there is only a
single copy of it. For example, the human class could have a static variable called
population count that holds the number of instances currently in existence.
Client-side scripts are often embedded within an HTML document (hence known as an
"embedded script"), but they may also be contained in a separate file, which is referenced by the
document (or documents) that use it (hence known as an "external script"). Upon request, the
necessary files are sent to the user's computer by the web server (or servers) on which they
reside. The user's web browser executes the script, and then displays the document, including
any visible output from the script. Client-side scripts may also contain instructions for the
browser to follow if the user interacts with the document in a certain way, e.g., clicks a certain
button. These instructions can be followed without further communication with the server,
though they may require such communication.
UNIT-IV
1. What is Variable? How variables are declared in PHP?
o Integers: are whole numbers, without a decimal point, like 4195.
o Doubles: are floating-point numbers, like 3.14159 or 49.1.
o Booleans: have only two possible values either true or false.
o NULL: is a special type that only has one value: NULL.
o Strings: are sequences of characters, like 'PHP supports string operations.'
o Arrays: are named and indexed collections of other values.
o Objects: are instances of programmer-defined classes, which can package up
both other kinds of values and functions that are specific to the class.
o Resources: are special variables that hold references to resources external to PHP
(such as database connections
2. What is PhP?
PHP - Hypertext Preprocessor -one of the most popular server-side scripting languages for
creating dynamic Web pages. - an open-source technology - platform independent
3. List the features of PhP.
Simplicity
Efficiency
Security
Flexibility
Familiarity
1. List possible data types available in PHP.
<?php
// This is a single-line comment
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
Syntax
$x=100; //100 is an expression
$a=$b+$c; //b+$c is an expression
$c=add($a,$b); //add($a,$b) is an expresson
$val=sqrt(100); //sqrt(100) is an expression
$var=$x!=$y; //$x!=$y is an expression
In PHP, data-type conversion can be performed by passing the data type as an argument to
function settype. Function settype takes two arguments: The variable whose data type is to be
changed and the variable ’s new data type. E.g., settype( $testString, "double" );
8. Write the uses of text manipulation with regular expression in PHP.
PHP processes text data easily and efficiently, enabling straightforward searching,
substitution, extraction and concatenation of strings.
Text manipulation in PHP is usually done with regular expressions — a series of
characters that serve as pattern-matching templates (or search criteria) in strings, text
files and databases.
This feature allows complex searching and string processing to be performed using
relatively simple expressions
9. How to Include PHP in a Web Page?
There are 4 ways of including PHP in a web page
<html>
<head>
<title>Hello World</title>
<body>
<?php echo "Hello, World!";?>
</body>
</html>
<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
?>
</body>
</html>
12. Write a PHP script to set the background colour to blue on Tuesday in a given date
<?php
$day=date("l");
switch($day)
{
case 'Monday':
$bg_color = "red";
break;
case 'Tuesday':
$bg_color = "blue";
break;
case 'Wednesday':
$bg_color = "blue";
break;
case 'Thursday':
$bg_color = "gray";
break;
case 'Friday':
$bg_color = "yellow";
break;
case 'Saturday':
$bg_color = "green";
break;
case 'Sunday':
default:
$bg_color = "black";
break;
}
echo "
Welcome to my Homepage
";
?>
13. What is cookie? Give example in PHP
A cookie is a text string stored on the client machine by your script (to track
users and manage transactions). Cookies are automatically returned (by the
client), and can be accessed using a variable of the same name
• The following script reads and displays a cookie, and sets it with a new value
(string) that was passed to the script as a parameter.
• The cookie will expire after 20 minutes (1200 seconds)
<?php setCookie("CookieTest", $val, time()+1200); ?>
<html>
<head><title>Welcome</title></head>
<body>
<?php echo("<h2>The cookie is: $CookieTest</h1>
</body>
</html>
3. What are the stages in the life cycle of servlet? (APR/MAY 2008) (Nov/Dec 2008)
The interface that declares this framework is the javax.servlet. Servlet interface. The servlet
Interface defines the life cycle methods. These methods are init(), service(), and destroy().
init()
The init() method is where the servlet's life begins. It is called by the server immediately after
the Servlet is instantiated. It is called only once. In the init() method, the servlet creates and
initializes any Resources, including data members, that it will be using while handling
requests. The init() method's Signature is defined as follows:
The init() method takes a ServletConfig object as a parameter. You should save this object so
that It can be referenced later. The most common way of doing this is to have the init()
method call Super.init(), passing it the ServletConfig object. You will also notice that the
init() method can throw a servletexception. If, for some reason, the Servlet cannot initialize
the resources necessary to handle requests, the init() method will throw a Servletexception.
service()
The service() method handles all requests sent by a client. It cannot start servicing requests
until the init() method has been executed. You will not usually implement this method
directly, unless you extend the GenericServlet abstract class.
The most common implementation of the service() method is in the HttpServlet class. The
HttpServlet class implements the servlet interface by extending GenericServlet. Its service()
Method supports standard http/1.1 requests by determining the request type and calling the
appropriate Method.
The service() method implements a request and response paradigm. The servletrequest object
Contains information about the service request, encapsulating information provided by the
client. The Servletresponse object contains the information returned to the client.
destroy()
This method signifies the end of a servlet's life. When a service is being shut down, it calls
the servlet's destroy() method. This is where any resources that were created in the init()
method will be cleaned Up. If you have an open database connection, you should close it
here. This is also a good place to save any persistent information that will be used the next
time the servlet is loaded.
The signature of the destroy() is :
Public void destroy();
When the HttpServlet.service() method is invoked, it reads the method type stored in the
request And determines which method to invoke based upon this value. These are the
methods that you will want to override. If the method type is GET, it will call doGet(). If the
method type is POST, it will call doPost(). There are five other method types and these will
be covered later in this chapter. All these Methods have the same parameter list as the
service() method.
Method Description
doDelete Called in response to an HTTP delete request. Such a request is normally
used to delete a file from a server. This may not be available on some
servers, because of its inherent security risks (e.g., the client could delete
a file that is critical to the execution of the server or an application).
doHead Called in response to an HTTP head request. Such a request is normally
used when the client only wants the headers of a response, such as the
content type and content length of the response
doOption Called in response to an HTTP options request. This returns information
s to the client indicating the HTTP options supported by the server, such as
the version of HTTP (1.0 or 1.1) and the request methods the server
supports.
doPut Called in response to an HTTP put request. Such a request is normally
used to store a file on the server. This may not be available on some
servers, because of its inherent security risks (e.g., the client could place
an executable application on the server, which, if executed, could damage
the server— perhaps by deleting critical files or occupying resources).
The two objects that the service() method receives are ServletRequest and ServletResponse.
The ServletRequest object holds the information that is being sent to the servlet, whereas the
ServletResponse object is where you place the data you want to send back to the server.
Figure 5.3 Diagrams the flow of a GenericServlet request.
8. What is servlet? How do you compare servlet and traditional CGI programs?
(NOV/DEC 2007)
Both are server-side technologies, but CGI programs execute in their own shell, at run-time
they create there own shell, and it involves an heavy weight activity. but where as servlets
can be requested using different threads.
Advantages of CGI:
Can be written in variety of languages ,primarily written in perl
Bugs does not crash the web server
Easy for reference
Execute in their own OS Shell, doesn’t have concurrency conflicts
All service providers support CGI Programs
Disadvantages:
Response time is high, the creation of an OS Shell is an heavy weight activity
CGI is not scalable
Not always secure or object-oriented
No separation of presentation and business logic
Scripting languages are often platform-dependent
Type 4 drivers are the most direct of the lot. Written entirely in Java, Type 4 drivers
understand database-specific networking protocols and can access the database directly
without any additional software.
The method to program cookies is different for different languages. Most of the
language provide some class that covers all the details of cookie creation and maintenance.
For example in Java you have a javax.servlet.http.Cookie class that is used to work with
cookies.
12. Write and explain any one method of servlet interface(May/June 2009)
Servlet interface methods (package javax.servlet).
Method Description
void init( ServletConfig The servlet container calls this method once during a servlet’s
config ) execution cycle to initialize the servlet. The ServletConfig
argument is supplied by the servlet container that executes the
servlet
ServletConfig This method returns a reference to an object that implements
getServletConfig() interface ServletConfig. This object provides access to the
servlet’s configuration information such as servlet initialization
parameters and the servlet’s ServletContext, which provides the
servlet with access to its environment
(i.e., the servlet container in which the servlet executes).
String getServletInfo() This method is defined by a servlet programmer to return a string
. containing servlet information such as the servlet’s author and
version
void The servlet container calls this method to respond to a client
service( ServletRequest request to the servlet
request,
ServletResponse
response )