Servlets

7x puncte

categorie: Informatica

nota: 10.00

nivel: Facultate

One of the most common tasks that init performs is reading server-specific initialization parameters. For example, the servlet might need to know about database settings, password files, server-specific performance parameters, or hit count files.
To read initialization parameters, first a ServletConfig object must be obtained through the getServletConfig method, and then the getInitParamet[...]
DOWNLOAD REFERAT

Preview referat: Servlets

One of the most common tasks that init performs is reading server-specific initialization parameters. For example, the servlet might need to know about database settings, password files, server-specific performance parameters, or hit count files.
To read initialization parameters, first a ServletConfig object must be obtained through the getServletConfig method, and then the getInitParameter method must be called on the result. Here is an example:

In the code above, the init method uses the getServletConfig() method to obtain a reference to the ServletConfig object; ServletConfig has a getInitParameter() method with which it is possible to look up initialization parameters associated with the servlet. Both the input (the parameter name) and the output (the parameter value) are strings.
Initialization parameters are read by calling the getInitParameter() method of the ServletConfig object and they are set through the web.xml file. This file belongs in the WEB-INF directory of the Web application and controls many aspects of servlet and JSP behavior.

web.xml contains an XML header, a DOCTYPE declaration, and a web-app element. For the purpose of initialization parameters, the web-app element should contain a servlet element with three subelements: servlet-name, servlet-class, and init-param. The servlet-name element is the name that will be used to access the servlet. The servlet-class element gives the fully qualified (including packages) class name of the servlet, and init-param gives names and values to initialization parameters.

The server may decide to remove a previously loaded servlet instance, perhaps because it is explicitly asked to do so by the server administrator, or perhaps because the servlet is idle for a long time. Before it does, however, it calls the servlet's destroy method. This method gives the servlet a chance to close database connections, halt background threads, and perform other such cleanup activities. Hhowever, it is possible for the Web server to crash so, it is not a good programming technique to rely on destroy as the only mechanism for saving state to disk. Activities like hit counting that indicate special access should also proactively write their state to disk periodically.
DOWNLOAD REFERAT
« mai multe referate din Informatica

CAUTA REFERAT


TRIMITE REFERAT CERE REFERAT
Referatele si lucrarile oferite de E-referate.ro au scop educativ si orientativ pentru cercetare academica.