Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Java

Submission + - Servlet Life Cycle (blogspot.com)

anij_java writes: "

Life cycle of a servlet starts when its first load in the memory space in web server and ends when unloaded from the server memory. we can divide this in 3 steps.

STEP 1: INITIALIZATION:

  • Server loads the servlet class.
  • Creates an instance for the servlet class.
  • Server initializes the instance by calling init() method.

STEP 2: SERVICE:

  • Server creates a request & a respond object based on the client's request.
  • Invokes the service() method of the servlet, passing the request respond object.
  • service() method process the request and use the respond object to create the client respond.
  • service() method can invoke can also invoke other methods like doGet(), doPost(), doDelete(), doOptions(), doPut() and doTrace().

STEP 3: DESTROY:

  • Server calls the destroy() method to relinquish any resources such as file handles that are allocated to that servlet. destroy() method is invoked once in a servlet's life time.
  • Then the server unload the servlet and its objects, and it's memory can be garbage collected.

*Unavailable exception thrown *Initialization failed

"

The Internet

Submission + - HTTP vs. HTTPS (blogspot.com)

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."

Submission + - Web Container vs Web Server vs Application Server (blogspot.com)

anij_java writes: "

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 invoking Servlets and JSP pages. So,basically it controls the whole life cycle of servlet and JSP.
  • It is a part of the web server.
  • Example: Apache Tomcat.

Web Server / HTTP Server :

  • It is a server which is capable of handling HTTP request send by a client and respond back with a HTTP respond .
  • Example: Apache Web Server.

Application Server / App Server :

  • It can handle all application operations between users and an organization's back end business applications or databases.
  • It's for complex transaction-based application.
  • It is frequently viewed as part of a three-tier application, where top-most tier is Presentation tier(GUI layer), then the Logic tier(an Application Server) and Data tier(consist of database server).
  • Example: IBM — WebSphere Application Server.
"

Java

Submission + - J2EE: SERVLET: What is Servlet Interface? (blogspot.in)

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."

Java

Submission + - J2EE: SERVLET: Class GenericServlet vs Class HttpServlet (blogspot.in)

anij_java writes: "Class GenericServlet :

                                        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.)."

Slashdot Top Deals

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...