anij_java writes: "HTTP stands for HyperText Transfer Protocol, whereas, HTTPS is HyperText Transfer Protocol Secure.
HTTP transmits everything as plan text, while HTTPS provides encrypted communication, so that only the recipient can decrypt and read the information. Basically, HTTPS is a combination of HTTP and SSL (Secure Sockets Layer). This SSL is that protocol which encrypts the data.
HTTP is fast and cheap, where HTTPS is slow and expensive.
As, HTTPS is safe it’s widely used during payment transactions or any sensitive transactions over the internet. On the other hand, HTTP is used most of the sites over the net, even this blogspot sites also use HTTP.
HTTP URLs starts with “http:// “ and use port 80 by default, while HTTPS URLs stars with “https:// “ and use port 443.
HTTP is unsafe from attacks like man-in-the-middle and eavesdropping, but HTTPS is secure from these sorts of attacks."
Web Container / Servlet Container / Servlet Engine:
In J2EE Architecture, a web container(also known as servlet container or servlet engine), is used to manage the components like servlets, JSP.
It provides a runtime environment to the components of J2EE.
When ever web server receive a request it forward it to web container which deals with it by instantiating, initializing and invokingServlets and JSP pages. So,basically it controls the whole life cycle of servlet and JSP.
Servlet is a server-side (runs within a Web server), Java Programming Language Class which interacts with clients via request-response programming model (example, HTTP Request-Response model).
It can respond to any type of request, but, generally, it is used to extend the application hosted by Web Server by providing dynamic web content.
It has build-in threading capability and provides a secure environment for programming.
Java Servlet API provides javax.servlet and javax.servlet.http packages offer necessary classes and interfaces for writing servlets. All Servlets must implement Interface Servlet, which contains the servlet life-cycle methods.
To implement a generic service we can extend Class GenericServlet, which defines a generic, protocol-independent servlet. And to write an HTTP servlet for use on the Web, we can extend Class HttpServlet, which provides methods, such as doGet() and doPost(), for handling HTTP-specific services." Link to Original Source
anij_java writes: "Interface javax.servlet.Servlet is that interface which defines the ServletLife Cycle methods. So, all servlets must implement this interface, either directly or by extending a class which implements this interface. Instead of directly implementing the Servlet Interface, a servlet can also extend Class GenericServlet (which implements Servlet Interface), or can extend HttpServlet Class (which extends the GenericServlet class).
Methods of Interface Servlet:
init(ServletConfig config) : Called by the Web Container to initialize a servlet. Here, config is a ServletConfig object containing the servlet's configuration and initialization parameters
service(ServletRequest req, ServletResponse res) : Called by the Web Container to allow a servlet to respond to a request. Here, req is the ServletRequest object that contains the client's request and res is the ServletResponse object that contains the servlet's response.
destroy() : Called by the Web Container to clean up a servlet’s service.
getServletConfig() : Return a ServletConfig object, which contain the initialization parameter and startup configuration of a servlet.
getServletInfo() : Returns a string containing the details of a servlet, like author, version and copyright."
It is an abstract class which defines a generic and protocol independent servlet. Here, protocol independent means, by default, it doesn’t contain inherent support for any particular type of protocol, but it can be extended to provide implementation of any protocol.
Class GenericServlet implements Interface Servlet and Interface ServletConfig and it belongs to javax.servlet package.
It offers simpler version of the servlet life cycle methods init() and destroy() and the methods of ServletConfig. That’s why, it makes writing a servlet easier.
Here, the method service(ServletRequest req, ServletResponse res) is abstract, so the subclasses must override it. And this is also the reason why the GenericServlet is an abstract class.
Class HttpServlet :
It is also an abstract class which defines HTTP prototype dependent servlet. That means we need to extend it to write a HTTP servlet for the use of the web.
Class HttpServlet is a subclass of Class GenericServlet and it belongs to javax.servlet.http package.
As it’s an abstract class, a subclass of it must override at least 1 method, generally one of these doGet(), doPost(), doPut(), doDelete(), init(), destroy(), getServletInfo().
Class HttpServlet has two service() methods — one is public void service(ServletRequest req, ServletResponse res) which dispatches client request to protected void service(ServletRequest req, ServletResponse resp) which again dispaches the request to the doXXX methods (like doGet(), doPost(), etc.)."