Overview of Java servlets

Servlets are protocol and platform independent server-side software components,written in Java. They run inside a Java enabled server or ap...

Servlets are protocol and platform independent server-side software components,written in Java. They run inside a Java enabled server or application server. Servlets are loaded and executed within the Java Virtual Machine (JVM) of the Web server or application server, in much the same way that applets are loaded and executed within the JVM of the Web client. Since servlets run inside the servers, however, they do not need a graphical user interface (GUI). In this sense, servlets are also faceless objects. Servlets more closely resemble Common Gateway Interface (CGI) scripts or programs than applets in terms of functionality. As in CGI programs, servlets can respond to user events from an HTML request, and then dynamically construct an HTML response that is sent back to the client. Servlet process flow Servlets implement a common request/response paradigm for the handling of the messaging between the client and the server. The Java Servlet API defines a standard interface for the handling of these request and response messages between the client and server.

  • The client sends a request to the server.
  • The server sends the request information to the servlet.
  • The servlet builds a response and passes it to the server. That response is dynamically built, and the content of the response usually depends on the client’s request. External resources may also be used.
  • The server sends the response back to the client.
Figure given below shows a high-level client-to-servlet process flow:

Servlets are powerful tools for implementing complex business application logic. Written in Java, servlets have access to the full set of Java API’s, such as JDBC for accessing enterprise databases. As mentioned above, servlets are similar to CGI in that they can produce dynamic Web content.

Servlets, however, have the following advantages over traditional CGI programs:

❑  Portability and platform independence: Servlets are written in Java, making them portable across platforms and across different Web servers, because the Java Servlet API defines a standard interface between a servlet and a Web server.

❑  Persistence and performance: A servlet is loaded once by a Web server, and invoked for each client request. This means that the servlet can maintain system resources, like a database connection, between requests. Servlets don’t incur the overhead of instantiating a new servlet with each request. CGI processes typically must be loaded with each invocation.

❑  Java based: Because servlets are written in Java, they inherit all the benefits of the Java language, including a strong typed system, object-orientation, and modularity, to name a few.

Best Online Tutorials | Source codes | Programming Languages: Overview of Java servlets
Overview of Java servlets
Best Online Tutorials | Source codes | Programming Languages
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content