281. What is connection pooling?- With servlets, opening a database connection
is a major bottleneck because we are creating and tearing down a new connection for
every page request and the time taken to create connection will be more. Creating a
connection pool is an ideal approach for a complicated servlet. With a connection
pool, we can duplicate only the resources we need to duplicate rather than the
entire servlet. A connection pool can also intelligently manage the size of the
pool and make sure each connection remains valid. A number of connection pool
packages are currently available. Some like DbConnectionBroker are freely available
from Java Exchange Works by creating an object that dispenses connections and
connection Ids on request. The ConnectionPool class maintains a Hastable, using
Connection objects as keys and Boolean values as stored values. The Boolean value
indicates whether a connection is in use or not. A program calls getConnection()
method of the ConnectionPool for getting Connection object it can use; it calls
returnConnection() to give the connection back to the pool.
282. Why should we go for interservlet communication?- Servlets running together
in the same server communicate with each other in several ways. The three major
reasons to use interservlet communication are: a) Direct servlet manipulation -
allows to gain access to the other currently loaded servlets and perform certain
tasks (through the ServletContext object) b) Servlet reuse - allows the servlet to
reuse the public methods of another servlet. c) Servlet collaboration - requires to
communicate with each other by sharing specific information (through method
invocation)
283. Is it possible to call servlet with parameters in the URL?- Yes. You can
call a servlet with parameters in the syntax as (?Param1 = xxx || m2 = yyy).
284. What is Servlet chaining?- Servlet chaining is a technique in which two or
more servlets can cooperate in servicing a single request. In servlet chaining, one
servlet’s output is piped to the next servlet’s input. This process continues until
the last servlet is reached. Its output is then sent back to the client.
285. How do servlets handle multiple simultaneous requests?- The server has
multiple threads that are available to handle requests. When a request comes in, it
is assigned to a thread, which calls a service method (for example: doGet(),
doPost() and service()) of the servlet. For this reason, a single servlet object
can have its service methods called by many threads at once.
Saturday, May 10, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment