一些JavaWeb概念初理解(一)

Tomcat

tomcat的理解

官网介绍:

The Apache Tomcat® software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies.

Apache Tomcat software powers numerous large-scale, mission-critical web applications across a diverse range of industries and organizations.

Tomcat是一个开源的Web应用服务器软件(对比Apache),而它也是一个Servlet和JSP容器

对于这个概念的初理解有以下几点

  1. tomcat和Apache都是Web服务器上的软件,称服务器为Web服务器是因为当采用B/S架构的时候,也就是浏览器(browser)与服 务器(server)之间交互的时候,服务器成为Web服务器。

  2. 服务器软件的作用实为:接受(收到浏览器来的请求),响应(返回相应的数据)
    类似的服务器软件有:WebLogic、IIS等

  3. 简单来说tomcat更像是apache的拓展,apache只能支持静态网页(html等),tomcat就像一个可以装载servlet的容器,可以让apache支持jsp等动态网页。
    形象来说,apache就像是一栋房子,里面摆了各种家具(静态的html),而tomcat就是这栋房子的水盆,没有它,水(jsp)就没有办法装起来

Apache与Tomcat的关系和区

Servlet

Servlet的理解

官方的定义:

Java Servlet Technology Overview

Servlets are the Java platform technology of choice for extending and enhancing Web servers. Servlets provide a component-based, platform-independent method for building Web-based applications, without the performance limitations of CGI programs. And unlike proprietary server extension mechanisms (such as the Netscape Server API or Apache modules), servlets are server- and platform-independent. This leaves you free to select a "best of breed" strategy for your servers, platforms, and tools.

servlets是拓展增强Web服务器的一种java平台技术。它提供了构建Web应用的各种方法,而且最重要的是它独立于服务器和平台,也就是说跨平台性很好(在哪都可以用)。

理解:

servlet本身其实是一个java接口,通常java接口也叫做规范,也就是它定义一系列的规范,告诉你怎么去提请求,怎么去返回数据,按照什么样的方式实现browser和server之间的交互。而当你实现servlet这个接口的时候,你实际上是写了一个java程序,这个程序可以实现B/S的交互。

Today servlets are a popular choice for building interactive Web applications. Third-party servlet containers are available for Apache Web Server, Microsoft IIS, and others. Servlet containers are usually a component of Web and application servers, such as BEA WebLogic Application Server, IBM WebSphere, Sun Java System Web Server, Sun Java System Application Server, and others.

这里提到servlet容器,这里有个链接详细解释了tomcat(servlet容器之一)和servlet之间的关系

(侵删)

  • Servlet实例即为 你(开发人员)实现servlet接口的java类
  • Servlet容器由Web服务器插件和Java容器两部分组成,如果客户端调用Servlct,Web服务器插件首先获得此请求的,控制并将它传递给Java容器(这个Java容器是Web服务器插件在服务器内部/外部地址空间打开一个Java虚拟机,在Java虚拟机上面加载的Java容器),然后Java容器把此请求交给Servlet来处理

You might want to check out the latest information on JavaServer Pages (JSP) technology. JSP technology is an extension of the servlet technology created to support authoring of HTML and XML pages. It makes it easier to combine fixed or static template data with dynamic content. Even if you're comfortable writing servlets, there are several compelling reasons to investigate JSP technology as a complement to your existing work.

介绍jsp时候详细分析其联系与区别

Servlet功能

Servlet 的主要功能在于交互式地浏览和修改数据,生成动态 Web 内容。这个过程为:

  1. 客户端发送请求至服务器端;

  2. 服务器将请求信息发送至 Servlet;

  3. Servlet 生成响应内容并将其传给服务器。响应内容动态生成,通常取决于客户端的请求;

  4. 服务器将响应返回给客户端。

总结:Servlet功能——处理并响应请求的服务端程序

你可能感兴趣的:(一些JavaWeb概念初理解(一))