1.

What is the javax.servlet package?

Answer»

The core of the Servlet API is the javax.servlet package. It includes the basic Servlet interface, which all SERVLETS must implement in one form or another, and an abstract GenericServlet class for developing basic servlets.

This package comprises of the following:

  • Classes for communicating with the host server and client (ServletRequest and ServletResponse)
  • Communicating with the client (ServletInputStream and ServletOutputStream).

In SITUATIONS where the underlying protocol is unknown, servlets should confine themselves to the classes within this package. 

Conclusion:

Unlike CGI and FastCGI, which use many processes to handle separate programs and separate requests, servlets are all handled by separate threads within the webserver process. Thus, the servlets are efficient and scalable. As servlets run within the web server, they can interact very closely with the server to do things that are not possible with CGI scripts.

An advantage of servlets is that they are portable: both ACROSS operating systems like with Java and also across web servers.

All of the major web servers support servlets. 

References and Resources:

  • Java Servlet PROGRAMMING, by Jason Hunter, Published by O'Reilly Media, Inc.
  • Java Servlet & JSP Cookbook, by Bruce W. Perry
  • Java Interview
  • JSP Interview
  • JSP vs Servlet


Discussion

No Comment Found