Blog
Web Systems and Technologies Past Paper 2015 – MSc IT 3rd Term UOS (IT-3548) – Paper B
University of Sargodha M.Sc. IT 3rd term Web Systems & Technologies (IT-3548) paper, 2015 exam (Paper B, 80 marks, 2:30 hours). Two different papers for this course and year were found; this is the one starting with the TABLE element question. It is retyped below, followed by solved answers for all 16 short questions and all six subjective questions: JavaScript form validation, how a browser processes a response, static content delivery, CSS, HTTP message structure and the TCP/IP layers compared with OSI.
Solved answers
Q1 – Short answers (16 × 2)
1. Syntax of TABLE.
<table border="1">
<caption>Results</caption>
<tr>
<th>Name</th><th>Marks</th>
</tr>
<tr>
<td>Ali</td><td>78</td>
</tr>
</table><tr> is a row, <th> a header cell, <td> a data cell; colspan/rowspan merge cells; <thead>, <tbody>, <tfoot> group rows.2. Sessions. A session stores information about one user across several page requests on the server (HTTP itself is stateless). A unique session ID is kept in a cookie; e.g. in PHP session_start(); $_SESSION["user"] = "Ali";. Used for logins and shopping carts.
3. PHP. PHP (Hypertext Preprocessor) is an open-source server-side scripting language embedded in HTML. The server runs the PHP code and sends the generated HTML to the browser; used for dynamic pages, forms, sessions and database access (MySQL), e.g. WordPress.
4. INPUT element types. text, password, email, number, tel, url, search, date, time, datetime-local, month, week, color, range, checkbox, radio, file, hidden, submit, reset, button, image.
5. Purpose of <meta>. The <meta> element (inside <head>) gives metadata about the page that is not displayed: character set (<meta charset="UTF-8">), description and keywords for search engines, author, viewport for mobile devices, and refresh/redirect.
6. XML. eXtensible Markup Language – a W3C markup language for storing and transporting data with user-defined tags; it is self-describing, strict (well-formed: one root, properly nested, closed tags) and platform-independent.
7. Browser. A client application that requests web resources with HTTP(S) and renders HTML, CSS and JavaScript for the user, e.g. Chrome, Firefox, Edge.
8. Purpose of <body>. Contains all the visible content of the page – text, headings, images, links, tables, forms – and can carry event attributes such as onload.
9. Simple HTML page.
<html>
<head><title>Welcome</title></head>
<body>
<h1>University of Sargodha</h1>
<p>This is a simple HTML page.</p>
<a href="https://shiningstudy.com">Past papers</a>
</body>
</html>10. Redirection status codes. 3xx codes telling the client to go to another URL given in the Location header: 301 Moved Permanently, 302 Found (temporary), 303 See Other, 304 Not Modified (use cached copy), 307 Temporary Redirect, 308 Permanent Redirect.
11. HTTP POST method. Sends data to the server in the body of the request (e.g. form fields, file uploads) to create or update a resource; data is not shown in the URL and has no practical size limit.
12. MVC design pattern. Model-View-Controller separates an application into the Model (data and business logic), the View (user interface/presentation) and the Controller (handles input, updates the model and selects the view) – used by Laravel, Django, ASP.NET MVC.
13. POP. Post Office Protocol (POP3, port 110/995) – used by e-mail clients to download messages from a mail server to the local computer, usually deleting them from the server.
14. ARPANET. Advanced Research Projects Agency Network – the first packet-switched network (1969, US Department of Defense), which introduced TCP/IP in 1983 and became the basis of the internet.
15. HTTP. HyperText Transfer Protocol – the stateless, request–response application protocol of the web (port 80; HTTPS on 443 with TLS); methods GET, POST, PUT, DELETE; status codes 2xx–5xx.
16. SMTP. Simple Mail Transfer Protocol (port 25/587) – used to send e-mail from a client to a mail server and between mail servers.
Q2 – Client-side form validation with JavaScript
Client-side validation checks user input in the browser before the form is submitted, giving instant feedback and reducing server load. (The server must still validate, because client checks can be bypassed.) It is done by handling the form’s onsubmit event and returning false to stop submission when data is invalid.
<form name="reg" action="register.php" method="post" onsubmit="return validate()">
Name: <input type="text" id="name"><br>
Email: <input type="text" id="email"><br>
Age: <input type="text" id="age"><br>
Password: <input type="password" id="pwd"><br>
<span id="err" style="color:red"></span><br>
<input type="submit" value="Register">
</form>
<script>
function validate() {
var name = document.getElementById("name").value.trim();
var email = document.getElementById("email").value.trim();
var age = Number(document.getElementById("age").value);
var pwd = document.getElementById("pwd").value;
var err = document.getElementById("err");
if (name === "") { err.textContent = "Name is required"; return false; }
if (!/^[^\s@]+@[^\s@]+\.[a-z]{2,}$/i.test(email)) { err.textContent = "Invalid email"; return false; }
if (isNaN(age) || age < 18) { err.textContent = "Age must be 18 or more"; return false; }
if (pwd.length < 8) { err.textContent = "Password must have 8 characters"; return false; }
return true; // all checks passed - form is submitted
}
</script>- Checks: required fields, numeric ranges, length, format with regular expressions (email, phone), matching passwords.
- Feedback: messages next to fields, highlighting with CSS, focusing the wrong field.
- HTML5 also provides built-in validation attributes: required, type=”email”, min/max, pattern, maxlength.
Q3 – Processing flow of a response in a browser
- Receive the response – the networking layer reads the status line (e.g. 200 OK, 301, 404), headers (Content-Type, Content-Length, Set-Cookie, Cache-Control) and body; redirects are followed; cookies and cache are stored.
- Decide how to handle it – by MIME type: text/html is rendered, images/media are displayed, others downloaded or handed to plug-ins.
- Parse HTML – tokenise and build the DOM tree; while parsing, request linked resources (CSS, JS, images).
- Parse CSS into the CSSOM; execute JavaScript (which may modify the DOM).
- Build the render tree (visible nodes with computed styles), layout/reflow (sizes and positions) and paint/composite pixels on the screen.
- Handle events – user interaction and scripts cause further DOM changes, repaints and new requests (AJAX).
Q4 – Web server delivery of static content
Static content is files that do not change per request – HTML pages, CSS, JavaScript, images, videos, PDFs.
- The client sends
GET /images/logo.png HTTP/1.1with the Host header. - The server maps the URL path to a file in its document root (e.g. /var/www/html/images/logo.png), checking permissions and default documents (index.html).
- If the file exists it determines the MIME type from the extension (Content-Type: image/png) and builds headers: Content-Length, Last-Modified, ETag, Cache-Control.
- If the client sent If-Modified-Since/If-None-Match and the file is unchanged, the server replies 304 Not Modified without the body.
- Otherwise it returns 200 OK with the file contents (possibly compressed with gzip, or partial content 206 for range requests); a missing file gives 404 Not Found.
- The connection may be kept alive for further requests.
Static delivery is fast and cacheable; CDNs and browser caches further speed it up. Servers such as Apache and Nginx are optimised for it.
Q5 – CSS and methods of associating it
Cascading Style Sheets (CSS) describe the presentation (colours, fonts, layout) of HTML documents, separating content from design. There are three ways to associate styles with a document:
- Inline styles – the
styleattribute on one element:<p style="color:red; font-size:14pt">Hello</p>. Highest priority, but mixes style with content and cannot be reused. - Internal (embedded) style sheet – a
<style>element in the<head>, applying to that page only:<style> body { font-family: Arial; background: #f5f5f5; } h1 { color: navy; } .note { border: 1px solid #999; padding: 8px; } </style> - External style sheet – rules saved in a separate .css file and linked to many pages:
<link rel="stylesheet" href="style.css">(or@import url("style.css");inside a style block). Best for consistent site-wide design and caching.
Cascade and precedence: when rules conflict, inline beats internal/external, then more specific selectors (id > class > element) win, and among equal specificity the rule that comes last wins; !important overrides normal rules. Styles are also inherited by child elements.
Q6 – Structure of HTTP messages
HTTP messages are plain text with three parts: a start line, headers and an optional body, separated by a blank line (CRLF).
Request message:
POST /login.php HTTP/1.1 <- request line: method, URL, version
Host: www.example.com <- headers
User-Agent: Mozilla/5.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 27
<- blank line
user=ali&password=secret123 <- bodyResponse message:
HTTP/1.1 200 OK <- status line: version, status code, reason
Date: Sat, 05 Dec 2015 10:00:00 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 1024
Set-Cookie: PHPSESSID=abc123
<html> ... </html> <- body- Methods: GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH.
- Status code classes: 1xx informational, 2xx success, 3xx redirection, 4xx client error, 5xx server error.
- Header types: general (Date, Connection), request (Host, Accept, Cookie, User-Agent), response (Server, Set-Cookie, Location), entity (Content-Type, Content-Length).
Q7 – TCP/IP layers with reference to OSI
| TCP/IP layer | OSI layers | Functions | Protocols |
|---|---|---|---|
| Application | 7 Application, 6 Presentation, 5 Session | Network services to applications, data formatting, encryption, session management | HTTP, HTTPS, FTP, SMTP, POP3, DNS, SSH, Telnet |
| Transport (host-to-host) | 4 Transport | Process-to-process delivery with ports, segmentation, reliability, flow and congestion control | TCP, UDP |
| Internet | 3 Network | Logical (IP) addressing, routing, fragmentation | IP (IPv4/IPv6), ICMP, ARP, IGMP |
| Network access (link) | 2 Data link, 1 Physical | Framing, MAC addressing, error detection, transmission of bits on the medium | Ethernet, Wi-Fi (802.11), PPP |
Comparison: OSI is a 7-layer reference model defined before its protocols; TCP/IP is a practical 4-layer model built around existing protocols and used by the internet. TCP/IP merges OSI’s top three layers into one application layer and the bottom two into network access. Data is encapsulated as it goes down: message → segment → packet (datagram) → frame → bits.
