Java Servlets Question and Answers

37. What is CGI?
  • The Common Gateway Interface (known as CGI) is a program used to process the information on a client’s request. The process would open connections to one or more databases in order to obtain the necessary information.
  • CGI allows separate process to read data from the HTTP request and write data to the HTTP response. A variety of different languages are used to build CGI programs/CGI scripts, including C, C++, VB, Java, Perl, Tcl, etc.
  • Usually, CGI programs must be in a special directory on the web server, often called cgi-bin. Compiled C or C++ programs, Perl scripts, and shell scripts belong to the cgi-bin directory.
Your Name Your Email-ID
Your Answer
38. What is HttpServlet?
  The HttpServlet is a class which extends GenericServlet. It is commonly used when developing Servlets that receive and process HTTP requests.
Your Name Your Email-ID
Your Answer
39. What is Servlet Runner?
  • The Servlet Runner is a small utility, intended for testing. It is multi-threaded, and it can run more than one Servlet. It can be used, therefore, to run multiple Servlets simultaneously, or to test one Servlet that calls other Servlets in order to satisfy client request.
  • Unlike some web servers, it does not automatically reload Servlets when they are updated.
  • It assumes that servletrunner is running on the machine, localhost, at port 8080, and that they MyServlet program is located in the Servlet directory provided to Servlet Runner to startup.
Your Name Your Email-ID
Your Answer
40. What is session tracking?
  • HTTP is a stateless protocol, which means that each request is independent of the previous one.
  • However, in some applications, it is necessary to save the state information, so that the information can be collected from several interactions between a browser and a server. Sessions provide such a mechanism.
  • A session can be created via the getSession() method of HttpServletRequest interface.
  • An HttpSession object is returned. This object can store a set of bindings that associate names with objects.
  • The putValue(), getValue(), getvalueNames(), and removeValue() methods of HttpSession manage these bindings.
  • It is important to note that session state is shared among all the Servlets that are associated with a particular client. This is called Session Tracking.
Your Name Your Email-ID
Your Answer
1234567891011 Page 10 of 11