资讯专栏INFORMATION COLUMN

JAVA服务器概述

付永刚 / 3137人阅读

摘要:尽管大多数的服务器有支持脚本语言的插件,通过这些脚本语言,比如,,,可以产生动态的内容,但是服务器大多数旨在为静态页面服务。

Java服务器

  作为Java工程师,服务器对于我们的开发工作很重要,将我们开发好的项目放到服务器上用户才可以使用。我们常用到的服务器有Tomcat、Apache、Nginx等等。对于我们所开发的应用,如何选择合适的服务器是个问题。下面简单的介绍Web服务器Servlet容器应用服务器的基本概念以及各种服务器的应用场景。
  本文是Google上查询的几遍文章的部分截断,我自己加上了中文翻译。

WEB Server Example

  Apache、IIS、Nginx

Features and Responsibility

  Web Servers are responsible for serving static content e.g. HTML over HTTP protocol.
  Web服务器的主要职责是服务静态页面,例如,以HTTP协议传输的HTML页面

  In a simple situation,a user type in a URL in browser(a client),and get a web page to read.So what the server does is sending a web page to the client.The transformation is in HTTP protocol which specifies the format of request and response message.
  一个简单的应用场景,用户在浏览器(客户端)输入URL并且开始浏览网页。那么服务器所做的就是发送一个静态页面到客户端,传输的信息是通过指定了请求和响应格式的HTTP协议。

Servlet Container Example

  Tomcat、Jetty

Features and Responsibility

  A servlet-container supports only the servlet API(including JSP,JSTL)
  Servlet容器仅仅支持Servlet API,包括JSP、JSTL

  Servlet container are only responsible for generating HTML by executing JSP and Servlet on Server side.So servlet container is essentially a part of a web server that interacts with the servlets.
  Servlet容器唯一的职责就是通过执行服务器上的JSP和Servlet来产生HTML页面。那么Servlet容器本质上是Web服务器的一部分,只不过加上了和Sevlet交互的接口。

Servlet

  Servlet is an interface defined in javax.servlet package.It declares three essential methods for the life cycle of a servlet – init(),service(),and destroy().They are implemented by every servlet and invoked at specific times by the server.
  Servlet是定义在javax.servlet包下面的接口。对于一个Servlet的声明周期,它声明了三种内在的方法——init(),servie()和destroy().在服务器上每一个Servlet被唤醒的时候,他们都会执行。

How Servlet Container and web server process a request ?

Web server receives HTTP request

Web server forwards the request to servlet containter

The servlet is dynamically retrieved and loaded into the address space of the container,if it is not in the container.

The container invokes the init() method of the servlet for initialization(invoked once when the servlet is loaded first time)

The container invokes the service() method of the servlet to process the HTTP request,read data in the request and formulate a response.The servlet remains in the container’s address space and can process other HTTP requests.

Application Server Example

  WebSphere,WebLogic,JBoss

Features and Responsibility

  Application Server is responsible for generating dynamic content by executing server side code e.g. JSP,Servlet or EJB.
  应用服务的主要职责就是通过执行服务器代码产生动态页面,列如,JSP,Servlet或者EJB。

  Application server is responsible for serving dynamic content,managing EJB pool,facilitating distributed transation,facilitating application lookup over JNDI,application security and others.
  应用服务器的主要任务是服务动态内容,管理EJB Pool,促进事务分配,促进应用查找JNDI,应用安全等等。

  An application server supports the whole JavaEE - EJB,JMS,CDI,JTA
  应用服务器支持整个JavaEE体系
  An application usually includes a Web server,but also adds a lot of more features.The most important is that it manages objects.Whether they will be Servlets,EJBs,JMS listenters.
  一个应用服务器通常包括一个Web服务器,但是额外加了很多特性。最重要的就是它管理对象(Servlets,EJB,JMS)

Tomcat

  Tomcat is not exactly an application server, it"s more of a servlet engine or web container or also known as servlet containers because it provides the runtime environment for Servlet and JSP but doesn"t provide the services like EJB and distributed transaction which are a key feature of the application server in Java JEE world
  Tomcat不完全是一个应用服务器,它只是一个Servlet引擎或者是一个Web容器或者是我们众所周知的Servlet容器,因为它只提供了Servlet和JSP的运行环境,但是没有提供像是EJB和事务控制的部分,而这部分才是JEE领域里面应用服务器的特点。

Summary

  It’s expected from a Web server to provide HTTP protocol level service while application server is supposed to provide more powerful and dynamic Web service and business level service via EJB(Enterprise Java Beans).Essential services like Database connection pooling is not only provided by application server but also by Servlet containers like Tomcat.
  可以预计的是一个Web服务器提供HTTP协议层次的服务,应用服务器应该是提供更多的强大的动态的Web服务,并且包括商务级别的服务经由EJB。像数据库连接池这样必要的服务不仅仅是应用服务器支持,像是Tomcat这样的Servlet容器也支持。

  You need a Web server like Apache HTTPD if you are serving static web pages.If you have a Java application with just JSP and Servlet to generate dynamic content then you need Servlet containers like Tomcat or Jetty while,if you have JavaEE application using EJB,distributed transation,messaging and other fancy features than you need a full fledged application server like JBoss,WebSphere or WebLogic.
  如果你为静态页面提供服务,你就需要像Apache HTTPD这样的Web服务器。如果你有一个仅仅是JSP和Servlet的JAVA应用去生成动态的页面内容,你需要一个像Tomcat或者Jetty这样的Servlet容器。如果你的JAVAEE应用使用了EJB,事务管理,消息和其他一些复杂华丽的特点,你就需要一个完全成熟的应用服务器,列如JBoss,WebSphere或者WebLogic.

  For example,one of the popular setups is Apache fronting Tomcat or Ngnix fronting Tomcat
  比如,一个非常流行的做法就是在Tomcat上面加一Apache或者是在Tomcat上加Nginx服务。

  What is the difference between application server and web server ?

  Web Server is designed to serve HTTP Content. Application Server can also serve HTTP Content but is not limited to just HTTP. It can be provided other protocol support such as RMI/RPC
  Web服务器旨在为HTTP内容提供服务。应用服务器也可以为HTTP内容提供服务,但是它不仅仅限于HTTP,它可以提供其他的协议支持,例如RMI/RPC。

  Web Server is mostly designed to serve static content, though most Web Servers have plugins to support scripting languages like Perl, PHP, ASP, JSP etc. through which these servers can generate dynamic HTTP content.
  尽管大多数的Web服务器有支持脚本语言的插件,通过这些脚本语言,比如PHP,ASP,JSP,可以产生动态的HTTP内容,但是Web服务器大多数旨在为静态页面服务。

  Most of the application servers have Web Server as integral part of them, that means App Server can do whatever Web Server is capable of. Additionally Application Server have components and features to support Application level services such as Connection Pooling, Object Pooling, Transaction Support, Messaging services etc.
  大多数的应用服务器都包括Web服务器来构成他们完整的体系,这也就意味着应用服务器可以做任何Web服务器有能力做的事情。除此之外,应用服务器包含了一些能够达到应用层次的组件和特点,例如连接池,对象池,事务支持,消息服务等。

  As web servers are well suited for static content and app servers for dynamic content, most of the production environments have web server acting as reverse proxy to app server. That means while service a page request, static contents such as images/Static html is served by web server that interprets the request. Using some kind of filtering technique (mostly extension of requested resource) web server identifies dynamic content request and transparently forwards to app serve
  对于静态页面来说Web服务器很适,而应用服务器适合动态内容,但是大多数的生产环境都是有一个Web服务器作为应用服务器的反向代理。这就意味着一个页面的请求,像图片和静态HTML这样的静态内容是由Web服务器提供服务。使用一些像过滤器这样的技术,Web服务器鉴别动态内容请求并显示的导向应用服务器。

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/40021.html

相关文章

  • Spring Framework 参考文档(概述

    摘要:除此之外,还为不同的应用程序体系结构提供了基础支持,包括消息传递事务数据和持久性以及,它还包括基于的框架,以及与之并行的反应性框架。还支持依赖项注入和公共注解规范,应用程序开发人员可以选择使用这些规范,而不是提供的特定于的机制。 概述 Spring使创建Java企业应用程序变得很容易,它提供了在企业环境中使用Java语言所需要的一切,支持Groovy和Kotlin作为JVM上的替代语言...

    silencezwm 评论0 收藏0
  • 2.《JSP应用开发案例教程》第1章 JSP概述

    摘要:第章概述简介是一种动态网页技术标准,是应用开发的主要技术之一,也是目前应用开发的主流技术之一。为此,需要逐一完成开发包服务器开发工具以及数据库管理系统的安装与配置。在此,开发包使用,服务器使用开发工具使用,数据库管理系统使用。 ...

    Pocher 评论0 收藏0
  • 服务与Spring Cloud概述

    摘要:微服务架构概述应用架构的发展应用是可独立运行的程序代码,提供相对完善的业务功能。阿里开源的是的典型实现。它目前由官方开发维护,基于开发,提供一套完整的微服务解决方案。 微服务与Spring Cloud 随着互联网的快速发展, 云计算近十年也得到蓬勃发展, 企业的IT环境和IT架构也逐渐在发生变革,从过去的单体应用架构发展为至今广泛流行的微服务架构。 微服务是一种架构风格, 能给软件应用...

    scwang90 评论0 收藏0
  • DevOps 基于Walle的小型持续集成实战(一)概述

    摘要:该文章用于概述一个小型持续集成环境的搭建的方案什么是持续集成持续集成作为当今软件开发实践,可以简单理解为团队开发相对频繁的集成他们的工作,一般让每个成员每天至少集成一次,而这回造成每天会有多次的版本发布。 该文章用于概述一个小型持续集成环境的搭建的方案 什么是持续集成? 持续集成作为当今软件开发实践,可以简单理解为团队开发相对频繁的集成他们的工作,一般让每个成员每天至少集成一次,而这回...

    Yangyang 评论0 收藏0
  • java学习(五) —— 常用API类概述

    摘要:成员方法类概述用于产生随机数成员方法正则表达式相关方法判断功能分割功能替换功能获取功能和类的使用类概述包含一些有用的类字段和方法。注意它不能被实例化,因为此类构造器是私有的成员方法类类概述表示特定的瞬间,精确到毫秒。 前言 我们都知道,JDK包含了JRE,而JRE中也提供了各种功能的java类,现在我们就对这些类有个简单了解,然后灵活运用。 常用类:Object类/Scanner类,...

    Tecode 评论0 收藏0
  • Java包的基本概述

    摘要:第七章包的基本概述起因在我们设计一个程序的时候尤其是多人合作,会写一些类来实现功能,但是往往会有重名的现象发生,为了解决这个问题,则专门设计了包。概念为了更好地组织类,提供了包机制,用于区别类名的命名空间。 第七章 7.1 包的基本概述 起因: 在我们设计一个程序的时候(尤其是多人合作),会写一些类来实现功能,但是往往会有重名的现象发生,为了解决这个问题,则专门设计了包。(还有其他作用...

    Baaaan 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<