渔舟唱晚的天空
——welkinwalker的遐想
servlet, JavaBeans, EJB(Enterprise JavaBeans), web container, jee, j2ee, jsp

 

JavaBeans是遵循特定规范的java 类,这个规范是:

  • The class must have a public default constructor (no-argument). This allows easy instantiation within editing and activation frameworks.
  • The class properties must be accessible using getsetis (used for boolean properties instead of get) and other methods (so-called accessor methods and mutator methods), following a standard naming convention. This allows easy automated inspection and updating of bean state within frameworks, many of which include custom editors for various types of properties. Setters must receive only one argument.
  • The class should be serializable. It allows applications and frameworks to reliably save, store, and restore the bean's state in a fashion independent of the VM and of the platform.

EJB 

The EJB specification is one of several Java APIs in the Java EE specification. EJB is a server-side model that encapsulates the business logic of an application. The EJB specification was originally developed in 1997 by IBM and later adopted by Sun Microsystems (EJB 1.0 and 1.1) in 1999[1] and enhanced under the Java Community Process as JSR 19 (EJB 2.0), JSR 153 (EJB 2.1),JSR 220 (EJB 3.0) and JSR 318 (EJB 3.1). 

The EJB specification intends to provide a standard way to implement the back-end 'business' code typically found in enterprise applications (as opposed to 'front-end' interface code). Such code addresses the same types of problems, and solutions to these problems are often repeatedly re-implemented by programmers. Enterprise JavaBeans are intended to handle such common concerns aspersistencetransactional integrity, and security in a standard way, leaving programmers free to concentrate on the particular problem at hand. 

EJB是一个封装了商业逻辑的模型,该怎么理解呢?商业代码要处理很多同类的任务,这些任务要关注持久化、事务一致性、安全,通常来说,程序猿在做不同功能的时候都要重复实现上述积累逻辑。EJB就是要把这些东西的实现标准化,让程序猿关注具体的业务功能。

 

Bean这个词很有意思,很久不清楚,后来想java这个词,是咖啡的意思,bean呢是豆子的统称。java bean不就是咖啡豆么,要和咖啡就要现有咖啡豆。所以你懂了,bean就是组成java应用的部分,其实就是类了。EJB就是java企业应用的类,java bean就是普通java的类。不知道这么解释合适不,呵呵。 

 

servlet is a Java programming language class used to extend the capabilities of servers that host applications access via a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by Web servers. Thus, it can be thought of as a Java Applet that runs on a server instead of a browser. 

 

servlet就是一个java类,一个运行在web server上的类,用来处理http的request并返回response

 

Servlet is a Java-based server side web technology. As the name implies, it serves a client request and receives a response from the server. Technically speaking a Servlet is a Java class in Java EE that conforms to the Java Servlet API, a protocol by which a Java class may respond to requests. They are not tied to a specific client-server protocol, but are most often used with the HTTP protocol. Therefore, the word "Servlet" is often used in the meaning of "HTTP Servlet".[2] Thus, a software developer may use a servlet to add dynamic content to a Web server using the Java platform. The generated content is commonly HTML, but may be other data such as XML. Servlets are the Javacounterpart to non-Java dynamic Web content technologies such as PHP and ASP.NET. Servlets can maintain state in session variables across many server transactions by using HTTP cookies, or URL rewriting.

To deploy and run a Servlet, a Web container must be used. A Web container (also known as a Servlet container) is essentially the component of a Web server that interacts with the servlets. The Web container is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet and ensuring that the URL requester has the correct access rights.

The servlet API, contained in the Java package hierarchy javax.servlet, defines the expected interactions of the Web container and a servlet.[2]

Servlet is an object that receives a request and generates a response based on that request. The basic servlet package defines Java objects to represent servlet requests and responses, as well as objects to reflect the servlet's configuration parameters and execution environment. The package javax.servlet.http defines HTTP-specific subclasses of the generic servlet elements, including session management objects that track multiple requests and responses between the Web server and a client. Servlets may be packaged in a WAR file as a Web application.

Servlets can be generated automatically from JavaServer Pages (JSP) by the JavaServer Pages compiler. The difference between Servlets and JSP is that Servlets typically embed HTML inside Java code, while JSPs embed Java code in HTML. While the direct usage of Servlets to generate HTML (as shown in the example below) has become rare, the higher level MVC web framework in Java EE (JSF) still explicitly uses the Servlet technology for the low level request/response handling via the FacesServlet. A somewhat older usage is to use servlets in conjunction with JSPs in a pattern called "Model 2", which is a flavor of the model-view-controller pattern.

posted on 2012-06-06 15:33  welkinwalker  阅读(511)  评论(0编辑  收藏  举报