zoukankan      html  css  js  c++  java
  • 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.

    宛如智障,暗藏锋芒
  • 相关阅读:
    使用Spring的ReloadableResourceBundleMessageSource读取properties配置
    IFrame自适应高度
    Js返回页面顶部
    复制页面内容时添加额外信息
    怎样将Excel中的日期格式转换为文本格式
    为Tomcat页面设置访问权限(HTTP)
    为tomcat页面设置访问权限(BASIC认证)
    离线安装Maven FOR Eclipse插件
    sharepoint 获得上级和部门的封装函数
    SharePoint定制开发个性皮肤
  • 原文地址:https://www.cnblogs.com/zienzir/p/9000849.html
Copyright © 2011-2022 走看看