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.

    宛如智障,暗藏锋芒
  • 相关阅读:
    调试 camera 时记录点滴
    奇偶场的合并&yuv2rgb
    拓宽视野
    Eclipse中看不到jsp的页面效果
    极品函数
    Visual C# 2005中让ComboBox控件显示出多个数据源属
    C#——如何使tableLayoutPanel 不闪烁
    ASP.NET中JSON的序列化和反序列化
    有钱慷慨的管理者,有钱吝啬的管理者,无钱思想慷慨的管理者,无钱思想吝啬的管理者都有各自的下场白
    C# WinForm开发系列 ComboBox
  • 原文地址:https://www.cnblogs.com/zienzir/p/9000849.html
Copyright © 2011-2022 走看看