A Simple Servlet Container
来源:互联网 发布:itoa函数在linux 编辑:程序博客网 时间:2024/06/11 07:25
I will develop my own servlet container by presenting two applications.
The first application has been designed to be as simple as possible to make it easy for you to understand how a servlet container works.It then evolves into the second servlet container,which is slightly more complex.
Application 1
Now, let’s examine servlet programming from a servlet container’s perspective. In a nutshell, a fully-functional servlet container does the following for each HTTP request for a servlet:
When the servlet is called for the first time, load the servlet calss and call the servlet’s init method(only once)
For each request ,construct an instance of javax.servlet.ServletRequest and an instance of javax.servlet.ServletResponse.
Invoke the servlet’s service method, passing the ServletRequest and ServletResponse objects.
When the servlet class is shut down, call the servlet’s destory method and unload the servlet class.
The first servlet container for this chapter is not fully functional. Therefore, it cannot run other than very simple servlets and does not call the servlet’s init and destory methods. Instead, it does the following:
Wait forr HTTP requests.
Construct a ServletRequest object and a ServletResponse object.
If the request is for a static resource, invoke the process method of the StaticResourceProcessor instance, passing the ServletRequest and ServletResponse objects.
If the request is for a servlet. load the servlet class and invoke the service method of the servlet, passing the ServletRequest and ServletResponse objects.
Note In this servlet container, the servlet class is loaded every time the servlet is requested.
The first application consists of six classes:
1 HttpServer1
2 Request
3 Response
4 StaticResourceProcessor
5 ServletProcessor1
6 Constants
- A Simple Servlet Container
- A Simple Servlet Container
- Tomcat-4 A Simple Servlet Container
- CHAPTER 2 A Simple Servlet Container
- How A Servlet container Works
- How A Servlet container Works
- JSON servlet synchronized error:A child container failed during start
- servlet/springMVC/spring/Tomcat报错:Servlet mapping specifies an unknown servlet, A child container...
- windows phone:A Really Super Light and Simple IoC Container for Windows Phone 7
- How tomcat work读书笔记 chapter2 a simple servlet
- 知识库--The Simple Container Application
- (全英文)How to install and run a simple Asp.Net 5 Application in a Docker Container
- JSP/Java Servlet Container
- Quicksort on a container
- Instantiating a container
- 发现了一本好书<How Tomcat Works A Guide to Developing Your Own Java Servlet Container>
- servlet 一个simple web project
- A simple bootstrap
- Chrome和HTTPS——安全Web的征途
- 23种设计模式
- Android 开发60条技术经验总结
- cv论文(Low-rank相关)
- 1655: [Usaco2006 Jan] Dollar Dayz 奶牛商店
- A Simple Servlet Container
- 11期 11月期刊自荐
- 使用ThinkPHP框架快速开发网站
- 计算星座
- Uploadify插件的参数属性、事件、方法函数详解
- 2016.11.14 jq(HTML )
- 单例模式的方法不是线程安全的
- 图片上传——html5+PHP实现无刷新上传
- 虚幻引擎源码分析(1)