Servlet definition Servlets are modules of Java code that run in a server application (hence the name Servlets", similar to Applets"on the client side to answer client requests. It is based on servlet APl and extendthefunctionalityofahttpserver. Servlets are not tied to a specific client-server protocol but they are most commonly used with Http and the word servlet"is oftenusedinthemeaningofhttpservlet Mapped to URLs and managed by container with a simple architecture Available and running on all major web servers and app servers Platform and server independent
Servlet Definition ◼ Servlets are modules of Java code that run in a server application (hence the name "Servlets", similar to "Applets” on the client side) to answer client requests. It is based on servlet API and extend the functionality of a HTTP server. ◼ Servlets are not tied to a specific client-server protocol but they are most commonly used with HTTP and the word "Servlet" is often used in the meaning of "HTTP Servlet". ◼ Mapped to URLs and managed by container with a simple architecture ◼ Available and running on all major web servers and app servers ◼ Platform and server independent
Servlet sample code PublicclasshelloservletextendshttpServlet publicvoiddoGet(httpServletrequestrequest Http servletrEsponse response response. setContentType( text/html") PrintWriter out response getWriter0 out println ( <title>Hello World </title>)
Servlet Sample Code
CGI and servlet CGI (Common Gateway Interface) Written in cc++, visual Basic and perl A CGi program and probably also an extensive runtime system or interpreter) needs to be loaded and started for each CGI request
CGI and Servlet ◼ CGI (Common Gateway Interface) ◼ Written in C, C++, Visual Basic and Perl ◼ A CGI program (and probably also an extensive runtime system or interpreter) needs to be loaded and started for each CGI request
CGI and servlet Servlets written in java A Servlet does not run in a separate process. This removes the overhead of creating a new process for each request. There is only a single instance which answers all requests concurrently. this saves memory and allows a servlet to easily manage persistent data. A servlet can be run by a servlet engine in a restrictive Sandbox Gust like an applet runs in a Web browser's Sandbox which allows secure use of untrusted and potentially harmful Servlets
CGI and Servlet ◼ Servlets ◼ Written in Java. ◼ A Servlet does not run in a separate process. This removes the overhead of creating a new process for each request. ◼ There is only a single instance which answers all requests concurrently. This saves memory and allows a Servlet to easily manage persistent data. ◼ A Servlet can be run by a Servlet Engine in a restrictive Sandbox (just like an Applet runs in a Web Browser's Sandbox) which allows secure use of untrusted and potentially harmful Servlets
CGI and servlet Request cAll Child for CAll Request CG12 CGI Based Child for cg12 Webserver Request cgIl Child for CAll Request Servlet Servlet Based Webserver Request servlet Servlet Request Servlet Servlet
CGI and Servlet