Past Papers, UOS Main Campus, Web System and Technologies

Web System & Technologies Past Paper 2016 – BS IT 6th Term UOS (IT-3548)

ProgramBS IT
Term6th
Year2016
Course codeIT-3548
AnswersSolved ✓

University of Sargodha BS IT 6th term examination 2016, Web System & Technologies (IT-3548) paper (80 marks, 2:30 hours). The paper is retyped by Shining Study from a student’s copy (marks, names and roll numbers removed); all answers are written by Shining Study for revision. Solved answers for all 16 short questions and five long questions, including a tested PHP form-validation program (Name, CNIC xxxxx-xxxxxxx-x, email), DOM manipulation, CSS from JavaScript, XML structure and style sheet types.

Solved answers

Q1 – Short answers (16 × 2)

I. Purpose of the HTML <head> element. It contains information about the page (metadata) that is not shown in the page body: <title>, meta tags (charset, description, viewport), links to CSS files, scripts and favicon.

II. Client-side vs server-side scripting. Client-side scripts (JavaScript) run in the browser for interactivity and validation; server-side scripts (PHP, ASP.NET) run on the server to process requests and access databases, and send back HTML.

III. TCP/IP. The Internet protocol suite: TCP provides reliable, ordered delivery of data between applications; IP addresses and routes packets between networks.

IV. HTML vs XHTML. XHTML is HTML written with XML rules: all tags lowercase and properly closed (<br />), properly nested, attribute values quoted, one root element. HTML is more relaxed; browsers forgive errors.

V. WAMP. A software stack for Windows: Windows, Apache web server, MySQL database and PHP – used to run PHP websites locally (localhost).

VI. MySQL. An open-source relational database management system that stores data in tables and uses SQL; commonly used with PHP for dynamic websites.

VII. AJAX stands for. Asynchronous JavaScript And XML.

VIII. HTML vs DHTML. HTML creates static pages. DHTML (Dynamic HTML) combines HTML, CSS, JavaScript and the DOM to change page content and style after loading, without contacting the server.

IX. Why use jQuery. It simplifies JavaScript: easy element selection with CSS selectors, DOM manipulation, events, animations and AJAX, with cross-browser compatibility – “write less, do more”.

X. Semantic web browser. A browser/tool for the Semantic Web, which can read machine-understandable data (RDF, OWL, linked data) and show relationships between resources, so computers can understand meaning, not just display pages.

XI. Concatenation operators. JavaScript uses + ("Shining" + " Study"); PHP uses the dot . ("Shining" . " Study") and .= to append.

XII. Some web browsers. Google Chrome, Mozilla Firefox, Microsoft Edge, Safari, Opera, Brave.

XIII. DOM. The Document Object Model is a tree representation of an HTML/XML page that lets scripts access and change its content, structure and style, e.g. document.getElementById("demo").innerHTML = "Hi";

XIV. Social network websites. Websites that let users create profiles, connect with others and share content (posts, photos, videos), e.g. Facebook, LinkedIn, Instagram, X (Twitter).

XV. Session and cookies. A cookie is small data stored in the browser and sent with each request; a session stores user data on the server and identifies the user with a session ID (stored in a cookie).

XVI. Pseudo-class in CSS. A keyword added to a selector to style an element in a special state, e.g. a:hover { color: red; }, :visited, :focus, li:first-child.

Q2 – PHP form validation: Name, CNIC and email

<?php
$name = $cnic = $email = "";
$errors = [];

function clean($v) {
    return htmlspecialchars(trim($v));
}

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name  = clean($_POST["name"] ?? "");
    $cnic  = clean($_POST["cnic"] ?? "");
    $email = clean($_POST["email"] ?? "");

    if ($name == "") {
        $errors[] = "Name is required.";
    } elseif (!preg_match("/^[a-zA-Z ]+$/", $name)) {
        $errors[] = "Name can contain only letters and spaces.";
    }

    if (!preg_match("/^[0-9]{5}-[0-9]{7}-[0-9]$/", $cnic)) {
        $errors[] = "CNIC must be in the format xxxxx-xxxxxxx-x.";
    }

    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $errors[] = "Please enter a valid email address.";
    }

    if (count($errors) == 0) {
        echo "<p>Form submitted successfully. Welcome, $name!</p>";
    } else {
        foreach ($errors as $e) {
            echo "<p style='color:red'>$e</p>";
        }
    }
}
?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>">
  Name: <input type="text" name="name" value="<?php echo $name; ?>"><br>
  CNIC: <input type="text" name="cnic" placeholder="12345-1234567-1" value="<?php echo $cnic; ?>"><br>
  Email: <input type="text" name="email" value="<?php echo $email; ?>"><br>
  <input type="submit" value="Submit">
</form>

The CNIC pattern ^[0-9]{5}-[0-9]{7}-[0-9]$ accepts exactly xxxxx-xxxxxxx-x. Tested in PHP 8: “Ali Khan / 38403-1234567-1 / ali@example.com” is accepted, while “Ali2 / 3840-12-1 / bad” shows all three error messages.

Q3 – JavaScript approaches to manipulate HTML content

  • Select elements: document.getElementById(), getElementsByClassName(), getElementsByTagName(), querySelector(), querySelectorAll().
  • Change content: innerHTML (with HTML) or textContent (plain text).
  • Change attributes: el.src = "a.jpg", setAttribute("href", "..."), removeAttribute().
  • Change style/classes: el.style.color = "red", el.classList.add("active").
  • Create, add and remove elements: createElement(), appendChild(), append(), remove().
  • Events: addEventListener("click", fn) to react to user actions.
  • Other: document.write() (old, during page load), and libraries like jQuery.
<p id="msg">Hello</p>
<button id="btn">Change</button>
<script>
  document.getElementById("btn").addEventListener("click", function () {
    var p = document.getElementById("msg");
    p.textContent = "Welcome to Shining Study";
    p.style.color = "blue";
    var li = document.createElement("li");
    li.textContent = "New item";
    document.body.appendChild(li);
  });
</script>

Q4 – Accessing CSS from JavaScript

  • Inline style property: el.style.backgroundColor = "yellow"; (CSS names become camelCase).
  • Read the computed style: getComputedStyle(el).fontSize.
  • Change classes (best practice): el.className = "box" or el.classList.add/remove/toggle("dark").
  • Set many properties: el.style.cssText = "color:red; font-size:20px";
  • Style sheets: document.styleSheets[0].insertRule("p { color: green }", 0); or add a new <link>/<style> element.
<style> .dark { background: #222; color: #fff; } </style>
<div id="box">Box</div>
<script>
  var box = document.getElementById("box");
  box.style.border = "2px solid red";          // set inline style
  box.classList.toggle("dark");                // switch a CSS class
  alert(getComputedStyle(box).backgroundColor); // read the style
</script>

Q5 – Basic structure of an XML document

<?xml version="1.0" encoding="UTF-8"?>          <!-- XML declaration (prolog) -->
<!DOCTYPE library SYSTEM "library.dtd">          <!-- optional DTD -->
<library>                                        <!-- one root element -->
  <!-- comment -->
  <book id="b1" category="CS">                   <!-- element with attributes -->
    <title>Web Engineering</title>
    <author>Ali Raza</author>
    <year>2016</year>
  </book>
</library>
  • Prolog: XML declaration (version, encoding) and optional DTD/schema reference.
  • Root element: exactly one element that contains all others.
  • Child elements nested properly; every start tag has an end tag (or is self-closed <br/>).
  • Attributes in quotes inside start tags.
  • XML is case-sensitive; special characters use entities (&lt;, &amp;); comments and CDATA sections are allowed.
  • A document following these rules is well-formed; if it also follows its DTD/XSD it is valid.

Q6 – Inline, internal and external style sheets

  • Inline CSS – in the style attribute of an element; affects only that element; highest priority: <p style="color:red;">Red text</p>
  • Internal (embedded) CSS – in a <style> block in the <head>; affects that one page.
  • External CSS – rules in a separate .css file linked with <link>; one file styles the whole website, easy maintenance and caching.
<!-- internal -->
<head>
  <style>
    h1 { color: navy; }
  </style>
  <!-- external -->
  <link rel="stylesheet" href="style.css">
</head>

/* style.css */
body { font-family: Arial; background-color: #f5f5f5; }

Cascade priority: inline > internal/external (whichever comes later) > browser default (and !important overrides).

Save this paper for offline studyDownload the question paper, or save the paper together with all solved answers as a PDF.
↓ Download Paper (JPG)
Have another year of Web System and Technologies?

Upload a photo in 10 seconds — no form to fill. We clean it, solve it and credit you.

Missing years for this subject
202420232022

About Saif R

An educator and technology enthusiast passionate about empowering students through quality education and digital learning. Dedicated to making academic resources and opportunities accessible to everyone.