0% found this document useful (0 votes)
6 views3 pages

Web Tech Micro1

The document contains a series of questions and answers related to web development technologies, including HTML, XML, servlets, cookies, JDBC drivers, JSP, and PHP. It covers fundamental concepts, differences between various technologies, and their functionalities, such as the life cycle of servlets and JSP pages. Additionally, it discusses the use of cookies for session management and the advantages of CSS for styling web pages.

Uploaded by

Tanmay raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Web Tech Micro1

The document contains a series of questions and answers related to web development technologies, including HTML, XML, servlets, cookies, JDBC drivers, JSP, and PHP. It covers fundamental concepts, differences between various technologies, and their functionalities, such as the life cycle of servlets and JSP pages. Additionally, it discusses the use of cookies for session management and the advantages of CSS for styling web pages.

Uploaded by

Tanmay raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Q1: Differentiate between HTML and XML Q2: Difference between ROWSPAN and COLSPAN.

Q3:What are the drawback of HTML? How they are addressed in XML? Q4: What is the difference between GET and POST request?

Q5: How a HTTP servlet does handle a request? Q6: Describe the life cycle of a servlet.
Ans: An HTTP servlet handles a request through the following steps: Ans: The life cycle of a servlet consists of three main phases: Initialization, Request Handling,
Client Request: A client sends an HTTP request (e.g., GET, POST) to the web server. and Destruction. Here's a brief overview:
Servlet Container: The server forwards the request to the servlet container, which identifies the Loading and Instantiation:The servlet container loads the servlet class when it is requested for
appropriate servlet using URL mapping. the first time or at startup (if configured).
Lifecycle:If not already initialized, the servlet's init() method is called. An instance of the servlet is created.
The container spawns a thread and invokes the service() method. Initialization (init() method):Called once when the servlet is initialized by the container.
Request Processing: Used for resource allocation or initialization tasks (e.g., database connections).
The service() method delegates to doGet(), doPost(), or other HTTP-specific methods based on the Request Handling (service() method):
request type. For each request, the servlet container spawns a thread and invokes the service() method.
The servlet processes the request using HttpServletRequest and prepares a response using The service() method determines the type of request (GET, POST, etc.) and delegates it to
HttpServletResponse. corresponding methods like doGet(), doPost(), etc.
Generate Response: The servlet writes the response (e.g., HTML, JSON) to the client. Destruction (destroy() method):Called once when the servlet is being removed from service.
Complete Request: The response is sent back to the client, and the thread is returned to the pool. Used for resource cleanup (e.g., closing database connections).
Q7: What is cookie and how it can be created? Q8: What are the four types of JDBC driver?
A cookie is a small piece of data stored on the client’s browser by a web server to track user Ans:Type 1: JDBC-ODBC Bridge Driver: Description: Converts JDBC calls into ODBC calls using an
activity, preferences, or session information.Key Points about Cookies: ODBC driver.
Purpose: Used for session management, personalization, and tracking user behavior. Pros: Simple and easy to use for basic applications.
Storage: Stored as key-value pairs in the user's browser. Cons:Dependent on the ODBC driver, which requires native installation. Platform-dependent
Types:Session Cookies: Deleted when the browser is closed. Usage: Rarely used due to limitations and better alternatives.
Persistent Cookies: Stored for a specified duration, even after the browser is closed. Type 2: Native-API Driver: Description: Converts JDBC calls into native database-specific calls
o clear a cookie in a servlet, set its max age to 0 and resend it to the client. This instructs the using database client libraries.
browser to delete the cookie.Steps to Clear a Cookie: Pros:Better performance than Type 1 as it uses native libraries.
Retrieve the Cookie: Cons:Requires database-specific client software.and Platform-dependent.
Cookie[] cookies = Usage: Used in older systems but not ideal for modern applications.
request.getCookies(); for (Cookie Type 3: Network Protocol Driver (Middleware Driver) : Description: Translates JDBC calls into a
cookie : cookies) { network protocol, then communicates with a middleware server that interacts with the
if ("username".equals(cookie.getName())) { database. Pros:Platform-independent. And No need for database-specific client software.
// Modify the cookie to clear it Cons:Requires a middleware server, adding complexity.
cookie.setValue(""); Usage: Suitable for internet-based and distributed systems.
cookie.setMaxAge(0); // Set max age to 0 Type 4: Thin Driver (Pure Java Driver):Description: Converts JDBC calls directly into the
response.addCookie(cookie); // Send back to client database's native protocol using a 100% Java implementation.
} Pros:Platform-independent and lightweight. And No additional software required on the client
} Cons: May depend on database-specific details.
Effect:The brower deletes the cookie immediately. Usage: Most widely used driver type in modern applications.
Q9: Explain the various components of JSP in details Q10: What is HTTPS? How HTTPS is different from HTTP.
Ans: Directives: Instructions for the JSP engine.
Page: Defines page attributes (e.g., language, buffer).
Include: Includes static files (<%@ include file="header.jsp" %>).
Taglib: Declares custom tags.
Scriptlets: Java code embedded in JSP (<% int x = 10; %>).
Expressions: Outputs data directly (<%= "Hello, " + name %>).
Declarations: Declares variables or methods (<%! int counter = 0; %>).
Standard Actions: Predefined tags for common tasks.
Include: <jsp:include page="header.jsp" />
Forward: <jsp:forward page="login.jsp" />
UseBean: <jsp:useBean id="user" class="com.example.User" />
Implicit Objects: Predefined objects like request, response, session, etc.
Custom Tags: User-defined tags (e.g., JSTL). HTTPS ensures secure, encrypted communication, while HTTP transmits data in plain text,
Comments: Hidden from client output (<%-- comment --%>). making it vulnerable to interception and tampering.
Q11: What is XML? Q12: What are the features of a Java servlets?
Ans: XML (eXtensible Markup Language) is a markup language designed to store and transport Ans: Platform-Independent: Servlets are written in Java, making them platform-independent
data. and can run on any operating system with a compatible servlet container (e.g., Tomcat).
Structure: Uses a tree-like structure with tags to define elements (e.g., <name>John</name>). Efficient and Scalable: Servlets can handle multiple requests concurrently and are designed
Human-readable: Text-based format, easy to read and understand. to be efficient in handling large volumes of requests.
Self-descriptive: Data is enclosed within tags that describe the content. Request-Response Model: Servlets use the client-server model, handling requests (e.g., GET,
Platform-independent: Can be used across different platforms and applications. POST) and generating appropriate responses (e.g., HTML, JSON).
Extensible: Users can define custom tags and structures. Supports Session Management: Servlets can maintain user sessions using cookies, session
Used for: Data interchange between systems, configuration files, and web services (e.g., SOAP). tracking, or URL rewriting.
Security: Supports authentication and authorization, ensuring secure communication between
clients and servers.
Q13: Define HTML DOM? Q14: What is Form? Explain method and action attribute of a Form.
ANS: The HTML DOM (Document Object Model) is an interface that represents an HTML Ans: A form in HTML is used to collect user input and send it to a server for processing. It is
document as a tree of objects, allowing manipulation of content and structure through defined using the <form> tag.
programming languages like JavaScript. Method Attribute:Specifies how to send form data to the server.
Key Points:Tree Structure: HTML elements are represented as nodes in a tree. Common Methods: GET: Appends form data to the URL (suitable for non-sensitive data).
Dynamic Interaction: Allows changing content and styles dynamically. POST: Sends form data in the request body (suitable for sensitive or large data).
Cross-language: Accessible by JavaScript, Python, etc. Action Attribute:Specifies the URL where the form data should be sent for processing.
Event Handling: Supports user events (click, keypress). Example:
Standardized: Defined by W3C for browser <form method="POST" action="submitForm.php">
compatibility. Example:<p id="demo">Hello!</p> <!-- form elements go here -->
<script> </form>
document.getElementById("demo").innerHTML = "Hello, DOM!";
</script>
Q15: What do you understand by hyperlink in HTML? Write mark-up for an image hyperlink. Q16: Explain Java Applets. What are the applications of Applets.
Ans: A hyperlink in HTML is used to link one page or resource to another. It is defined using the Ans: A Java applet is a small Java program that runs in a web browser using the Java plugin.
<a> tag, which can link to websites, documents, or other resources. Applets can provide interactive content like games, animations, or multimedia.
<a href="https://www.example.com"> Key Points:Execution: Runs in a browser or applet viewer, requiring Java plugin.
<img src="image.jpg" alt="Example Image"> Platform-Independent: Like other Java programs, applets are platform-independent.
</a> Security: Limited by sandboxing for security, restricting access to the local system.
href: Specifies the URL the link points to. GUI: Can create interactive graphical user interfaces (GUIs) using AWT or Swing.
src: Specifies the image source. Applications of Applets:Interactive Web Applications: For animations, games, or calculators.
alt: Provides alternate text if the image is not displayed. Educational Tools: For simulations or interactive lessons.
Data Visualization: Displaying charts and graphs.
Form Validation: Enhancing form behavior with dynamic responses.
Q17: What are Java Server Pages? Explain life cycle of a JSP page? Q18: What are JSP directives? Explain various types of directives with example?
Ans: JSP is a technology used for creating dynamic web pages by embedding Java code in HTML. It Ans: JSP directives provide instructions to the JSP engine on how to process a page. They affect
allows Java code to be executed on the server, and the resulting output is sent to the client's the overall structure of the generated servlet.Types of JSP Directives:
browser. Page Directive:
Life Cycle of a JSP Page: Purpose: Defines page-level attributes such as content type, language, error pages, etc.
Translation Phase: The JSP page is converted into a servlet by the container. Syntax:<%@ page language="java" contentType="text/html" %>
Compilation Phase: The generated servlet is compiled into bytecode. Include Directive:
Instantiation: The servlet container creates an instance of the compiled servlet (JSP). Purpose: Includes a static file (e.g., HTML or JSP file) at the time of page translation.
Initialization (jspInit()): Called once when the JSP is loaded, for initialization. Syntax:<%@ include file="header.jsp" %>
Request Processing (_jspService()): Handles each client request. It generates the response Taglib Directive:
dynamically. Purpose: Declares custom tag libraries that provide additional functionality (e.g., JSTL).
Destruction (jspDestroy()): Called when the JSP is unloaded, for cleanup. Syntax:<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

Q19: What is PHP? Describe session in detail? Explain the steps involved in connect PHP page to Q20.Describe HTML text formatting tags.
MYSQL database? Ans. HTML provides a variety of tags to format text content. Here's a summary of commonly used
Ans: PHP (Hypertext Preprocessor): HTML text formatting tags and their purposes:
PHP is a server-side scripting language designed for web development, but it can also be used Basic Text Formatting
for general-purpose programming. It is widely used to create dynamic web pages and interact 1. <b>: Makes text bold.
with databases.Session in PHP: Example: <b>This is bold text</b> → This is bold text
A session is used to store user data across multiple pages. Unlike cookies, sessions store data on 2. <strong>: Indicates strong importance (usually bold).
the server, making it more secure. Example: <strong>Important text</strong> → Important text
Starting a Session: Use session_start() to begin a session. 3. <i>: Italicizes text for styling.
Storing Data: Use $_SESSION array to store session variables. Example: <i>This is italic</i> → This is italic
$_SESSION['username'] = 'JohnDoe'; 4. <em>: Emphasizes text (usually italic).
Accessing Data: Access session data using $_SESSION['key']. Example: <em>Emphasized text</em> → Emphasized text
Ending a Session: Use session_destroy() to destroy all session data. 5. <u>: Underlines text.
Steps to Connect PHP to MySQL Database: Example: <u>Underlined text</u> → <u>Underlined text</u>
Establish Connection: Use mysqli_connect() to connect to the MySQL database. 6. <mark>: Highlights text.
$conn = mysqli_connect("localhost", "username", "password", "database_name"); Example: <mark>Highlighted text</mark> → Highlighted text
Check Connection: Verify if the connection is successful. 7. <small>: Reduces font size.
if (!$conn) { Example: <small>Smaller text</small> → Smaller text
die("Connection failed: " . mysqli_connect_error()); 8. <del>: Strikethrough to indicate deleted text.
} Example: <del>Deleted text</del> → Deleted text
Execute Queries: Use mysqli_query() to execute SQL queries. 9. <ins>: Underlines to indicate inserted text.
$result = mysqli_query($conn, "SELECT * FROM table_name"); Example: <ins>Inserted text</ins> → Inserted text
Close Connection: Close the connection when done. 10. <sub>: Subscript text (lowered). Example: H<sub>2</sub>O → H₂O
mysqli_close($conn); 11. <sup>: Superscript text (raised). Example: E = mc<sup>2</sup> → E = mc²

Q21.Explain about the different types of style sheets and their advantages.
Ans.CSS, or Cascading Style Sheets, is a stylesheet language used to control the appearance and layout of HTML
documents. It allows developers to separate content (HTML) from presentation (CSS), making web pages more
flexible, maintainable, and visually appealing.

You might also like