![]() |
VOOZH | about |
Servlets are the Java programs that run on the Java-enabled web server or application server. They are used to handle the request obtained from the webserver, process the request, produce the response, then send a response back to the webserver.
A package in servlets contains numerous classes and interfaces
Remember: In order to create servlet in packages, use command ''
There are two types of packages in Java Servlet that are providing various functioning features to servlet Applications. The two packages are as follows:
Type 1: javax.servlet package: This package of Servlet contains many servlet interfaces and classes which are capacity of handling any types of protocol sAnd This javax.servlet package containing large interfaces and classes that are invoked by the servlet or web server container as they are not specified with any protocol.
Type 2: javax.servlet.http package: This package of servlet contains more interfaces and classes which are capable of handling any specified http types of protocols on the servlet. This javax.servlet.http package containing many interfaces and classes that are used for http requests only for servlet
The Classes are in javax.servlet package are listed below:
Servlet: This interface describes and connects all the methods that a Servlet must implement. It includes many methods to initialize the destroy of the Servlet, and a general (service()) method which is handling all the requests are made to it. This Servlet interface is used to creating this servlet class as this class having featuring to implementing these interfaces either directly or indirectly to within it on to fetching servlets
ServletRequest: This ServletRequest interface in which examining the methods for all objects as encapsulating data information about its all requests i.e. made to the servers, this object of the ServletRequest interface is used to retrieve the information data from the user
ServletResponse: An interface examining the methods for all objects which are returning their allowed responses from the servers and object of this current interfacing objects is used to estimate the response to the end-user on the system
ServletConfig: declaring this interface ServletConfig useful to gaining accessing the configuration of its main parameters which are passing through the Servlets during the phase time of initialization and this ServletConfig object is used for providing the information data to the servlet classes external to explicitly.
ServletContext: The object of the ServletContext interface is very helpful to featuring the info. data to the web applications are explaining to it for servlets
GenericServlet: This is a generic classes examination to implement the Servlet. if you want to write the Servlet's protocols other than the HTTP, then the easy way of doing this is to extend GenericServlet rather than by directly implementing the Servlet interfaces
ServletException: it is an exception that can be thrown when the Servlet invoking a problem of some examples
ServletInputStream: This class ServletInputStream is used to reading the binary data from end user request
ServletContextEvent: in this any changes are made in the servlet context of its web application, this class notifies it to the end-user.
ServletOutputStream: This class ServletOutputStream is useful to send the transferring binary data to the end-user side of the system
Interfaces: The javax.servlet.http packages have provides these feature classes that are unique to handling these HTTP requests allowing from it. It provides the HttpServlet classes that is usable as it accesses the selectively interfaces from javax.servlet class.
HttpServlet: in this HttpServlet purely abstracted class having features as functionality to extending and applying on the HTTP requests. They have like Service() method that is declared in the Servlet interfaces will now call its methods similar to doGet() and the doPost(), which are enabled to providing behavior to the Calling Servlet
Cookie: This Class provides the feature Servlet an interface for the storage of small portions of data information on the end-user computer or system.
HttpServletRequestWrapper and HttpServletResponseWrapper: this two wrapper classes allowing capability of the HttpServletResponse and HttpServletRequest interfaces to the servlet by its functions
HttpSessionEvent: This class HttpSessionEvent notified as any activity or changes/editing are encountered in the session of web applications in servlet
HttpSessionBindingEvent: This class notified when any attribute is bounded, unbounded or replaced in any Current session
Implementation: Example on servlet by implements Servlet Interface is as follows:
we created a submit button as - Submit
we checking that the URL name should be match with an HTML form that is/go use in the code
Output: Following have the page when user clicking on the button to