Servlet之详解

曾经我们在学校里糊里糊涂的听老师说Tomcat是一个Servlet容器。

那么为什么你真正了解过么?

首先我们要明确几个概念性的问题。

J2EE--Java 2 Platform, Enterprise Edition(是一个为大企业主机级的计算类型而设计的Java平台)

J2EE的13种技术规范之一:servlet

Servlet

  servlet是用java编写的服务器端程序,主要功能在于交互式地浏览和修改数据,生成动态Web内容。狭义的Servlet是指Java语言实现的一个接口,广义的Servlet是指任何实现了这个Servlet接口的类,一般情况下,人们将Servlet理解为后者。

容    器

  java是面向对象的,那么容器就是一个特别的大的对象,一般这个容器里有一个Map类型属性,而这个Map来存放其他小对象,容器通过操纵Map来实现创建,管理,销毁等其他对象的生命周期。

  那么Servlet容器顾名思义就是来存放Servlet对象的容器。

Servlet『侠义』

    接口

Servlet『广义』

      实现类

 继承结构

  

 1 public interface Servlet {
 2 
 3     /**
 4      * Called by the servlet container to indicate to a servlet that the
 5      * servlet is being placed into service.
 6      * @param config  ServletConfig object containing the servlet's
 7      *     configuration and initialization parameters
 8      */
 9     public void init(ServletConfig config) throws ServletException;
10     
11     /**
12      *
13      * Returns a {@link ServletConfig} object, which contains that 
14      * initializes this servlet
15      */
16     public ServletConfig getServletConfig();
17     
18     /**
19      * Called by the servlet container to allow the servlet to respond to 
20      * a request.
21      */
22     public void service(ServletRequest req, ServletResponse res)
23     throws ServletException, IOException;
24 
25     /**
26      * Returns information about the servlet, such
27      * as author, version, and copyright.
28      * @return String containing servlet information
29      */
30     public String getServletInfo();
31     
32     /**
33      * Called by the servlet container to indicate to a servlet that the
34      * servlet is being taken out of service.
35      */
36     public void destroy();
37 }    
Servlet

  

猜你喜欢

转载自www.cnblogs.com/saber-himesama/p/9026616.html