Tomcat主要充当servlet/JSP容器,不过它却有大量的功能可以与传统的Web服务器相媲美,对公共网关接口(Common Gateway Interface)的支持就是其中之一。

传统的Web服务器为了响应浏览器的请求,提供了运行外挂程序的一种方式,典型地用于处理基于Web的表单。这种机制叫做CGI。

CGI之所以称为通用,是因为它几乎可以调用所有编程或脚本语言:Perl、Python、awk、Unix Shell脚本,甚至还可以选择性地支持Java。

实际上,由于启动负荷过载,您可能不会将Java应用程序当成CGI来执行;而设计servlet规范的起因就是为了消除这种系统负载过载。

servlet几乎永远都比CGI高效,因为每当有人点击链接或按钮时候,并不会启动新的操作系统级进程。

[root@d3 apache-tomcat-7.0.90]# cat conf/tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<tomcat-users>
<!--
NOTE: By default, no user is included in the "manager-gui" role required
to operate the "/manager/html" web application. If you wish to use this app,
you must define such a user - the username and password are arbitrary. It is
strongly recommended that you do NOT use one of the users in the commented out
section below since they are intended for use with the examples web
application.
-->
<!--
NOTE: The sample user and role entries below are intended for use with the
examples web application. They are wrapped in a comment and thus are ignored
when reading this file. If you wish to configure these users for use with the
examples web application, do not forget to remove the <!.. ..> that surrounds
them. You will also need to set the passwords to something appropriate.
-->
<!--
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
<user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
<user username="role1" password="<must-be-changed>" roles="role1"/>
-->
<role rolename="admin"/>
<user username="un" password="123" roles="admin"/>
</tomcat-users>
[root@d3 apache-tomcat-7.0.90]#

  

在Java servlet出现之前,大多数Web应用程序都是以C/C++或Perl编写的。这些应用程序通常由多个静态HTML网页以及一些产生动态内容的CGI所构成。这些CGI脚本的编写过程可能与平台无关,不过这不是必要的

。同时,因为CGI是跨左右Web服务器品牌与实现的工业标准,所以CGI脚本可以写成独立于Web服务器实现的程序。事实上,某些CGI是这样处理的,而另一些则不是。CGI的最大问题是其设计本身会让他先天性执行缓慢,并无法扩充。

另一种产生动态网页内容的方式是使用Web服务器模块。例如,Apache http Web服务器可以在启动时执行动态可加载的模块。这些模块会响应预先配置的HTTP请求样式,并将动态网页内容送至HTTP的客户端/浏览器。

“通用网关接口”(CGI)是将Web服务器与自定义的Web应用程序挂钩的老标准,其主要用途是编写动态网页内容的脚本。一次,一半会把他成为“CGI脚本编写”(CGI scriprting),但其实也可以用C语言来编写CGI程序(对这样的程序,

我们一般不把它叫做脚本)。

所有对CGI脚本的HTTP请求,意味着操作系统都必须产生及执行新的进程,而且设计规则也会强制要求这样做。当Web服务器在大量网络负载下运行时,会启动和停止太多的进程,势必会造成服务器必须投入大部分资源以处理

启动和停止作业,而完成非HTTP请求。

tomcat servlet JSP common gateway interface 公共网关接口的更多相关文章

  1. Common Gateway Interface Python CGI编程

    https://en.wikipedia.org/wiki/Gateway_(telecommunications) In telecommunications, the term gateway r ...

  2. CGI(Common Gateway Interface),通用网关接口

    通用网关接口,简称CGI,是一种根据请求信息动态产生回应内容的技术.通过CGI,Web 服务器可以将根据请求不同启动不同的外部程序,并将请求内容转发给该程序,在程序执行结束后,将执行结果作为回应返回给 ...

  3. java web 开发入门 --- tomcat/servlet/jsp

    在做java web 开发时,要先安装tomcat.它是一个web服务器,也叫web容器,我们把写好的jsp, html页面放到它里面,然后启动它,就可以用浏览器访问这些页面,地址栏中输入localh ...

  4. The Apache Tomcat Servlet/JSP Container

    1.Tomcat部署的场景分析 通常,我们对tomcat单机部署需求可以分为几种: 单实例单应用 (一个tomcat 一个web应用) 单实例多应用 (一个tomcat多个应用) 多实例单应用 (多个 ...

  5. 什么是CGI(Common Gateway Interface)?

    参考: 1.Python CGI编程 2.十分钟搞懂CGI 3.CGI Made Really Easy

  6. Tomcat+Servlet登录页面实例

    概念   Tomcat server是一个免费的开放源码的Web 应用server,属于轻量级应用server,在中小型系统和并发訪问用户不是非常多的场合下被普遍使用,是开发和调试JSP 程序的首选. ...

  7. python web server gateway interface (wsgi ) notes

    前言: 注:如果需要得到支持批Python3.x以及包含了勘误表,附录,和说明的更新版规范,请查看PEP 3333 摘要: 这篇文档详细说明了一套在web服务器与Python web应用程序(web框 ...

  8. Python Web Server Gateway Interface -- WSGI

    了解了HTTP协议和HTML文档,我们其实就明白了一个Web应用的本质就是: 浏览器发送一个HTTP请求: 服务器收到请求,生成一个HTML文档: 服务器把HTML文档作为HTTP响应的Body发送给 ...

  9. (一)CGI (通用网关接口) 简介

    CGI (通用网关接口)公共网关接口(Common Gateway Interface,CGI)是Web 服务器运行时外部程序的规范,按CGI 编写的程序可以扩展服务器功能.CGI 应用程序能与浏览器 ...

随机推荐

  1. 开始学习es6(二) let 与 const 及 块级作用域

    1.var JavaScript中,我们通常说的作用域是函数作用域,使用var声明的变量,无论是在代码的哪个地方声明的,都会提升到当前作用域的最顶部,这种行为叫做变量提升(Hoisting) cons ...

  2. react native 添加mobx

    "babel-plugin-transform-decorators-legacy": "^1.3.5", "babel-preset-react-n ...

  3. vue生命周期回调方法

    最近在用vue开发一个商品列表页,因需要根据请求回的字段是否有内容来显示隐藏该字段, 但因为vue异步加载导致显示隐藏方法不起作业(主要是判断条件取不到页面渲染内容),围观了vue生命周期后发现upd ...

  4. Codeforces 245G Suggested Friends 暴力乱搞

    G. Suggested Friends time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  5. Codeforces 235 E Number Challenge

    Discription Let's denote d(n) as the number of divisors of a positive integer n. You are given three ...

  6. ubuntu navicat for mysql破解

    ubuntu navicat for mysql破解 ubuntu navicat for mysql只能试用14天. 破解方法:rm -rf /home/cxg/.navicat64/

  7. Hibernate 3 深度解析--苏春波

    Hibernate 3 深度解析   Hibernate 作为 Java ORM 模式的优秀开源实现, 当下已经成为一种标准,为饱受 JDBC 折磨的 Java 开发者带来了“福音.快速的版本更新,想 ...

  8. Lazarus安装使用

    Lazarus安装使用 最后还是安装了Lazarus: 安装之后,新建了项目,还引入了Unit,就可以跑了: 学习:http://tieba.baidu.com/p/3164001113 progra ...

  9. AngularJS的ng-repeat显示属性名和属性值

    代码下载:https://files.cnblogs.com/files/xiandedanteng/AngularJSAuthorRepeat.rar 代码: <!DOCTYPE HTML P ...

  10. Hibernate中的条件查询完毕类

    Hibernate中的条件查询有下面三个类完毕: 1.Criteria:代表一次查询 2.Criterion:代表一个查询条件 3.Restrictions:产生查询条件的工具类