The API Java Servlet is an application Java which makes it possible to dynamically generate data within a Serveur HTTP. These data are most generally presented to the format HTML, but they also can the being with the format XML or any other format intended for the navigators Web.
This Java program is carried out dynamically on the Web server and allows the extension of the functions of this last, typically: access to databases, transactions of E-trade, etc a servlet can be automatically charged during starting with the Web server or at the time of the first request of the customer. Once charged, the servlets remain active in waiting of other requests of the customer.
The use of servlets is made by the means of a container of servlets (Framework) side waiter. This one constitutes the environment of execution of the servlet and allows him to persist between the requests of the customers. The API one defines the relations between the container and the servlet. The container receives the request of the customer, and selects the servlet which will have to treat it. The container also provides a whole whole of standard services to simplify the management of the requests and sessions
One or more servlets constitutes the Web applications Java, their principle of operation (architecture, functionalities, configuration, deployment) is described according to an official specification, carried out by Sun Microsystems and to which any person can contribute by the means of the Java Specification Requests (Java Community Process). The current version of the specifications servlet is the 2.5 .
There exists several Conteneurs of servlets, of which Apache Tomcat or Jetty. The waiter of application JBoss Application Server uses Apache Tomcat.
importation javax.servlet.*; importation java.io.*; public class HelloServlet extends GenericServlet { public void service (ServletRequest request, ServletResponse response) { try { PrintWriter out = response.getWriter (); out.println (" "); out.println ("
"); out.println ("Bonjour the world! "); out.println (" "); out.println (" "); out.println (" Hello world! "); out.println (" "); out.println (" "); } wrestling (IOException E) { e.printStackTrace (); } } }
Exit generated after deployment:
Bonjour the world! Hello world!
| Random links: | List publications by editors - Sun Productions - O | Arthur Oldham | Preston Lacy | Christine de Rivoyre | Park of Balagny-Saint-Épin |