adv java
adv java
A servlet is a Java program that runs on a web server and handles client requests (like from a browser). It is used to generate
dynamic content such as HTML pages. Servlets are part of the Java EE (Jakarta EE) platform.
2. What is protocol?
A protocol is a set of rules that defines how data is transmitted between computers over a network. Common protocols
include HTTP (for web communication), FTP (for file transfer), and TCP/IP (for general internet communication). They ensure
that the sender and receiver understand each other.
3. What is socket?
A socket is a connection point between two computers to communicate over a network. In Java, sockets are used for client-
server communication. The server creates a ServerSocket, and the client connects using a Socket. Data is sent and received
using input/output streams. It supports both TCP and UDP protocols.
4. What is JSP?
JSP (JavaServer Pages) is a technology used to create dynamic web content. It allows embedding Java code in HTML pages
using special tags. JSP is compiled into a servlet internally. It's part of the Java EE platform and is ideal for designing
presentation layers of web applications. It simplifies the creation of user interfaces compared to servlets.
6. What is Hibernate?
Hibernate is a Java-based ORM (Object Relational Mapping) framework. It simplifies database interaction by mapping Java
classes to database tables. Instead of writing SQL queries manually, developers use Hibernate to perform CRUD operations. It
supports features like lazy loading, caching, and automatic table creation. It's widely used in enterprise applications.
8. What is JDBC?
JDBC (Java Database Connectivity) is an API that allows Java applications to interact with databases. It provides classes and
interfaces to connect, execute queries, and fetch results. JDBC supports all major databases like MySQL, Oracle, and
PostgreSQL. It's an essential part of Java for database-related programming.
9. What is ORM?
ORM (Object Relational Mapping) is a technique that connects Java objects to database tables. It helps developers work with
databases using Java code instead of SQL. Frameworks like Hibernate implement ORM. ORM handles data conversion
between Java and database formats, saving time and reducing errors.
import java.net.*;
public class IPAddress {
public static void main(String[] args) throws Exception {
InetAddress ip = InetAddress.getLocalHost();
System.out.println("IP Address: " + ip.getHostAddress());
}
}
32) HttpServlet
Abstract class in javax.servlet.http.
Designed for handling HTTP requests.
Methods like doGet(), doPost(), doPut(), doDelete() are used.