Giter Site home page Giter Site logo

mytomcat's Introduction

mytomcat

模拟实现tomcat功能,先实现最简单的功能,模拟Servlet的几个接口service,doGet,doPost, 模拟tomcat的disptach(实际调用servlet的service)。 模拟tomcat的配置文件,这里使用简化的操作,没有使用xml配置文件,而是使用map替代配置文件。 后续会逐步更新换成NIO,AIO方式实现

步骤

1.启动ServerSocket,封装在MyTomcat中
2.accept得到Socket client
3.调用disptach(new MyRequest(client.getInputStream), new MyResponse(client.getOutputStream))
4.disptch内部根据request的url查询得到对应的servlet包名
5.调用Class.forName(servletName)得到实际的servlet类
6.用反射,netInstance或构造函数创建对象 servletObj
7.servletObj调用service分发请求和应答
8.service内部根据url中的请求方法判断调用doGet或doPost

mytomcat's People

Contributors

feitian168 avatar feifa168 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.