JavaWeb002-servlet基础

1)什么是servlet?(看文档)

Servlet is a small promgram that runs within a web server. Servlet receives and respond to requests from web clients, usually across HTTP, the HyperText Transfer Protpcol.

 

1)Servlet的生命周期过程是什么?

constructor –>init –>service –>destroy

servlet周期 

 

3)Servlet除servie等方法之外, 还有那些附加的方法?

In addition to the life-cycle-methods, this interface also provides the getServletconfig() method, which the servlet can use to get any startup information, and the getServletInfo(), which allows the servlet to return bisc information about itself, such as author, version, and copyright.

 

4)什么是servletConfig?

A servletconfig object used by servlet container to pass information to a servlet during initialization

*需要事先在web.xml中配置.(配置在对象的servlet元素中)

init-param配置

*获取, config.getInitParamter(“school”);

 

5)为什么要使用GenericServlet?

为了多次利用, 此处也不太懂, 因为还没有学习

 

6)为什么要使用HttpServlet?

我们用的最多的通信协议就是http协议, httpservlet便于处理http协议通信.

httpServlet参数与方法概览

 

7)tomcat启动加载

*什么是启动加载? 

*就是当tomcat移动的时候, 就调用某个servlet的inti方法, 开始初始化servlet.

*为什么要启动加载?

*比如一个servlet用于连接数据库, 而这个数据库连接需要花费一个小时, 那么我们可以在tomcat启动后就开始连接, 为用户节约时间.

*怎么启动加载?

*在web.xml中的对应servlet配置.

load-start-up

posted @ 2016-04-01 09:32  anoper  阅读(265)  评论(0编辑  收藏  举报