Documente Academic
Documente Profesional
Documente Cultură
Faculty of Engineering
Department of Computer Engineering & Information Technology
Solution of Assignment#1
Q1) Define the terms: a) Internet b) WWW c) Modem d) Router.
ANS:
a) Internet:-Internet refers to the electronic network of networks that connects individuals and
information by means of computers and other digital instruments permitting person-to-person
communication and information recovery. With this definition, one can infer that nowadays, the use
of internet is primarily for the exchange of information.
b) WWW:-The World Wide Web is a system of interlinked hypertext documents accessed via the
Internet. With a web browser, one can view web pages that may contain text, images, videos, and
other multimedia and navigate between them via hyperlinks.
c) Modem:-A modem (modulator-demodulator) is a device that modulates an analog carrier signal to
encode digital information, and also demodulates such a carrier signal to decode the transmitted
information. The goal is to produce a signal that can be transmitted easily and decoded to reproduce
the original digital data. Modems can be used over any means of transmitting analog signals, from
light emitting diodes to radio. The most familiar example is a voice band modem that turns the digital
data of a personal computer into modulated electrical signals in the voice frequency range of a
telephone channel. These signals can be transmitted over telephone lines and demodulated by
another modem at the receiver side to recover the digital data.
d) Router:- A router is a device that forwards data packets between computer networks, creating an
overlay internetwork. A router is connected to two or more data lines from different networks. When
a data packet comes in on one of the lines, the router reads the address information in the packet to
determine its ultimate destination. Then, using information in its routing table or routing policy, it
directs the packet to the next network on its journey. Routers perform the "traffic directing"
functions on the Internet.
Representation of bits.
Data rate.
Synchronization of bits.
Line configuration.
Physical topology.
Transmission mode.
4. Error control.
5. Access control.
Layer:-03 Network Layer
The network layer is responsible for the source-to-destination delivery of a packet,
possibly across multiple networks (links). the network
layer ensures that each packet gets from its point of origin to its final destination.
Other responsibilities of the network layer include the following:
1. Logical addressing.
2. Routing.
Layer:-04 Transport Layer
The transport layer is responsible for process-to-process delivery of the entire message
The transport layer,
on the other hand, ensures that the whole message arrives intact and in order, overseeing
both error control and flow control at the source-to-destination level.
Other responsibilities of the transport layer include the following:
1.
2.
3.
4.
5.
Service-point addressing.
Segmentation and reassembly.
Connection control
Flow control.
Error control.
Layer-07Application Layer
The application layer enables the user, whether human or software, to access the network.
It provides user interfaces and support for services such as electronic mail,
remote file access and transfer, shared database management, and other types of distributed
information services.
Specific services provided by the application layer include the following:
1.
2.
3.
4.
Q3) Explain various protocols used in the network layer. Explain their use and ports they use.
Q4) Explain the role of HTTP protocol in the client server communication.
ANS:
HTTP takes port in web browser communication. Hence it is called a communication protocol.
The basic feature of HTTP protocol is that it follows the request response model.
The client makes a request for desired web page by giving the URL in address bar.
This request is submitted to the web server and thenweb server gives the response to the web
browser by returning the required web page.
GET
POST
HEAD
OPTION
PUT
DELETE
TRACE
After request URL is used to identify the names or resources on the Internet.
Because the connection between the web server and the browser is not maintained. A request is
made to the server, and the server sends back stuff to the browser and disconnects.
It does not care who you are, it just needs to know where to send the data. For this reason, the
concept of sessions came to be.
For interactive content you have to maintain a connection, or at least a logical connection via a
session. Whatever service you are connecting to has to understand who you are, and that the
traffic you are sending is all part of the same session.
The Internet is an insecure network and as a result your connections over this network are not
secure.
The goal of secure connections is to provide a secure channel over this insecure network.
These connections are done over encrypted protocols so that your data cannot be deciphered and
you can be sure that the server you are talking to is the authentic and intended one.
Without using secure connections, your internet traffic can be listened to by anyone who wants to
eavesdrop on your email that you are sending and receiving, the contents of your web traffic, and
worse they can easily obtain your login and password credentials, or impersonate our servers.
Secure connections ensures reasonable protection from eavesdroppers andimpersonators.
Information resources may contain hyperlinks to other information resources. Each link contains the URI
of a resource to go to. When a link is clicked, the browser navigates to the resource indicated by the link's
target URI, and the process of bringing content to the user begins again.
Deadline: 21/1/2012
Solution of Assignment#2
Short Questions (Hand written)
1) List three characteristics of HTML that make it ideal for the World Wide Web.
Ans. HTML is ideal for the Web because it is an open, nonproprietary language that is crossplatform compatible. All of the markup tags are included with every document and usually can be
viewed through your browser.
2) What improvements does XHTML promise over existing HTML?
Ans. One of the significant advantages of making HTML part of XML is that XML has stricter code
syntax. As more sites adopt XHTML, they will have to clean up code that does not match the
standard. With more Web sites using cleaner code, browsers have to do less work judging what is
correct code and what is not. Additionally, XHTML is designed to appear properly in browsers that
support HTML 4.0.
3) Explain the three issues you should consider when designing for multiple operating systems.
Ans. Monitors and display software, browser versions, and font choices
4) Describe some common reasons HTML code might not validate correctly.
Ans. The most common mistakes that will make your code invalid include:
>
Rowspan Colspan
Ans. Colspan and rowspan are html attributes used to span table cells across more than a column
or row. Colspan is short for column span or indicates how many across while a rowspan
indicates how many down .
Faculty Name
Prof. Ashish G.
Revar (AGR)
Depart
ment
CE/IT
Subject/Subject
code
WAD(160705)
WTP(161602)
Semester
/Branch
6th CE
6th IT
Issued Date
30/1/2012
Due Date
3/2/2012
Solution of Assignment#3
1) What are the two parts of a style rule?
Ans. A style rule is composed of two parts: a selector and a declaration.
2) What are the three ways to combine CSS rules with your XHTML code?
Ans. You can combine CSS rules with XHTML code in the following three ways:
1) The style attribute
2) The <style> element
3) An external style sheet
3) List two reasons to state a style using the style attribute.
Ans. You generally use the style attribute to override a style that was set at a higher
level in the document, as when you want a particular heading to be a different color
from the rest of the headings on the page. The style attribute is also useful for
testing styles during development.
4) What are the advantages of using an external style sheet?
Ans. Placing style sheets in an external document lets you specify rules for multiple
Web pages.
5) Write a style rule that selects <ul> elements only when they appear within <p>
elements and set the color property to red.
Ans. p ul {color: red;}
6) What is the advantage of working with the id attribute?
Ans. Because id refers to only one instance of the id attribute value within a
document, this allows you to specify an id value and apply it to one unique element
in a document.
7) Explain CSS Box model.
Ans. The CSS Box Model
All HTML elements can be considered as boxes. In CSS, the term "box model" is used
when talking about design and layout.
Example
a:link {color:#FF0000;} /* unvisited link */
a:visited {color:#00FF00;} /* visited link */
a:hover {color:#FF00FF;} /* mouse over link */
a:active {color:#0000FF;} /* selected link */
Faculty Name
Department
CE/IT
Subject/Subject
code
WAD(160705)
WTP(161602)
Semester/Branch
6th CE
6th IT
Solution of Assignment # 4
1. What is difference between Java script and JAVA?
ANS:
Difference between Java and JavaScript
Java is an object oriented programming language whereas JavaScript is more of a
scripting language.
JavaScript is used to make the web pages more interactive. However, Java can be used not
only to make interactive web pages but can also be used to create server side applications
and standalone programming.
Java uses the concept of classes and objects that makes reuse of the code easier but there
is no such thing in JavaScript.
Java exhibits the properties like inheritance, data encapsulation and polymorphism
whereas JavaScript does not.
Java Script is used for front-end web development while Java can only be used as a backend language within a web environment.
Java doesn't need a web browser to compile and execute like Javascript does. Java is
compiled prior to runtime while Javascript is compiled at runtime.
2. Justify it: Java script is used in validation techniques .
ANS:
The simple program allows a user to enter a password via form that is then accessed in
JS program.
This program serves to make a point about how to pick up details from the form; it
would not be feasible to check a password in these way as it would be insecure.
If you want to check input from a user of an email address, the first thing to decide is
what the format of such an address could in all possible and legal cases.
A routine to validate an email should be check for invalid characters, check the
existence of the single @ and its positioning.
)t should be also check the . )s present in the domain name and again its positioning.
There are some good string manipulation an excess function built into JS. The presence
of a character and its positioning can be checked with:
o Strpos=stringName.indexOf @ ,startPos ;
The indexOf returns the position of characters,if it does not exist in the string then
returns -1.
It can be used to detect the visitors,browsers and can load page accordingly.
May improve the usability of Web sites for users whose browsers support scripts
Can give developers more control over the look and behavior of their Web widgets (note
that this can be an advantage or disadvantage)
Can be substituted with alternatives (for example, HTML) if users' browsers do not support
scripts
Are reusable and obtainable from many free resources such as Hotscripts.com and
Javascript.com.
Disadvantages
Client-side scripts also create additional worries, including:
Not all browsers support scripts, therefore, users might experience errors if no alternatives
have been provided
Different browsers and browser versions support scripts differently, thus more quality
assurance testing is required
More development time and effort might be required (if the scripts are not already
available through other resources)
Developers have more control over the look and behavior of their Web widgets; however,
usability problems can arise if a Web widget looks like a standard control but behaves
differently or vice-versa.
5) Explain what is meant by event-driven programming.
ANS: When an events happen it triggers object that are associated with that kind of event.
Programming using this is called event driven programming.
6) What does the acronym DHTML stand for?
ANS: DHTML stands for Dynamic Hyper Text Markup Language.
7) Describe how client-side scripting can be used to enhance a website experience?
ANS:
Running a script on the client side saves processing time on the server.
The main two client side scripting languages are VB script and JS.
In client side scripting the web browser use its own resources and eases the burden on
the server.
Due to many advantages of using client side scripting it can be used to enhance a web
site experience
// cosine of a
Math.exp(a)
// log of a base e
// sine of a
// tangent of a
The onload and onUnload events are triggered when the user enters or leaves the page
The onload event is often used to check the visitor's browser type and browser version,
and load the proper version of the web page based on the Information.
Both the onload and onUnload events are also often used to deal with cookies that should
be set when a user enters or leaves a page.
onFocus, onBlur and onChange
The onFocus, onBlur and onChange events are often used in combination with validation
of form fields.
Example: The checkEmail() function will be called whenever the user changes the content
of the field:
<input type="text" size="30"
id="email" onchange="checkEmail()">;
Example & Demo: onblur
<html>
<head>
<script type="text/javascript">
function upperCase() {
var x=document.getElementById("fname").value
document.getElementById("fname").value=x.toUpperCase()
}
</script>
</head>
<body>
Enter your name:
<input type="text" id="fname" onblur="upperCase()">
b. DOM :Document object model is a set of platform independent and language neutral
application programming interface(API) which describes how to access and manipulate the
information stored in HTML,XHTML and JS document.
Example:<script type= text/javascript >
document.write(str.toupper case());
</script>
document.write(text.length);
</script.
e. Property:The prototype property allows to add properties and methods to add object.
Example:< script type= text/javascript>
function employee(name,jobtitle,born)
{
this.name=name;
this.jobtitle=jobtitle;
this.born=born;
document.write(fred.salary);
</script>
f. Regular Expression :It ia an object that describes a pattern of characters. It is y=used to
perform pattern matching and search and replace function on the text.
Example:<script type= text/javascript>
var str= All right ;
var pat=/[a-z]/g;
</script>
form.html
<html>
<head>
<title> </title>
<body>
<form>
<table>
<th>Get started with Gmail </th><hr/>
<tr><td>First Name:</td>
google.css
@charset "utf-8";
/* CSS Document */
.google
{
background-color:#F4F4F7;
padding-left:100px;
}
Output:
Faculty Name
Department
CE/IT
Subject/Subject
code
WAD(160705)
WTP(161602)
Semester/Branch
6th CE
6th IT
Solution of Assignment # 5
1) Give merits and demerits of DTDs in XML.
ANS:
Advantages:
1. Of the primary three languages, DTDs are the only ones that can be defined inline. That
is, the DTD can actually be embedded directly into the document.
2. DTDs can define more than merely the content model. It can define data elements that
can be used in the document; much like a C or C++ preprocessor may have #defines
that are used internally.
3. The DTD language is compact and highly readable, though it does require some
experience to understand.
Disadvantages:
1. The primary disadvantage to DTDs is their weakness of specificity. The content models
for DTDs are very basic, particularly compared to the other two languages.
2. Overuse of DTD-defined elements may make a document illegible or incomprehensible
without the associated DTD.
3. The language that DTDs are written in is not XML. Therefore, DTDs cannot use the
various frameworks that have been built around XML. XML editors that support
writing DTDs must do so by parsing an additional language.
4. The DTD concept for XML was borrowed from the SGML DTD concept. As such, the
construct could not be changed when XML was extended with namespaces. As such,
DTDs are namespace unaware.
5. There is limited support for defining the type of the contained data. DTDs are primarily
structural in nature. They do not have the ability to specify that an element contains an
integral number, real number, a date, or anything of that nature.
2) Give advantages and disadvantages of XML schemas.
ANS:
Disadvantages
Faculty Name
Department
CE/IT
Subject/Subject
code
WAD(160705)
WTP(161602)
Semester/Branch
6th CE
6th IT
Solution of Assignment # 6
1. How do you create cookie in PHP? Give difference between session
and cookie with example.
ANS:
The cookies can be created using setcookie() function. if PHP code is embedding in
HTML script then setcookie() functionmust appear before <html> tag.
Syntax: setcookie(cookiename,value,expire,path,domain);
For Example: $value= some value ;
Setcookie MyCookie ,$value ;
Setcookie MyCookie ,$value,time +3600 ;
Session
1. Session can store any type of
data because the value is of data
type of "object"
2. These are stored at Server side
Cookies
1. Cookies can store only "string" data type
2. Whats PHP? Write down source code to create database and retrieve
data with connection of PHP.
ANS:
PHP is a scripting language that is combined with HTML, either by embedding it within
a web document or by using it as a file that is prossed alongside it, but on the server
side!
PHP Script:
<?php
echo $_POST['fname'];
echo $_POST['lastname'];
$con = mysql_connect("localhost","root","");
if(!$con)
{
die('Error'.mysql_error());
}
mysql_select_db("database",$con);
$detail="INSERT INTO details(firstName,lastName,userName,password,gender)
VALUES('$_POST[fname]','$_POST[lastname]','$_POST[login]','$_POST[pwd]','$_POST[stay]'
)";
if(!mysql_query($detail,$con))
{
die('Error'.mysql_error());
}
mysql_close($con);
?>
5. Write a PHP program to make the sum of first 100 odd numbers.
ANS:
PHP Script:
<?php
$sum=0;
for($i=1;$i<=200;$i++)
{
$sum=$sum+$i;
$i++;
}
echo "Addition of first 100 odd numbers is:".$sum;
?>
6. Describe following terms:
a. str_replace()
b. strtolower()
c. strstr()
d. $_FILES[]
ANS:
a. str_replace():
Syntax: str_replace($search,$replace,$string,$count).
Functions: It search within the full string and replace with the replacing keyword
and also return how many time these function has replace the value of given word.
b. strtolower():
Syntax: strtolower($string).
Functions: It converts all characters in string to lowercase.
c. strstr():
Syntax: strstr($string1, $string2).
Functions: It finds string 2 inside sy[tring 1 and if it is not found returns false
otherwise returns that portions of string 1 that contains it.
d. $_FILES[]:
Syntax:$size=$F)LES[ File ][ Size ];
Function:$FILES() are used to fetch initial name of the file and file size.
available?
ANS:
Cookies can be used to carry information throughout a website about a particular
visitor, but cookies are not the best secure way to keep informable.
Because they are very simple in method to store information.
Also cookies can be deleted or can be changed by user so it will create a problem to
store information.
Cookies are not safer for e-commerce, to ensure information is available across the
pagers without relaying on the visitor s browser.
For these reason cookies are not the best secure way to keep information available.
8. Explain enctype with respect to HTML and PHP.
ANS:
The enctype attribute specifies how the form data should be encode when
submitting it the server.
The enctype attribute of the form> tag specifies which content-type to use when
submitting the form.
Syntax: <form enctype= value >
Example:
<form action= demo_post enctype.php method= post enctype= multiport
form_data >
First name:<input type= text name=fname ><br>
Last name:<input type= text name=lname ><br>
(ere multipart form_data is used when a form requires binary data, like the
contents of a file, to be uploaded.
Allowing users to upload file is a big security risk. Only permit trusted users to
perform file uploads.