BIT 4303 DL Chapter Four, Five & Six
BIT 4303 DL Chapter Four, Five & Six
BIT 4303 DL Chapter Four, Five & Six
Chapter four
Server-side Programming
c) Server selects the appropriate servlet to generate the response, creates request/response
objects, and passes them to a method on the servlet instance
Entry point to servlet code is via call to a method (doGet() in the example)
Advanced Web @ Fred 2022
b) Servlet interaction with end user is indirect via request/response object APIs
Q2.write 20 points on client side scripting and server side scripting technologies or languages.
Client side scripting: is a class of computer programs on the web that are executed by the client-
side user browser instead of server side.
Web authors write the scripts in languages such as java script and vbscript.
They have different and changing content depending on the user input.
Client side scripts also have instructions which the browser should follow in response to
certain user action.
The user cannot see the server side source code unless the server publishes it separately.
Client-server scripts have greater access to the information and functions available on the
server.
The users’ web browser should how ever have an interpreter.
They are mostly embedded within an html or xhtml.
Client side script is not inherently unsafe although users are required to update their
browsers
Actions script is a browser used to create animated interactive web applications for adobe
flash player.
Server side scripting
It’s a technique which involves embedding scripts in html source code which then
handles the users’ request.
This scripting is used to limit access to proprietary databases and other data sources.
These scripts may assemble client characteristics for use in customization
It also enables the web owner to reduce user access to the source code of server scripts.
The server side provides more computing resources before sending a page to the client
computer for display via its web browser.
Client side scripts are usually embedded with html or xhtml documents but may also
contain separate files.
Java scripts are executed when a user requests a document they produce output
understandable by the web browser.
Documents produced by server side scripts may produce client side scripts in them.
Advanced Web @ Fred 2022
Techniques like activex may be used to control user access and used as sidestep
restriction.
Some server script languages are ASP, CGI etc.
Q3.With the aid of examples describe the relationship between HTML,XML and SGML
The relationship between HTML, XML and SGML is a family bond that helps make websites
work and web design dynamic.
SGML- is the parent in this family. It provides a way to define markup languages and set the
standard for their form simply put it states what some languages can or cannot do.
HTML- is the child or application of SGML. It designs the page for an internet browser. Using it
you can embed images, create page sections, establish fonts and direct the flow of the page. It is
the markup language that creates the form and appearance of the web page.
XML- is the cousin to HTML and the nephew to SGML. Although it is a markup language and
therefore part of the family, it has different functions than HTML. It is a subset of SGML, this
gives it rights that an application such as HTML doesn’t .
Maintenance-the contents in the web should be able to accept import existing content
and should be able to manage all the content
Website growth-it should be controlled in such a way that one is able to manage expired
content.
Visible- the content if images should be clearly seen if text should be readable for the
user in question to get the message or the essence of the website.
Adaptability- the content displayed on the website should be adaptable in that it can be
changed constantly according to the designers preference or due to the emergence of new
information.
Reliable- the content of the website to be designed should be accurate and factual for the
sake of the user.
Accessibility –the content of your website can either be open sourced such that anyone
can access the information in your website or it may require authorized access for
example through subscription thus the user can access the content.
User friendly- the content to be displayed on the website should be simple enough for any
average user to be able to comprehend it avoiding the use of complicated terms is advised
Intergration -this applies to existing systems thus should not habour complications.
Communication-the web system should be able to accept benefits from the seniors
Advanced Web @ Fred 2022
Distribution of content-the features should not be hidden in a way that web users will
strain to get certain informations.
Turnover rate-the turnover rate should be high to ensure that the website itself is fast.
Accuracy – contents in the website should be accurate this is to enable true passing and
receiving of information.
Cost-the size and quality should be accessed to ensure that the server side does not suffer
a lot in terms of financial areas in the process of setting up the website.
Business requirements-a website should meet business requirements required.
Useability -a website should have a high rate of useability cause that is the essence of it.
Advanced Web @ Fred 2022
Chapter five
What is CSS?
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.
(Netscape vs MS Internet Explorer)
External Style Sheets can save you a lot of work. External Style Sheets are stored in CSS files.
CSS Versions
The World Wide Web Consortium has published two main CSS recommendations of style sheets
CSS1 and CSS2.
Syntax
p {text-align:center ; color:red}
<head>
<style type="text/css">
h1 {color: red}
h3 {color: blue}
</style>
</head>
<html>
<body>
<a href="lastpage.htm"
style="text-decoration:none">
THIS IS A LINK!
</a>
</body>
</html>
Myhtml.html
…
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
….
Mystyle.css
hr {color: sienna}
p {margin-left: 20px}
body {background-image: url("images/back40.gif")}
CSS, Why ?
By editing a single CSS file, you can make site-wide design changes in seconds.
CSS lets you output to multiple formats quickly. It lets you use logical names for page elements.
You can, for example, give a DIV the name "header", or a H1 the class "headline". It's self-
describing.
External CSS files are cached by browsers, improving load time. CSS eliminates the need for
messy code -- namely font tags, spacer GIFs and nested tables.
Advanced Web @ Fred 2022
CSS lets you do things normal HTML doesn't. Examples: better font control, absolute
positioning, nifty borders. Practical use of CSS encourages proper HTML structure, which will
improve accessibility and search engine placement. CSS's :hover PseudoClass cuts down on the
need to use JavaScript onmouseover calls.
What is XML?
XML stands for EXtensible Markup Language. It’s a markup language much like HTML.
It was designed to describe data. XML tags are not predefined. You must define your own
tags. XML uses a Document Type Definition (DTD) or an XML Schema to describe the data.
XML was designed to carry data. XML is not a replacement for HTML.
XML was designed to describe data and to focus on what data is. HTML was designed to display
data and to focus on how data looks. HTML is about displaying information, while XML is
about describing information.
XML
Best description of XML is this: XML is a cross-platform, software and hardware independent
tool for transmitting information.
</book>
…………….
</bookstore>
<html>
<head>
<script type="text/javascript“ for="window" event="onload">
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("xml_note.xml")
nodes=xmlDoc.documentElement.childNodes
to.innerText= nodes.item(0).text
from.innerText= nodes.item(1).text
header.innerText=nodes.item(2).text
body.innerText= nodes.item(3).text
</script>
<title>HTML using XML data</title>
</head>
<body bgcolor="yellow">
<h1>W3Schools.com Internal Note</h1>
<b>To: </b>
<span id="to"> </span>
<br />
<b>From: </b>
<span id="from"></span>
<hr>
<b><span id="header"></span></b>
<hr>
Advanced Web @ Fred 2022
<span id="body"></span>
</body>
</html>
Advanced Web @ Fred 2022
Chapter six
Browser Scripting
Browser scripting languages allow dynamic behavior to be specified within HTML documents.
A scripting language is a lightweight programming language Browsers must support the used
scripting language. Browsers are disabled for scripting to prevent the risk of misuse.
What is JavaScript?
JavaScript was designed to add interactivity to HTML pages. It’s a scripting language.
A JavaScript consists of lines of executable computer code. It’s usually embedded directly into
HTML pages. It’s an interpreted language (means that scripts execute without preliminary
compilation). Everyone can use JavaScript without purchasing a license.
NO!
Java and JavaScript are two completely different languages in both concept and design!
Java (developed by Sun Microsystems) is a powerful and much more complex programming
language - in the same category as C and C++.
<html>
<body>
<script type="text/javascript">
document.write("Hello World!")
Advanced Web @ Fred 2022
</script>
</body>
</html>
a) Head section
b) Body section
c) External scripts
<html>
<head>
<script type="text/javascript">
function message()
{
alert("This alert box was called with
the onload event")
}
</script>
</head>
<body onload="message()">
</body>
</html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
document.write("Hello World!")
</script>
</body>
<html>
<head>
<script src="xxx.js">
</script>
Advanced Web @ Fred 2022
</head>
<body>
</body>
</html>
<html>
<body>
<script type="text/javascript">
var d = new Date()
var time = d.getHours()
if (time < 10)
{
document.write("<b>Good morning</b>")
}
else
{
document.write("<b>Good day</b>")
}
</script>
...............
<html>
<body>
<script type="text/javascript">
for (i = 0; i <= 5; i++)
{ document.write("The number is " + i)
document.write("<br />")
}
</script>
<p>Explanation:</p>
<p>This for loop starts with i=0.</p>
<p>As long as <b>i</b> is less than, or equal to 5, the loop will continue to run.</p>
<p><b>i</b> will increase by 1 each time the loop runs.</p>
</body>
</html>
What is VBScript?
When a VBScript is inserted into a HTML document, the Internet browser will read the HTML
and interpret the VBScript.
<html>
<head>
</head>
<body>
<script type="text/vbscript"> document.write("Hello from VBScript!")
</script>
</body>
</html>
<html>
<head>
<script type="text/vbscript">
some statements
</script>
</head>
<body>
<script type="text/vbscript">
some statements
</script>
</body>
VBScript (Example)
html>
<head>
<script type="text/vbscript">
function greeting()
i=hour(time)
if i < 10 then
document.write("Good morning!")
else
document.write("Have a nice day!")
end if
end function
</script>
</head>
Advanced Web @ Fred 2022
<body onload="greeting()">
</body>
</html>
……………..
<html>
<body>
<script type="text/vbscript">
for i = 0 to 5
document.write("The number is " & i & "<br />")
next
</script>
</body>
</html>