IT602 Web Technology Exam 2023
IT602 Web Technology Exam 2023
HTTP (Hypertext Transfer Protocol) is the protocol used for transferring data over the web. Its significance lies in enabling the communication between web clients and servers. The process involves a client sending an HTTP request to a server, which then processes this request and responds with an HTTP response. The communication is stateless, meaning each transaction is independent. HTTP is foundational for web browsing, facilitating the fetching and rendering of web pages.
MVC (Model-View-Controller) architecture is pivotal in web development because it separates the application into three interconnected components. The Model encapsulates the core data and business logic, the View is the user interface, and the Controller manages user input and interfaces with the Model. This separation of concerns facilitates modularity, making development, debugging, and scaling easier. It also allows multiple views for the same model, improving flexibility in user interface design.
The Servlet lifecycle consists of three main phases: initialization, request handling, and destruction. It begins with the servlet being loaded into memory by the web container (initialization), followed by handling requests via the service method, and ends with the servlet being destroyed when the server needs to free up resources (destruction). This lifecycle is essential for web applications as it provides a standardized way of managing servlets, ensuring efficient resource management and dynamic response generation for web clients.
RMI (Remote Method Invocation) architecture in Java allows an object residing in one Java virtual machine to invoke methods on an object in another Java virtual machine. It facilitates remote communication by using a client-server model where the client side gets a reference to the remote object and invokes methods as if they were local. The communication takes place over Java Remote Method Protocol (JRMP)
To prevent SQL injection, web applications can implement several security measures: using prepared statements and parameterized queries to separate SQL code from data input, employing stored procedures which are usually pre-compiled and thus immune to injection, validating and sanitizing input to allow only expected types and formats, and employing ORM frameworks that abstract database interactions, reducing the likelihood of injection. Additionally, regular security testing and updates help identify and fix vulnerabilities.
Web services facilitate interoperability by adhering to open standards such as XML, SOAP, and HTTP, allowing different platforms and technologies to communicate over the Internet. XML enables data structuring in a way that can be understood across programs and languages, SOAP provides a protocol for message exchanges, and HTTP serves as a transport protocol. This combination allows web services to enable applications built on different platforms to exchange data seamlessly, making them widely applicable in distributed systems.
In JDBC, the Statement object is used to execute SQL queries, which do not require parameters, on the database. It serves as a vehicle for sending SQL statements to the database. The ResultSet, on the other hand, represents the result set of a query. It maintains a cursor pointing to the current row in the result set and allows sequential access of data retrieved from the database.
AJAX enhances user experience by allowing web pages to update asynchronously, without reloading the entire page. This leads to smoother performance and faster interactions as only parts of the page that need updating get refreshed. A basic example of AJAX code for reading data from a file involves using the XMLHttpRequest object to request data from the server, handling server responses, and updating the webpage content dynamically without full reloads.
SAX (Simple API for XML) and DOM (Document Object Model) are two different approaches for processing XML data. SAX is an event-driven, serial access protocol suitable for large XML documents as it doesn't load the entire document into memory. It reads XML tags, attributes, and values one by one, making it faster and less memory-intensive. DOM, however, is an object-based protocol that loads the entire XML document into memory and enables traversal and manipulation of the data, making it more suitable for smaller documents where the entire structure needs manipulation. SAX is preferred in performance-critical applications, while DOM is chosen for ease of use when working with small to medium-sized documents.
Both doGet() and doPost() are used to handle HTTP requests in servlets. doGet() is used for requests that produce data retrieval operations and appends form data to the URL; it is idempotent and can be cached. In contrast, doPost() handles requests that change state or have side effects on the server and send form data in the body of the request; it is not idempotent. Cookies can be utilized in both methods to store session data on the client side. For example, in a login service, cookies can remember usernames and passwords to maintain user sessions across different requests.