Revise Servlets in 10 mins

Revising Servlets in 10 mins, useful only if you have already read on servlets and just need to some guide points to recollect.
  1. Servlet is used to create dynamic web applications. Resides at server side.
  2. Implement Servlet interface to make a Servlet. Or you can extend the HTTPServlet class.
  3. Capable to serving and responding to requests.
  4. Better performance (creates new thread for each request), robust, secure and portable(since in java)
  5. Uses the HTTP Protocol to transfer data between the web server and the web browser. Stateless by default.
  6. HTTP Request methods:
    1. GET
    2. POST
    3. HEAD
    4. PUT
    5. DELETE
    6. OPTIONS
    7. TRACE
  7. Container provides runtime environment for j2ee applications
    1. Life cycle management
    2. Multithreading support
    3. object pooling
    4. Security
  8. Content Types: text/html, text/plain, images/jpeg etc
  9. Server types: Web server and application server
  10. Servlet Life Cycle:
    1. Servlet class is loaded
    2. Servlet instance is created
    3.  init method is invoked
    4. service method is invoked, every time a request for the servlet is received
    5. destroy method is invoked
  11. ServletRequest: provides client request information like the parameter names and values, header information etc.
  12. RequestDispatcher
    1. forward: forwards the request from the servlet to another servlet, jsp, or html file.
    2. include: includes and displays the content of the requesting servlet and the responding servlet.
  13. sendRedirect - send request to another web server, ie you can redirect to any other web page or web site.
  14. ServletConfig and ServletContext:
    1. Each servlet can have its initialization parameters which can be specified in the web.xml (init-param)
    2. ServletContext is created by the web context at the start of the deployment. Information which needs to be shared across all the servlets can be put in ServletContext in web.xml (context-param)
  15.  Scopes of Servlet Attributes:
    1. request
    2. session
    3. application

Comments

Popular posts from this blog

Writing your own ejabberd Module

npm ECONNREFUSED error

Conditional Flow - Spring Batch Part 6