Java Servlets Question and Answers

41. 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
42. How are Servlets developed?
  Developing Servlets is a three step process
Write the Servlet:
  • import javax.servlet.*;
  • public class extends GenericServlet
  • over-ride service() method and give the business logic, if any
  • print the message/results to the client.
Install the Servlet:
  • The source file generated as above should be compiled with JDK 1.1 or later version and the resulting .class file (say MyServlet.class) should be put (copied) in the directory, C :\JavaServer 1.0\ servlets
  • Start and run the local host, i.e. C: \JavaServer1.0\bin\httpd, which runs on port no. 8080
Run the Servlet:
  • Start the browser. Type the following as the URL address. http://localhost:8080/servlet/MyServlet
 
Your Name Your Email-ID
Your Answer
43. What is a properties file in Servlets?
  It is a text file to register Servlet properties. This file defines two properties for a Servlet
  • servlet.name.code that enables you to associate a name with the class that contains the code for the Servlet.
  • servelt.name.initargs that enables you to define a sequence of comma delimited parameter names and values.
    For both properties, name is a string by which this Servlet is to be known. The default locations for this file are:
  • C:\JavaServer1.0\properties\server\javawebserver\webpageservice directory
  • C:\jsdk2.0\examples directory, if serveletrunner utility is used.
 
Your Name Your Email-ID
Your Answer
1234567891011 Page 11 of 11