标签:tst 业务 inter load hit 调试 ati exception 也有
class MyTomcat{ ServerSocket server=new ServerSocket(8080); // 等待客户端的连接请求 Socket socket=server.accept(); }
public interface Servlet { void init(ServletConfig config) throws ServletException; ServletConfig getServletConfig(); void service(ServletRequest req, ServletResponse res)throws ServletException, IOException; String getServletInfo(); void destroy(); }
class LoginServlet extends HttpServlet { doGet(request,response){} doPost(request,response){} }
<servlet> <servlet-name>LoginServlet</servlet-name> <servlet-class>com.gupao.web.servlet.LoginServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>LoginServlet</servlet-name> <url-pattern>/login</url-pattern> </servlet-mapping>
class MyTomcat{ List list=new ArrayList(); ServerSocket server=new ServerSocket(8080); Socket socket=server.accept(); // 把请求和响应都封装在业务代码中的servlet // 只要把业务代码中一个个servlets添加到tomcat中即可 list.add(servlets); }
Tomcat版本:Tomcat8.0.11
各个版本下载地址 :https://archive.apache.org/dist/tomcat
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.apache.tomcat</groupId> <artifactId>Tomcat8.0</artifactId> <name>Tomcat8.0</name> <version>8.0</version> <build> <finalName>Tomcat8.0</finalName> <sourceDirectory>java</sourceDirectory> <testSourceDirectory>test</testSourceDirectory> <resources> <resource> <directory>java</directory> </resource> </resources> <testResources> <testResource> <directory>test</directory> </testResource> </testResources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3</version> <configuration> <encoding>UTF-8</encoding> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> <version>3.4</version> </dependency> <dependency> <groupId>ant</groupId> <artifactId>ant</artifactId> <version>1.7.0</version> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> <version>1.6.2</version> </dependency> <dependency> <groupId>javax.xml</groupId> <artifactId>jaxrpc</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>org.eclipse.jdt.core.compiler</groupId> <artifactId>ecj</artifactId> <version>4.5.1</version> </dependency> </dependencies> </project>
name:gp-tomcat Main class:org.apache.catalina.startup.Bootstrap
VM options:-Dcatalina.home="apache-tomcat-8.0.11
(1)web容器 (2)servlet容器
04 Tomcat架构设计
4.1 各个组件含义
官网 :https://tomcat.apache.org/tomcat-8.0-doc/architecture/overview.html
Endpoint接收Socket连接,生成一个SocketProcessor任务提交到线程池去处理
SocketProcessor的run方法会调用Processor组件去解析应用层协议,
Processor通过解析生成Request对象后,会调 用Adapter的service方法。
4.3 Request Process Flow
官网 :https://tomcat.apache.org/tomcat-8.0-doc/architecture/requestProcess/request-process.png
标签:tst 业务 inter load hit 调试 ati exception 也有
原文地址:https://www.cnblogs.com/flgb/p/12081713.html