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. transform与position:fixed的那些恩怨--摘抄

    1. 前言 在写这篇文章之前,我理解的fixed元素是这样的:(摘自CSS布局基础) 固定定位与absolute定位类型类似,但它的相对移动的坐标是视图(屏幕内的网页窗口)本身.由于视图本身是固定的, ...

  2. 标准C程序设计七---102

    Linux应用             编程深入            语言编程 标准C程序设计七---经典C11程序设计    以下内容为阅读:    <标准C程序设计>(第7版) 作者 ...

  3. linux 头文件以及库的路径

    原来在编译的时候可以指定执行时去哪里找需要的lib文件,长知识了 本文详细介绍了Linux 下gcc头文件指定方法,以及搜索路径顺序的问题.另外,还总结了,gcc动态链接的方法以及路径指定,同样也讨论 ...

  4. babel转码神器babel-preset-env

    简介 现如今不同的浏览器和平台chrome, opera, edge, firefox, safari, ie, ios, android, node, electron 不同的模块 "am ...

  5. java excel导出(基于注解)

    小白,做日志只是为了方便自己查看,能帮到别人当然更好,不喜勿喷. 上代码 依赖: <dependency> <groupId>org.apache.poi</groupI ...

  6. Java调用Python程序

    最近,需要在应用中,需要使用Java程序去调用Python代码,主要有两种实现方式. 一.使用Jython架包 因为调用的Python代码中需要使用Json对象,开始使用jython2.5.2,发现不 ...

  7. Oracle hidden costs revealed, Part2 – Using DTrace to find why writes in SYSTEM tablespace are slower than in others

    http://blog.tanelpoder.com/2008/09/02/oracle-hidden-costs-revealed-part2-using-dtrace-to-find-why-wr ...

  8. mysql 存储过程时间月份减法

    declare startTime VARCHAR(19) default '2014-00-00 00:00:00'; declare tempTime VARCHAR(19) default NO ...

  9. System::String *,char*,string 等的类型转换 [转]

    在VC 的编程中,经常会用到各种类型的转换,在MFC中textbox等控件得到的返回类型是System::String *,而写入的文件要求是 const char *类型的,下面介绍一些转换的方法: ...

  10. 视图交互--表视图(UITableView)的cell交互析略

    在表视图UITableView的cell上经常有一些交互,根据项目开发中的情况,需要对此进行一些规范.总结出了几种交互方法,这些方法在其他视图的交互上同样可以适用.用一个简单的例子来举例说明一下,其他 ...