Lab Assignment 2
Lab Assignment 2
1. While creating a website, how many tags can you use? List them with explanation.
There are many HTML tags, some important ones include:
6. How many platforms are available to write down HTML code? Which one is better? Explain in
brief.
Platforms:
7. In List tags there is <DD>, <DT>... Tags are available. Why are they used during making of
website?
These are used in Definition Lists:
<dt>HTML</dt>
</dl>
8. Can we implement <blockquote> tag to make Restaurant website? What is the purpose of
<fieldset> and <legend> tags?
<fieldset>
<legend>Reservation Details</legend>
</fieldset>
9. What are the technologies available in client-side for web application development?
• HTML: Structure
• CSS: Styling
10. What are the rules for cascading style sheet to implement inheritance concept?
CSS Inheritance rules:
color: inherit;
Let me know if you want these answers in a printable format (Word or PDF).
Lab Assignment 3
Here are the answers to your XML Lab Assignment – 3 questions:
1. What is meant by XML document? How can we store data with the help of XML language?
XML (Extensible Markup Language) is a markup language designed to store and transport data. It is
both human-readable and machine-readable.
Data is stored using custom tags that define structure and meaning:
<student>
<name>John</name>
<age>22</age>
</student>
You can store data in a hierarchical format and use it in web services, configuration files, etc.
2. What is a DTD file? How many types are present in DTD file?
DTD (Document Type Definition) defines the structure and legal elements/attributes in an XML
document.
Types:
<!DOCTYPE student [
]>
• Supports namespaces
<xsl:template match="/student">
<h2><xsl:value-of select="name"/></h2>
</xsl:template>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
</xs:schema>
Building blocks:
• <xs:element>
• <xs:complexType>
• <xs:sequence>
• <xs:attribute>
• Case-sensitive.
• Attribute values must be quoted.
7. Explain tags related to XML including attributes, entities like #PCDATA and CDATA.
<student id="101">John</student>
• #PCDATA: Parsed Character Data – text that will be parsed by XML parser.
<book xmlns:ns1="http://example.com/ns1">
<ns1:title>XML Guide</ns1:title>
</book>
10. How XML processing works when the data is based on DOM?
DOM (Document Object Model) represents XML as a tree structure.
xhr.onreadystatechange = function() {
document.getElementById("result").innerHTML = xhr.responseText;
};
xhr.send();
Lab Assignment 4
Here are the answers to your JavaScript and Angular questions from the image:
1. What is the role of validation in JavaScript? List and explain types of JavaScript validation.
Role of Validation: Ensures that the user provides correct and complete input before form
submission.
Types of Validation:
• Client-side Validation: Performed in browser using JavaScript before data is sent to the
server.
• Examples:
o Required fields
• alert("Welcome!");
5. What is the purpose of JavaScript objects? Define & display JavaScript object. Create JSON
object.
Example JS Object:
let student = {
name: "John",
age: 21
};
console.log(student.name);
JSON Object:
"name": "John",
"age": 21
6. Why is JavaScript used in Angular? Explain modules in Angular with respect to directives.
• JavaScript forms the base of Angular (which uses TypeScript, a superset of JS).
Angular Modules:
Steps:
3. Create project:
4. ng new project-name
5. Serve it:
6. cd project-name
7. ng serve
Types:
1. Interpolation: {{ data }}
• The :active pseudo-class applies styles when an element is being activated (e.g., clicked).
Example:
button:active {
background-color: blue;
color: white;
Let me know if you want all answers compiled into a formatted PDF or document
Lab Assignment 5
Sure! Let's go into detailed explanation for each of the 10 questions from the Servlet assignment.
These answers are helpful for your Viva, practicals, or assignments.
A Servlet is a Java class that handles HTTP requests and generates responses. It runs on a Servlet
container (like Apache Tomcat) and is used to create dynamic web applications.
2. Class.forName("com.mysql.cj.jdbc.Driver");
3. Establish Connection:
7. Close connection.
2. mysql -u root -p
3. Create Database:
6. USE college;
7. Create Table:
13. );
Example:
while(rs.next()) {
Client-side Runs in the browser, interacts with users HTML, CSS, JavaScript
Server-side Runs on the server, handles logic/database Java Servlets, PHP, Node.js
3. destroy() – Called once when the servlet is unloaded (server shutdown or redeploy).
---> service()
---> destroy()
Example:
}
8. Which query is executed in servlet to show table?
Servlet Code:
while(rs.next()) {
out.println(rs.getString("name"));
It is used to:
• Configure servlets
Example:
<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>com.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
• HttpServlet
• HttpServletRequest
• HttpServletResponse
It is needed:
• During compilation in IDE or CLI
To add it:
Would you like me to compile all these answers into a Word or PDF file?
Lab Assignment 6
• Answer: JSP (JavaServer Pages) is a technology that helps in creating dynamic web content.
Unlike Servlets, which are pure Java code, JSP allows embedding HTML with Java code,
making it easier to design web pages. JSP is mostly used for the presentation layer, while
Servlets are better for the business logic.
• Answer: Yes, it is possible. JSP can be used to create the front-end (view) of web
applications. Combined with Servlets or JavaBeans, JSP can also handle backend processing,
form handling, session management, and database operations.
• Answer:
• Answer:
• Answer: JSTL (JavaServer Pages Standard Tag Library) is a collection of useful tags for
common tasks like iteration, conditionals, formatting, and SQL operations. It removes the
need to write Java code in JSP and promotes cleaner code.
6. How can we run JSP applications? Why the need of JavaBeans platform?
• Answer: JSP applications run on a servlet container like Apache Tomcat. JavaBeans are
reusable components used in JSP to encapsulate data and logic, promoting separation of
concerns. They can store user data, perform business logic, and interact with databases.
o Controller: Servlet – processes user input and interacts with model/view. JSP fits
perfectly in the View layer of the MVC architecture.
• Answer:
o Servlets
o JavaBeans
o JSTL
o EL (Expression Language)
o AJAX
o JDBC
o Tag Libraries
o Frameworks like Struts, Spring MVC
o Protocol for exchanging structured information in web services using XML over HTTP.
• Answer:
o Best practice: Use Servlets as Controllers and JSP as Views (in MVC).
Would you like me to compile this into a formatted PDF or document file as your assignment
submission?
Lab Assignment 7
Here is the detailed answer for Lab Assignment 7 (PHP-related):
3. How we can perform operations like file handling with help of PHP?
• If-else:
• if ($a > $b) {
• echo "A is greater";
• } else {
• echo "B is greater";
• }
• Switch-case:
• switch ($color) {
• case "red": echo "Color is red"; break;
• default: echo "Other color";
• }
• Loops:
o for, while, do...while, foreach
o Example:
o for ($i = 0; $i < 5; $i++) {
o echo $i;
o }
10. What are the operators we can perform with help of PHP?
• Arithmetic: +, -, *, /, %
• Assignment: =, +=, -=
• Comparison: ==, !=, >, <, ===, !==
• Logical: &&, ||, !
• String: . (concatenation)
o Example:
o $full = $first . " " . $last;
Lab Assignment 8
Here's the detailed explanation for Lab Assignment 8 based on Apache Struts (a popular MVC framework for
Java web applications):
• Struts is an open-source web application framework for developing Java EE web applications using the
MVC (Model-View-Controller) architecture.
• It helps developers separate the model (data), view (UI), and controller (logic).
• Latest stable version (as of 2025): Struts 2.5.x / 6.x (Struts 2 is the widely adopted version; Struts 1 is
deprecated).
• MVC architecture
• Annotation-based configuration
• AJAX support
Working:
Struts 2 provides custom tag libraries that help in creating UI elements easily. Tag types:
• Action classes are responsible for handling user requests and business logic.
• Returns a String result name like "success" or "error", which maps to a specific view (JSP).
Interceptors are objects that allow pre-processing and post-processing of a request. Uses:
• Input validation
• Logging
• Authentication/Authorization
Struts 2 uses an interceptor stack, and we can create custom interceptors too.
4. The framework automatically validates form fields before calling the action method.
• Based on the user's locale, Struts loads the correct language file.
Struts 2 supports annotation-based configuration which reduces the need for XML.
Common annotations:
Example:
@Action(value="/login", results={
@Result(name="success", location="/welcome.jsp"),
@Result(name="error", location="/login.jsp")
})
// logic
Let me know if you'd like all this converted into a PDF, Word doc, or PowerPoint!
Lab Assignment 9
Here is the detailed explanation for Lab Assignment 9 based on AngularJS and Angular:
AngularJS is a JavaScript-based open-source front-end web framework developed by Google to build dynamic
single-page applications (SPAs).
Features:
• MVC architecture
• Two-way data binding
• Dependency injection
• Routing support
AngularJS binds these components using two-way data binding, allowing real-time synchronization between
the model and view.
• ngAnimate – animations
• uppercase / lowercase
• currency
• date
• filter (search)
• limitTo
Example:
In Angular (2+):
• It uses the @Component decorator with metadata like template, selector, etc.
Example:
@Component({
selector: 'app-header',
templateUrl: './header.component.html'
})
Steps:
3. Create a project:
4. ng new my-app
6. cd my-app
8. ng serve
AngularJS uses the $http service or Angular’s HttpClient (in Angular 2+) to communicate with backends via API
calls.
$http.get("api/data").then(function(response){
$scope.data = response.data;
});
A Bootstrap wrapper is a container/component that wraps Bootstrap UI elements inside a framework like
Angular or jQuery.
• ng-bootstrap
• ngx-bootstrap
• It's a test harness for interacting with the component and its DOM.
Example:
fixture = TestBed.createComponent(AppComponent);
• It's used to tell Angular how to process and display the component.
Example:
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
• It marks a class as a component and lets Angular know how to render and use it in templates.
Let me know if you'd like this in a PDF/Word format or slides for submission!
Lab Assignment 10
Here is the detailed explanation of Lab Assignment 10 based on Enterprise JavaBeans (EJB):
EJB (Enterprise Java Bean) is a server-side software component that encapsulates business logic of an
application. It is a part of Java EE (Jakarta EE) specification and is used to build scalable, secure, and
transactional applications.
Key features:
Benefits:
• Stateless:
• Stateful:
MDB Lifecycle:
• Project dependencies
• Build tasks
• Plugins
Example snippet:
dependencies {
implementation 'javax.ejb:javax.ejb-api:3.2'
POM (Project Object Model) is the core file in Maven used to manage:
• Project metadata
• Dependencies
• Plugins
• Build lifecycle
Sample snippet:
<dependencies>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
</dependency>
</dependencies>
• Environment/Container support
• Version compatibility
Package Description
Let me know if you'd like diagrams or slides for the EJB lifecycle explanation too!