Day 19

One: The difference between dynamic include and static include in JSP?

Dynamic include: <jsp:include page="included.jsp" flush="true" />
Static include: <%@ include file="included.htm" %>
1. Static import is to completely integrate the code of the imported page, and the two pages are integrated into a whole servlet; while dynamic import is to use the include method in the servlet to import the content of the imported page.
2. The compilation instruction of the imported page will work during static import; while the compilation instruction of the imported page will not work during dynamic import, only the body content of the imported page is inserted.

3. Dynamic inclusion can also add additional parameters.

Two: What is a database connection pool?

Database connections are a limited and expensive resource, and database connections affect program performance metrics. The database connection pool is proposed for this problem. The database connection pool is responsible for allocating, managing, and releasing database connections. It allows applications to reuse an existing database connection instead of re-establishing one; release database connections whose idle time exceeds the maximum idle time to avoid failure due to failure to release database connections. Caused by missing database connections. This technique can significantly improve the performance of database operations.

Three: The difference between HashMap and Hashtable?

1. Different histories of inheritance

public class Hashtable extends Dictionary implements Map
public class HashMap  extends AbstractMap implements Map

Hashtable is inherited from the Dictionary class, and HashMap is an implementation of the Map interface introduced in Java 1.2.

2. Different security
HashMap is non-synchronized, and its efficiency is higher than that of hashTable, while HashTable is synchronized by default, which means that HashTable is thread-safe, and multiple threads can share a HashTable; and if there is no correct synchronization , HashMap cannot be shared by multiple threads. ConcurrentHashMap is provided after Java 5, which is a replacement for HashTable and has better scalability than HashTable. Of course, we can synchronize the HashMap by:

Map m = Collections.synchronizeMap(hashMap);

3. Similarities and differences of nullable value
HashMap allows you to use null value as the key or value of a table entry. Only one record in a HashMap can be an empty key, but any number of entries can be an empty value. That is, if the search key is not found in the table, or if the search key is found but it is an empty value, then get() will return null; HashTable does not, neither key nor value allow null values .