Web Application
Web Application
The basic principles of Web Engineering serve as guidelines to ensure the efficient and
effective development of web applications. These principles align with best practices in software
engineering, adapted for the unique challenges of web-based systems.
1. User-Centric Design
12. Cost-Effectiveness
Q: Describe the basic components of web application architectures with
necessary diagram.
1. Client-Side (Front-End)
o Handles user interface (UI) and user interactions.
o Technologies: HTML, CSS, JavaScript, frameworks like React or Angular.
2. Server-Side (Back-End)
o Processes client requests, applies business logic, and communicates with the
database.
o Technologies: Node.js, Python, Java, PHP, etc.
3. Database
o Stores and manages application data.
o Types: Relational (MySQL, PostgreSQL) and NoSQL (MongoDB, Redis).
4. Web Server
o Handles HTTP requests and serves responses or static files.
o Examples: Apache, Nginx.
5. API Layer
o Facilitates communication between the front-end, back-end, and external services.
o Types: REST, GraphQL.
6. Load Balancer
o Distributes incoming traffic across multiple servers to ensure availability and
performance.
7. CDN (Content Delivery Network)
o Caches static content and delivers it closer to the user's location for faster load
times.
Q: Mention the types and attributes of web application.
1. User Request:
o User enters a URL in the address bar or clicks a link.
2. DNS Resolution:
o The browser resolves the domain name (e.g., example.com) into an IP address
using a DNS server.
3. Connection Establishment:
o A connection is established with the server via HTTP or HTTPS (with SSL/TLS
for secure connections).
4. Sending HTTP Request:
o The browser sends an HTTP request to the server for the desired resource (e.g.,
HTML file).
5. Server Response:
o The server processes the request and sends back an HTTP response containing the
resource or an error code.
6. Content Rendering:
o The browser:
Parses the HTML to build a DOM (Document Object Model).
Parses CSS for styling.
Executes JavaScript for interactivity.
Renders images, videos, and other resources.
7. Resource Loading:
o The browser makes additional requests for resources like images, CSS, and
JavaScript files as referenced in the HTML.
8. Display Content:
o The browser displays the fully rendered page to the user and updates dynamically
if required.
9. Caching:
o Frequently used resources are cached locally to speed up future requests.
Q: Differences between client side and server-side programming
HTML, CSS, JavaScript, frameworks like Node.js, Python, PHP, Java, Ruby, ASP.NET,
Technologies
React, Angular, Vue.js. frameworks like Django.
Cannot directly access databases or Directly interacts with databases, files, and
Resource Access
server resources. other server resources.
Less secure, as the code is visible to More secure, as the code runs on the server
Security
users (e.g., in browser dev tools). and isn't exposed to users.
Reduces server load but depends on Increases server load but ensures consistent
Performance
the user's device for performance. processing regardless of the client.
Sends requests to the server for data Processes requests and sends responses
Communication
using APIs (e.g., REST, GraphQL). (HTML, JSON, XML) to the client.
Object-Oriented Programming (OOP) is a paradigm centered around objects that combine data
(attributes) and methods (functions) to model real-world systems. Common OOP languages
include Java, Python, C++, and C#.
Cross-Site Scripting (XSS) is a type of security vulnerability that allows attackers to inject
malicious scripts into websites viewed by other users. These scripts are usually written in
JavaScript, but other languages like HTML or VBScript can also be used. XSS attacks exploit
vulnerabilities in web applications to execute unauthorized scripts in the context of a trusted
website.
$_SERVER["PHP_SELF"] is a superglobal variable in PHP that returns the current script name
relative to the root directory. While convenient, it is vulnerable to security risks, especially
Cross-Site Scripting (XSS) attacks, if user input is used in combination with it.
For example, an attacker might inject a malicious script into the URL that gets echoed back by
the PHP script, leading to an XSS attack.
Q: How to create a link in HTML that will connect another web page when
clicked?
To create a link in HTML that connects to another web page when clicked, you can use the <a> (anchor)
tag, which is specifically designed for linking. Here's the basic syntax:
href: Specifies the URL (web address) of the page you want to link to.
Link Text: This is the text that will appear as the clickable link.
In this example:
The link text "Click here to visit Example.com" will appear as a clickable link.
When the user clicks the link, they will be redirected to https://www.example.com.
Q: Name some common lists that are used when designing a page?
When designing a webpage, lists are commonly used to organize content and improve
readability. Here are some common types of lists that are frequently used in web design:
To insert a picture as a background image on a webpage, you can use the CSS property
background-image. This allows you to set an image as the background for any HTML element,
such as the body or a div.
Here are some examples and techniques to add a picture as a background image for your web
page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Background Image Example</title>
<style>
body {
background-image: url('background.jpg');
background-size: cover; /* Ensure the image covers the entire page */
background-position: center; /* Center the image */
background-attachment: fixed; /* Make the image stay in place while scrolling */
}
</style>
</head>
<body>
</body>
</html>
background-image: url('background.jpg');: This sets the background image. Replace
'background.jpg' with your image path or URL.
background-size: cover;: Ensures the image covers the entire viewport (screen) even if
the aspect ratio of the image doesn't match the screen size.
background-position: center;: Centers the image on the screen.
background-attachment: fixed;: Keeps the background image fixed while scrolling
(optional).
Q: Why we use bootstrap?
Bootstrap is used primarily to quickly build responsive websites by providing pre-designed components
like buttons, forms, navigation bars, and a grid system, allowing developers to create visually appealing
and functional layouts without writing extensive custom CSS code, saving significant development time
while ensuring consistent design across different devices and browsers; essentially, it acts as a readily
available toolkit for front-end web development.
Q: grid system of bootstrap
The Bootstrap Grid System is a flexible layout system that allows you to design responsive and
mobile-first web pages using a 12-column structure. Here’s a quick overview:
Key Components:
1. Container:
o .container: Fixed-width container.
o .container-fluid: Full-width container that spans the entire viewport.
2. Row:
o .row: Defines a horizontal group of columns.
3. Columns:
o Columns are created using .col-* classes, where * is the number of columns the
element should span (e.g., .col-6 for half-width).
o Bootstrap's grid is based on 12 columns in total.
Responsive Breakpoints:
.col-: Extra small screens (<576px).
.col-sm-: Small screens (≥576px).
.col-md-: Medium screens (≥768px).
.col-lg-: Large screens (≥992px).
.col-xl-: Extra large screens (≥1200px).
Q: How does web site programming works?
Website programming involves the process of creating and managing a website’s functionality
through code. Here’s how it works in short:
1. Front-End (Client-Side) Programming:
HTML: Defines the structure and content of a webpage (headings, paragraphs, images,
links, etc.).
CSS: Styles the webpage, controlling layout, colors, fonts, and overall appearance.
JavaScript: Adds interactivity, such as handling user clicks, form submissions, and
dynamic content updates without refreshing the page.
These front-end elements are processed by the web browser (like Chrome or Firefox) when a
user visits a webpage.
2. Back-End (Server-Side) Programming:
Server: A server is a computer that hosts the website and processes requests.
Programming Languages: Languages like PHP, Python, Node.js, Ruby, or Java handle
the business logic, database interaction, and data processing.
Database: A database (like MySQL, PostgreSQL, MongoDB) stores and retrieves data,
such as user information, product data, or blog posts.
The back-end processes user requests, retrieves data, and sends it back to the front-end for
display.
3. Interaction Between Front-End and Back-End:
When a user visits a webpage or submits a form, the browser (front-end) sends a request
to the server (back-end).
The server processes the request, accesses the database if needed, and then sends the
relevant data back to the front-end to be displayed to the user.
4. Web Frameworks and Libraries:
Web frameworks (e.g., React, Angular for front-end, Django, Flask for back-end)
simplify development by providing pre-built functions and structure.
APIs: Application Programming Interfaces (APIs) are used to exchange data between the
front-end and back-end.
Q: What are the benefits of Web programming?
The benefits of web programming include:
1. Accessibility: Web applications can be accessed from any device with an internet
connection, making them platform-independent.
2. Cost-Effective: Web apps eliminate the need for software installation on each user’s
device, reducing maintenance and deployment costs.
3. Scalability: Web applications can easily scale to accommodate increasing traffic and
users.
4. Real-Time Updates: Changes or updates can be made on the server-side, meaning all
users receive the latest version instantly without requiring updates on their end.
5. Cross-Platform Compatibility: Web applications work across different operating
systems and devices (Windows, macOS, iOS, Android) using browsers.
6. Security: Centralized server-based applications make it easier to apply security updates
and control access.
7. Global Reach: Websites can be accessed by users worldwide, providing a broad
audience for businesses, services, and content.
8. Interactivity: Web programming enables the creation of dynamic, interactive, and user-
friendly websites with features like forms, chat, and real-time updates.
Q: How can you integrate CSS in a web page?
you can integrate CSS (Cascading Style Sheets) into a web page in three ways:
Method: Define styles inside a <style> block in the <head> section of the HTML
document.
Use case: For styling the page as a whole without affecting other pages. This is useful for
a single-page website.
Method: Link an external CSS file to the HTML document using the <link> tag in the
<head> section.
Use case: Best for large websites with multiple pages to maintain a consistent style across
all pages.
Q: What benefits and demerits do external style sheets have?
The CSS Box Model defines how elements are structured and how their dimensions are
calculated in a webpage. It consists of four key elements:
1. Content: The actual content of the element (text, images, etc.), where width and height
are applied.
2. Padding: The space between the content and the border. It adds inner space within the
element.
3. Border: A line around the padding (if any), which can be styled with width, color, and
type.
4. Margin: The outermost space around the border, separating the element from others.
In this example:
button:hover {
background-color: green;
transform: scale(1.1);
}
</style>
</head>
<body>
<button>Hover Me</button>
</body>
</html>
How It Works:
On hover: The button smoothly changes its background color and slightly scales up.
The transition is applied only to the specified properties.
Note: Use all as the property to apply transitions to all animatable properties.
Q: Are Java & Javascript same?
No, Java and JavaScript are not the same. While their names are similar, they are distinct
programming languages with different purposes and characteristics.
Summary:
The similarity in their names is coincidental, as JavaScript was named during a marketing partnership
between Netscape (the creator of JavaScript) and Sun Microsystems (the creator of Java).
Q: How Javascript can change HTML content & HTML attributes value.
JavaScript can dynamically change HTML content and attributes using the DOM (Document
Object Model). Here's how:
1. Change HTML Content:
Use the innerHTML property to update the content of an element.
Example:
<p id="demo">Original Content</p>
<script>
document.getElementById("demo").innerHTML = "New Content";
</script>
2. Change HTML Attributes:
Use the setAttribute() method or directly modify the attribute.
Example 1: Using setAttribute():
<img id="image" src="old.jpg" alt="Old Image">
<script>
document.getElementById("image").setAttribute("src", "new.jpg");
</script>
Summary:
Content: Modify with innerHTML or textContent.
Attributes: Update using setAttribute() or direct property changes.
Q: innerHTML - The innerHTML property in JavaScript is used to get or set the HTML
content inside an element. It allows you to manipulate the contents of an HTML element
dynamically.
Key Points:
It can insert both plain text and HTML tags.
Be cautious: Setting innerHTML with untrusted user input may lead to Cross-Site
Scripting (XSS) vulnerabilities.
Summary:
The innerHTML property is a simple and effective way to update the content of HTML elements
dynamically. However, for secure and efficient applications, use it with caution and consider
safer alternatives where possible.
Alternative: Use textContent if you only need to insert plain text without parsing HTML.
Q: document.write() function
The document.write() function in JavaScript writes text, HTML, or other content directly to
the web page during the initial rendering process.
Syntax: document.write(content);
content: The string (text or HTML) to be written to the document.
Key Features:
1. It directly inserts the content into the HTML page.
2. Can be used to include text, HTML elements, or even scripts.
Summary:
document.write() writes content directly to the webpage during rendering.
It can overwrite the page content if used after the document is fully loaded.
Better alternatives, like innerHTML or DOM methods, should be used for modern
development.
Q: window.alert() function
The window.alert() function in JavaScript is used to display a pop-up alert dialog with a
specified message. It is typically used to show information, warnings, or simple messages to the
user.
Syntax:
window.alert(message);
message: The text or content to display in the alert dialog.
The window object is optional because it is the global object in browsers. You
can also simply write:
alert(message);
Summary:
The window.alert() function is a simple way to display a message in a modal dialog box.
While useful for basic alerts or debugging, it is not suitable for modern, interactive applications
due to its interruptive nature and lack of customization.
Q: console.log function
The console.log() function in JavaScript is used to output messages or values to the browser's
console. It is commonly used for debugging and tracking the execution of code.
Syntax:
console.log(message);
message: The data (string, variable, object, etc.) to be logged in the console.
Summary:
console.log() is a powerful and simple tool for debugging and tracking the flow of your
JavaScript code. It helps developers identify and fix issues quickly but should be removed or
minimized in production environments.
Q: E-commerce (Electronic Commerce) refers to the buying and selling of goods,
services, or information over the internet. It enables businesses and consumers to
conduct transactions online without the need for physical interaction.
Types of E-commerce:
1. B2B (Business-to-Business): Transactions between businesses (e.g., wholesaler to
retailer).
2. B2C (Business-to-Consumer): Businesses sell directly to consumers (e.g., Amazon,
eBay).
3. C2C (Consumer-to-Consumer): Individuals sell to other individuals (e.g., eBay,
Craigslist).
4. C2B (Consumer-to-Business): Consumers offer products or services to businesses (e.g.,
freelancing platforms).
5. D2C (Direct-to-Consumer): Manufacturers sell directly to consumers, bypassing
intermediaries.
Advantages:
Convenience for buyers and sellers.
Wider market reach.
Cost-effective operations.
Easy scalability and access to data analytics.
Disadvantages:
Security concerns (e.g., fraud, hacking).
Lack of personal interaction.
Dependence on internet connectivity.
Key Applications of E-commerce:
1. Retail and Wholesale:
Online stores like Amazon, eBay, and Walmart offer a variety of products for purchase.
Retailers sell directly to consumers, while wholesalers cater to businesses.
2. Banking and Finance:
Online banking, fund transfers, and bill payments are enabled through e-commerce
platforms.
Financial institutions provide services like loan applications and investment management
online.
3. Online Marketplaces:
Platforms like Etsy and Alibaba allow sellers to list products for global customers.
Facilitates consumer-to-consumer (C2C) transactions.
4. E-Tickets and Entertainment:
Booking tickets for flights, trains, events, and movies is made convenient through
platforms like Ticketmaster and Expedia.
Streaming services (e.g., Netflix, Spotify) provide digital entertainment.
5. Education and Training:
E-learning platforms like Udemy, Coursera, and Khan Academy offer online courses and
certifications.
Universities use e-commerce for enrollment and material distribution.
6. Healthcare:
E-commerce is used for telemedicine, online consultations, and purchasing medicines
(e.g., 1mg, Netmeds).
Appointment booking and health management systems improve accessibility.
7. Food and Grocery Delivery:
Platforms like Uber Eats, DoorDash, and Instacart allow users to order food or groceries
online.
Restaurants and supermarkets utilize e-commerce to expand their reach.
8. Travel and Tourism:
Booking accommodations, flights, and travel packages through platforms like Airbnb and
Booking.com.
Travel insurance and itinerary planning services are also part of this application.
9. Real Estate:
Platforms like Zillow and Realtor.com enable users to search for properties and schedule
virtual tours.
Online payments for rent and real estate transactions are facilitated.
10. Subscription Services:
Services like software (SaaS), magazines, and digital tools are sold via recurring
subscription models (e.g., Adobe Creative Cloud, Microsoft 365).
6. International Trade:
Bilateral Agreements: The government aims to establish treaties with other countries to
facilitate international e-commerce, including streamlined customs procedures and
improved delivery channels.
These regulations are designed to create a secure and transparent environment for both
consumers and businesses in Bangladesh's e-commerce sector.
Q: Define active page
An active page refers to the web page that is currently in focus or being viewed by the user in a
browser. It is the page that is loaded and interacting with the user at any given time.
In a multi-page website, only one page can be "active" at a time. This is typically the page that is
displayed in the browser window. The concept of an active page can also extend to links,
navigation, or tabs within the website, where the "active" state indicates which section or
element is currently selected or being interacted with.
1. Navigation: Highlighting the current page in a navigation menu. For example, if a user is
on the "About Us" page, the "About Us" link in the menu might be styled differently to
indicate it’s the active page.
2. Tabs and Pages: On websites or web applications with multiple tabs or sections (like a
dashboard), the active page is the one that the user is viewing at the moment. The design
often visually differentiates it from other inactive tabs.
Differences:
Fixed, doesn’t change unless manually Changes dynamically based on user input or server
Content
updated data
Interaction No server/database interaction Server and database interactions for real-time data
Load Time Faster, as no processing is required Slower, due to server processing and data fetching
Use Case Informational websites, portfolios E-commerce, social media, news websites
Scalability Less scalable for large content updates More scalable for large and dynamic websites