Saturday, April 28, 2012

SERVLET API

Java Servlet API is that Application Program Interface (API), which defines and describes the contracts between servlets and servers. That means, it contains the set of programs and standard instructions to develop a proper access between a servlet and theserverServlet API is a part of the official J2EE API. This API contains 2 packages with the extension javax. They are as follows.

·        Package javax.servlet
·        Package javax.servlet.http

Package javax.servlet:

  • Package javax.servlet deals with the contracts between a servlet class and theruntime environment offered for an instance of the class, within the servlet container.

  • It contains a set of classes and interfaces. Some important classes and interfaces like, Class GenericServlet which implements Interface Servlet. Apart from that, interfaces like FilterRequestDispatcherServletRequestServletResponse, etc. and classes like ServletInputStreamServletOutputStream, etc are also belong of this package. It also contains 2 exceptions, and they areServletException and UnavailableException.

Package javax.servlet.http:

  • Package javax.servlet.http deals with the contracts between a servlet class, which is running under HTTP protocol and the runtime environment offered for an instance of the class, within the servlet container.

  • It also contains some important classes and interfaces. Some of them are, Interfaces like HttpSessionHttpServletResponseHttpServletRequest,HttpSessionBindingListener, etc and classes like CookieHttpServlet (which implements Interface Servlet of javax.servlet package), etc.

Uses of Servlet API:
  1. Management of Servlet life cycle.
  2. It provides access to servlet context.
  3. It also provides some utility classes.
  4. And last but not least, it also provides classes to handle HTTP protocol.

No comments:

Post a Comment