ITA Important Questions[2]
ITA Important Questions[2]
1.
<City>
<Name>Mumbai</Name>
<State>Maharashtra</State>
<WeatherStationCode>MUM101</WeatherStationCode>
<Wind>
<Speed>9.2</Speed>
<Direction>SW</Direction>
<Gusts>14.1</Gusts>
</Wind>
<Humidity>72.0</Humidity>
<Temperature>
<Min>26.0</Min>
<Max>34.0</Max>
</Temperature>
<AtmosphericPressure>1008.7</AtmosphericPressure>
<Rainfall>15.0</Rainfall>
<AQI>95</AQI>
</City>
<City>
<Name>Bangalore</Name>
<State>Karnataka</State>
<WeatherStationCode>BLR202</WeatherStationCode>
<Wind>
<Speed>6.0</Speed>
<Direction>NE</Direction>
<Gusts>10.0</Gusts>
</Wind>
<Humidity>60.0</Humidity>
<Temperature>
<Min>20.0</Min>
<Max>30.0</Max>
</Temperature>
<AtmosphericPressure>1015.0</AtmosphericPressure>
<Rainfall>0.0</Rainfall>
<AQI>42</AQI>
</City>
</WeatherData>
<xs:element name="WeatherData">
<xs:complexType>
<xs:sequence>
<xs:element name="City" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="State" type="xs:string"/>
<xs:element name="WeatherStationCode" type="xs:string"/>
<xs:element name="Wind">
<xs:complexType>
<xs:sequence>
<xs:element name="Speed" type="xs:float"/>
<xs:element name="Direction" type="xs:string"/>
<xs:element name="Gusts" type="xs:float"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Humidity" type="xs:float"/>
<xs:element name="Temperature">
<xs:complexType>
<xs:sequence>
<xs:element name="Min" type="xs:float"/>
<xs:element name="Max" type="xs:float"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="AtmosphericPressure" type="xs:float"/>
<xs:element name="Rainfall" type="xs:float"/>
<xs:element name="AQI" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
2. What is DTD? How it is used to define the elements and their attributes for an XML file?
Explain with help of an example .
DTD (Document Type Definition) is a way to define the structure and rules for an XML
document. It tells what elements, attributes, and data types can appear, how they nest, and
in what order — just like a grammar for the XML file.
It helps:
• Validate XML files (i.e., check if they follow the correct format).
Types of DTD
Defining Elements :
Defining Attributes
Example :
<?xml version="1.0"?>
<!DOCTYPE WeatherData [
]>
<WeatherData>
<City id="c1">
<Name>Delhi</Name>
<State>Delhi</State>
<Code>DL001</Code>
<Wind>
<Speed>15</Speed>
<Direction>NW</Direction>
<Gusts>20</Gusts>
</Wind>
<Humidity>40</Humidity>
<Temperature>
<Min>25</Min>
<Max>38</Max>
</Temperature>
<Pressure>1012</Pressure>
<Rainfall>2.5</Rainfall>
<AQI>150</AQI>
</City>
</WeatherData>
3. What is AJAX. How an AJAX operation sends a GET request to the server and displays
the response in the browser .
AJAX stands for Asynchronous JavaScript and XML. It's a technique used in web
development to send and receive data from a server asynchronously — without
having to reload the entire web page.
Key Points:
• Uses JavaScript (often with XMLHttpRequest or fetch) to communicate with the
server.
• Data can be in various formats — XML, JSON, HTML, or plain text.
• Allows smoother, faster, and more interactive user experiences.
<!DOCTYPE html>
<html>
<head>
<title>AJAX Example</title>
</head>
<body>
<div id="result"></div>
<script>
function loadData() {
// Step 1: Create an XMLHttpRequest object
var xhttp = new XMLHttpRequest();
</body>
</html>
Sample Server File: weather-info.txt :
Weather in Mumbai: 33°C, Humidity: 60%, Wind: 18 km/h NW
4. What is XML? Advantages of XML over HTML. What are the rules to create a well-
formed XML file?
Example :
<Student>
<Name>Ravi Kumar</Name>
<RollNo>101</RollNo>
<Course>Computer Science</Course>
</Student>
1. Single Root Element : There must be one and only one root element.
Ex : <Students> ... </Students>
2. Properly Nested Elements : Elements must be properly closed and not
overlap.
Ex : <Name><First>John</First><Last>Doe</Last></Name>
<Name><First>John</Name></First> Invalid
3. Every Tag Must Be Closed : All opening tags must have matching closing tags.
Ex: <RollNo>101</RollNo>
<RollNo>101
4. Tags are Case-Sensitive : <Name> and <name> are different.
5. Attribute Values Must Be Quoted :
Ex: <student id="101">
<student id=101>
6. No Reserved Characters in Data :
Characters like <, >, &, " must be replaced with entities:
< → <
> → >
& → &
" → "
5. Explain the life cycle of a JSP page with a suitable diagram. Explain each phase of the
life cycle and the functions calls.
Note: You should not override _jspService() — it's automatically generated and
handled.
6. Destruction – jspDestroy()
• Called only once when the JSP is removed or the server shuts down.
• Used to release resources like closing DB connections, cleaning up, etc
6. Explain the different types of tags used in JSP and their purpose. Give an example for
each type of tag.
In JSP (JavaServer Pages), different types of tags are used to insert Java code, control
the behavior of the page, and interact with clients. These tags help mix HTML with
Java logic effectively.
1. Directive Tags :
Purpose: Provide global information about the JSP page to the container (e.g.,
import packages, define page encoding, error handling, etc.)
Common Directives:
page: Defines page-level instructions (e.g., imports, error page).
include: Includes a static file during translation.
taglib: Declares a tag library.
Syntax : <%@ directive attribute="value" %>
Example :
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="header.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
2. Scriptlet Tags :
Purpose: Embeds Java code that is executed every time the page is requested.
Syntax : <% java_code %>
Example :
<%
int x = 10;
out.println("Value of x: " + x);
%>
3. Expression Tags :
Purpose: Evaluates a Java expression and outputs the result directly to the client.
Example:
4. Declaration Tags :
Purpose: Declare methods or variables at the class level of the servlet
generated from the JSP.
Syntax : <%! declaration %>
Example:
<%!
int counter = 0;
public int getCounter() {
return ++counter;
}
%>
<p>Counter: <%= getCounter() %></p>
5. Action Tags :
Purpose : Used to control the behavior of the JSP engine (includes, forwards,
etc.) — use XML syntax.
Syntax : <jsp:action attribute="value" />
Examples
Include another resource:
jsp
CopyEdit
<jsp:include page="footer.jsp" />
Forward to another resource:
jsp
CopyEdit
<jsp:forward page="home.jsp" />
Use JavaBeans:
jsp
CopyEdit
<jsp:useBean id="user" class="com.example.User" scope="session" />
<jsp:setProperty name="user" property="name" value="John" />
<jsp:getProperty name="user" property="name" />
6. Custom Tags :
Purpose : Reusable components defined using JSP Tag Libraries (JSTL) or your
own tags.
Example using JSTL Core Library:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:if test="${param.age > 18}">
<p>You are eligible.</p>
</c:if>
A JSP Element is a construct in JavaServer Pages (JSP) used to embed Java code or
JSP-specific instructions into HTML pages. These elements allow the server to
dynamically generate web content based on logic written in Java.
***********same tags explained above are the nswers for thi question *********
8. What is SOAP? Explain with suitable examples a SOAP Request and its
Response in XML.
SOAP (Simple Object Access Protocol) is a protocol used for exchanging
structured information in the implementation of web services. It allows
programs running on different operating systems to communicate using HTTP
and XML.
Key Features of SOAP:
Platform and language independent
Uses XML to encode messages
Typically sent via HTTP or SMTP
Supports request/response model
Well-defined SOAP envelope structure
SOAP Message Structure:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header> <!-- Optional --></soap:Header>
<soap:Body> <!-- Required -->
<!-- Application-specific data -->
</soap:Body>
</soap:Envelope>
Suppose we want to call a Add method in a web service that adds two numbers.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Add xmlns="http://tempuri.org/">
<intA>5</intA>
<intB>10</intB>
</Add>
</soap:Body>
</soap:Envelope>
SOAP Response : If the service successfully processes the request, it may respond
with:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddResponse xmlns="http://tempuri.org/">
<AddResult>15</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>
v. Digital Signature
A Digital Signature is a cryptographic technique used to validate the authenticity
and integrity of a digital message or document.
• It uses public key encryption.
• Ensures that the message:
o Comes from a verified sender
o Has not been tampered with
Process:
1. Sender generates a hash of the message.
2. Encrypts it using their private key.
3. Receiver uses sender’s public key to verify the signature.
Example: Used in secure emails, e-invoices, e-governance documents.
{
"name": "Charlie"
}
Response:
Json :
{ "id": 3, "name": "Charlie" }
3. PUT Request – Update a User
http :
PUT /users/3 HTTP/1.1
Host: api.example.com
Content-Type: application/json
{
"name": "Charles"
}
🔹 Key Features:
i. Platform-independent (e.g., Java can talk to .NET)
ii. Uses standard data formats like XML or JSON
iii. Can be accessed via URL
iv. Interoperable – works across different systems
🔹 Example Use Case:
A weather web service provides current temperature data. Your app can call this
service, receive the response, and display it to the user.
Service-Oriented Architecture (SOA) is a design pattern or architectural style where
applications are structured as a collection of independent, reusable services that
communicate over a network.
🔹 Key Characteristics:
I. Loose coupling – services are independent
II. Reusability – services can be reused across different apps
III. Interoperability – services built in different languages/platforms can work together
IV. Standard interfaces – often use WSDL for SOAP or OpenAPI for REST
🔹 Example:
An e-commerce system built using SOA might have:
i. A User Service for handling user authentication
ii. An Order Service for managing customer orders
iii. A Payment Service to process payments
Each service runs independently but works together to form the full system.
13. Explain the three types of JSP Directive tag with suitable examples.
1. Page Directive
Purpose:
• Defines page-level instructions like importing packages, defining content type, error
page, etc.
Syntax:
jsp
CopyEdit
<%@ page attribute="value" %>
Common Attributes:
• import: Import Java packages
• contentType: Define MIME type
• errorPage: Set error handler page
• isErrorPage: Specify if the page handles errors
Example:
jsp
CopyEdit
<%@ page import="java.util.*, java.sql.*" %>
<%@ page contentType="text/html" %>
<%@ page errorPage="error.jsp" %>
2. Include Directive
Purpose:
• Includes a static file (HTML, JSP, etc.) during translation time (before the JSP is
compiled).
Syntax:
jsp
CopyEdit
<%@ include file="filename.jsp" %>
Example:
jsp
CopyEdit
<%@ include file="header.jsp" %>
<p>Main content of the page here</p>
<%@ include file="footer.jsp" %>
Includes are useful for common page parts like headers and footers.
3. Taglib Directive
Purpose:
• Declares a tag library to use custom tags in the JSP using JSTL or other tag libraries.
Syntax:
jsp
CopyEdit
<%@ taglib uri="uri" prefix="prefixName" %>
Example (JSTL Core Tags):
jsp
CopyEdit
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
14. Explain the values of the readyState property of XMLHttpRequest object and
their significance.
The readyState property of the XMLHttpRequest object in AJAX indicates the current
state of the request. It holds an integer value from 0 to 4, each representing a
different phase of the request–response cycle.
XMLHttpRequest.readyState Values :
Explanation:
• onreadystatechange is triggered every time readyState changes.
• When readyState is 4 and status is 200 (OK), the request is successful, and the
response is processed.
15.
SOAP Request :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:web="http://example.com/webservice">
<soapenv:Header/>
<soapenv:Body>
<web:ConvertCurrency>
<web:SourceCurrency>INR</web:SourceCurrency>
<web:TargetCurrency>USD</web:TargetCurrency>
<web:FromAmount>1000</web:FromAmount>
</web:ConvertCurrency>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:web="http://example.com/webservice">
<soapenv:Header/>
<soapenv:Body>
<web:ConversionResponse>
<web:SourceCurrency>INR</web:SourceCurrency>
<web:TargetCurrency>USD</web:TargetCurrency>
<web:SourceAmount>1000</web:SourceAmount>
<web:ConvertedAmount>12.15</web:ConvertedAmount>
</web:ConversionResponse>
</soapenv:Body>
</soapenv:Envelope>
16.
XML with Internal DTD :
<showroom>
<twoWheeler>
<type>scooter</type>
<brandName>Honda Activa</brandName>
<modelNumber>ACT123</modelNumber>
<category>utility</category>
<price>75000</price>
<mileage>50</mileage>
<manufacturer>
<name>Honda Motors</name>
<address>
<addressLine1>Plot No. 12</addressLine1>
<addressLine2>Industrial Area</addressLine2>
<street>MG Road</street>
<city>Gurgaon</city>
<state>Haryana</state>
<pincode>122001</pincode>
<customerCare>18001031031</customerCare>
</address>
</manufacturer>
</twoWheeler>
<twoWheeler>
<type>bike</type>
<brandName>Yamaha FZ</brandName>
<modelNumber>FZV2</modelNumber>
<category>sports</category>
<price>95000</price>
<mileage>45</mileage>
<manufacturer>
<name>Yamaha India</name>
<address>
<addressLine1>No. 21</addressLine1>
<addressLine2>Main Road</addressLine2>
<street>Bannerghatta Road</street>
<city>Bangalore</city>
<state>Karnataka</state>
<pincode>560076</pincode>
<customerCare>18004201600</customerCare>
</address>
</manufacturer>
</twoWheeler>
</showroom>
Key Points:
i. The root element is <showroom>.
ii. Each <twoWheeler> holds:
o Basic info: <type>, <brandName>, <modelNumber>, <category>, <price>,
<mileage>.
o Nested <manufacturer> element which includes <name> and an <address>
block.
17.
SOAP Request :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://example.com/temperature">
<soapenv:Header/>
<soapenv:Body>
<tem:ConvertTemp>
<tem:FromUnit>DEG</tem:FromUnit>
<tem:ToUnit>FRN</tem:ToUnit>
<tem:Temperature>100</tem:Temperature>
</tem:ConvertTemp>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://example.com/temperature">
<soapenv:Header/>
<soapenv:Body>
<tem:TempConvResponse>
<tem:FromUnit>DEG</tem:FromUnit>
<tem:ToUnit>FRN</tem:ToUnit>
<tem:FromTemp>100</tem:FromTemp>
<tem:ConvertedTemp>212</tem:ConvertedTemp>
</tem:TempConvResponse>
</soapenv:Body>
</soapenv:Envelope>
Notes:
i. The namespaces (like http://example.com/temperature) should be replaced with the
actual namespace URI used by your web service.
ii. The units (DEG, FRN, KVN, etc.) are custom 3-letter codes for degrees Celsius,
Fahrenheit, Kelvin, etc.
iii. SOAP uses XML format to structure the request and response.
18.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Place Order</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
}
form {
max-width: 600px;
margin: auto;
background: #f9f9f9;
padding: 20px;
border-radius: 8px;
}
h2 {
text-align: center;
}
label {
display: block;
margin-top: 10px;
font-weight: bold;
}
input {
width: 100%;
padding: 8px;
margin-top: 5px;
}
.section-title {
margin-top: 20px;
font-size: 18px;
color: #333;
}
button {
margin-top: 20px;
width: 100%;
padding: 10px;
background: #28a745;
color: white;
border: none;
border-radius: 4px;
font-size: 16px;
}
.error {
color: red;
font-size: 14px;
}
</style>
</head>
<body>
<form id="orderForm">
<h2>Place Order</h2>
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="b_street">Street:</label>
<input type="text" id="b_street" name="b_street" required>
<label for="b_city">City:</label>
<input type="text" id="b_city" name="b_city" required>
<label for="b_state">State:</label>
<input type="text" id="b_state" name="b_state" required>
<label for="s_street">Street:</label>
<input type="text" id="s_street" name="s_street" required>
<label for="s_city">City:</label>
<input type="text" id="s_city" name="s_city" required>
<label for="s_state">State:</label>
<input type="text" id="s_state" name="s_state" required>
<label for="s_pin">Pin Code:</label>
<input type="text" id="s_pin" name="s_pin" required pattern="[0-9]{6}"
placeholder="6 digit PIN">
<script>
document.getElementById('orderForm').addEventListener('submit', function (e) {
const phone = document.getElementById('phone').value;
const b_pin = document.getElementById('b_pin').value;
const s_pin = document.getElementById('s_pin').value;
let error = '';
if (!/^\d{10}$/.test(phone)) {
error += 'Phone number must be exactly 10 digits.\\n';
}
if (!/^\d{6}$/.test(b_pin)) {
error += 'Billing PIN must be exactly 6 digits.\\n';
}
if (!/^\d{6}$/.test(s_pin)) {
error += 'Shipping PIN must be exactly 6 digits.\\n';
}
if (error) {
e.preventDefault();
alert(error);
}
});
</script>
</body>
</html>
19.
<form id="quickApplyForm">
<h2>Quick Apply</h2>
<label for="name">Name:</label>
<input type="text" id="name" required>
<label for="email">Email:</label>
<input type="email" id="email" required>
<label for="age">Age:</label>
<input type="number" id="age" required>
<button type="submit">Apply</button>
</form>
<script>
document.getElementById('quickApplyForm').addEventListener('submit', function
(e) {
const name = document.getElementById('name').value.trim();
const email = document.getElementById('email').value.trim();
const age = parseInt(document.getElementById('age').value);
const mobile = document.getElementById('mobile').value.trim();
const qualification = document.getElementById('qualification').value;
const bio = document.getElementById('bio').value.trim();
if (!/^\d{10}$/.test(mobile)) {
errorMsg += 'Mobile number must be exactly 10 digits.\n';
}
if (errorMsg) {
e.preventDefault();
alert(errorMsg);
}
});
</script>
</body>
</html>
20. What are the benefits of using AJAX over conventional web development?
• AJAX allows updating parts of a web page without reloading the entire page.
• Traditional web apps reload the entire page for every interaction.
• Unlike conventional methods, entire HTML pages aren't sent each time.
This means less data transfer, saving server resources and bandwidth.
• AJAX can fetch or send data in the background, allowing the user to continue using
the page uninterrupted.
• Asynchronous behavior means the page doesn't get blocked while waiting for server
response.
21. Explain the concept of AJAX. Describe an AJAX operation step by step that
sends a GET request to the server and displays the response in a designated
space on a web page with a suitable example.
Answer:
AJAX (Asynchronous JavaScript and XML) allows web pages to be updated without reloading
the entire page, making them more dynamic and user-friendly. It achieves this by using
JavaScript to send and receive data from a server in the background, using a special object
called XMLHttpRequest.
Here's a step-by-step breakdown of an AJAX operation sending a GET request and displaying
the response:
<div id="myDiv"></div>
This HTML sets up a div element (myDiv) where the data will be displayed, and a button that
triggers the AJAX request.
2. JavaScript Code:
JavaScript
function sendRequest() {
xhttp.onload = function() {
if (this.status == 200) {
document.getElementById("myDiv").innerHTML = this.responseText;
} else {
};
xhttp.send();
Step 3:
An XMLHttpRequest object (xhttp) is created. This object handles the communication with
the server.
Step 4:
An onload function is defined. This function is executed when the server responds to the
request. The this.status property indicates the HTTP status code of the response (e.g., 200
for success).
Step 5:
Inside the onload function, the response text (this.responseText) is retrieved and used to
update the content of the myDiv element.
Step 6:
The open() method is used to configure the request:
get_data.php: The URL of the server-side script that will handle the request.
Step 7:
Code
<?php
echo $data;
?>
This PHP script (or any other language) receives the request, processes it, and returns the
data as a response. In this example, it simply echoes a string.
In summary: A button click triggers the JavaScript code. The JavaScript creates an AJAX
request, sends it to the server, receives the server's response, and then updates the web
page without a full page reload.
22. Describe the three dialog boxes provided by the window object with code
examples, output and their use.
Code Example:
Javascript:
alert("This is an alert box!");
Output:
A pop-up box with the message:
This is an alert box!
[OK]
Use:
• Show important messages.
• Notify about form validation errors.
• Debugging (simple alerts during development).