Monday, 20 February 2012
Do you like this Article?
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 the server. Servlet 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 deals with the contracts between a servlet class and the runtime 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 Filter, RequestDispatcher, ServletRequest, ServletResponse, etc. and classes like ServletInputStream, ServletOutputStream, etc are also belong of this package. It also contains 2 exceptions, and they are ServletException and UnavailableException.
- 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 HttpSession, HttpServletResponse, HttpServletRequest, HttpSessionBindingListener, etc and classes like Cookie, HttpServlet (which implements Interface Servlet of javax.servlet package), etc.
Uses of Servlet API:
- Management of Servlet life cycle.
- It provides access to servlet context.
- It also provides some utility classes.
- And last but not least, it also provides classes to handle HTTP protocol.