• Servlet 小知识


    1.In servlet 3.0 we have new feature annotations to replace XML.也就是说应该尽量使用annotations
    2. Servlet is an API that provides many interfaces and classes to create web applications.

    APIs to create Servlets
    javax.servlet and javax,servlet.http are the two packages required to create servlets.

    3.What is javax?
    The javax prefix is used by the Java programming language for a package of standard Java extensions.
    These include extensions such as javax.servlet,which deals with running servlets,and javax.jcr,which deals with the java content library.

    The javax.servlet and javax.servlet.http packages provide interfaces and classes for writing servlets.
    All servlets must implement the Servlet interface,which defines lifecycle methods.
    When implementing a generic service ,you can use or extend the GenericServlet class provided with the Java Servlet ApI.
    The HttpServlet classes provides methods,such as doGet and doPost, for handling HTTP-specific services.

    1. 3 ways to create a servlet:
      -extending HttpoServlet Class
      -extending GenericServlet class
      -implementing Servlet interface.

    The mostly used approach is by extending HttpServlet because it provides http.request specific method such as doGety(),.doPost(),doHead() etc.

    Servlet Lifecycle

    The lifecycle of a servlet is controlled by the container in which the servlet has been deployed .
    When a request is mapped to a servlet, the container performs the following steps.
    1.If an instance of the servlet does not exist ,the web container
    a.Loads the servlet class .
    b.Creates an instance of the servlet class.
    The servlet instance is created only once int the servlet life cycle.
    c.Initializes the servlet instance by calling the init method.

    2.Invokes the service method passing request, and response objects.

    Web Pages are 2 types
    a,Static page-Page is already made and same for all users.
    b.Dynamic page-Page that loads at runtime and page changes as per the request from the user.

    Tomcat Server
    Tomcat is an HTTP server or web server and an HTTP container.
    HTTP stands for Hyper Text Transfer Protocol used to communicate between client and server.
    Tomcat converts JSP to servlets.

    宛如智障,暗藏锋芒
  • 相关阅读:
    MySQL数据库与表的增删改查
    JavaScript相关基础知识点
    用jquery制作一个二级导航下拉菜单
    jQuery如何获取元素及选择器的参考
    Trapping Rain Water
    First Missing Positive
    Combination Sum II
    Combination Sum
    vector的几小点
    C中字符结尾‘’的作用
  • 原文地址:https://www.cnblogs.com/zienzir/p/9000849.html
Copyright © 2020-2023  润新知