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. canvas之webgl的打开方式

    OK,一个完整的dome是从无到有的.这篇文章将记录我的webgl之旅.不定时更新. 首先,新建一个canvas元素. 然后获取到它. var e = document.ElementById('ca ...

  2. 用node写的一个后台框架

    server.js var http=require('http') var handleUrl=require('./handleUrl') var config = require('./conf ...

  3. linux 程序自动运行总结

    1.开机启动时自动运行程序Linux加载后, 它将初始化硬件和设备驱动, 然后运行第一个进程init.init根据配置文件继续引导过程,启动其它进程.通常情况下,修改放置在 /etc/rc或 /etc ...

  4. 让网站永久拥有HTTPS - 申请免费SSL证书并自动续期

    https://blog.csdn.net/xs18952904/article/details/79262646 https://freessl.org/

  5. 总结 Eclipse 编程常用的快捷键

    Eclipse 常用快捷键Eclipse的编辑功能非常强大,掌握了Eclipse快捷键功能,能够大大提高开发效率.Eclipse中有如下一些和编辑相关的快捷键. 1. [ALT+/] 此快捷键为用户编 ...

  6. SPOJ GSS系列(数据结构维护技巧入门)

    题目链接 GSS $GSS1$ 对于每个询问$l$, $r$,查询$a_{l}$, $a_{l+1}$, $a_{l+2}$, ..., $a_{r}$这个序列的最大字段和. 建立线段树,每个节点维护 ...

  7. Arduino可穿戴教程ArduinoIDE新建编辑源文件

    Arduino可穿戴教程ArduinoIDE新建编辑源文件 Arduino IDE新建源文件 Arduino IDE启动后默认就新建了一个源文件,如图2.20所示.新建的源文件名称是以sketch_开 ...

  8. Codeforces 245G Suggested Friends 暴力乱搞

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

  9. spring管理事务

    2.1 事务管理器 Spring并不直接管理事务,而是提供了多种事务管理器,他们将事务管理的职责委托给Hibernate或者JTA等持久化机制所提供的相关平台框架的事务来实现. Spring事务管理器 ...

  10. 跳转到指定页面popToViewController用法

    有人问popToViewController的用法 就写了下了 希望能帮到有需要的人 [self.navigationController popToViewController:[self.navi ...