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.

    宛如智障,暗藏锋芒
  • 相关阅读:
    C++ 多线程
    C++ 信号处理
    首页流量监控代码
    macro-name replacement-text 宏 调试开关可以使用一个宏来实现 do { } while(0)
    color depth 色彩深度 像素深度
    数据更新 数据同步 起始点 幂等同步历史数据
    获取当前调用函数名 方法名
    版本号风格为 Major.Minor.Patch
    query_string查询支持全部的Apache Lucene查询语法 低频词划分依据 模糊查询 Disjunction Max
    Cutoff frequency
  • 原文地址:https://www.cnblogs.com/zienzir/p/9000849.html
Copyright © 2011-2022 走看看