Java-EE explorer: Java-EE technology for stateless networks

Source: Internet
Author: User
Tags html form http request relative

In recent years, the development of the Java industry has grown exponentially. As an enterprise application developer, architecture architect, or technical manager, you can choose from many vendors, best practices, specifications, and component types for your Java technology implementation. The purpose of the Java EE Explorer series is to help you find a way to assist you in selecting the right technology for any given situation.

In this article, the 1th part, we will explore the stateless Java EE component and evaluate the most appropriate component for your enterprise architecture. When it comes to stateless, request processing components, there are two main options for Java EE: servlet or Enterprise JavaBeans technology-or, more specifically, stateless session beans.

In general, the servlet and EJB components are the transaction management components that are designed to be used as an enterprise architecture. Every technology has its advantages. The advantage of the servlet architecture is its overall efficiency and relative simplicity. EJB components are more robust, so development, maintenance, and debugging are more complex.

We first briefly discuss the quality of stateless (relative to stateful) networks, and then discuss these two stateless technologies in detail from both positive and negative aspects. At the end of the article, let's look at some of the most common application settings in Java EE programming, as well as the best technology solutions for the two options we're discussing.

Note that for the purposes of this article, JSP (Java serverpages) technology is considered a special type of servlet. This is not difficult to understand, given the translation of each JSP page into a servlet before executing it. Because of the stateless nature of the servlet, we consider only stateless session beans and the attributes they provide for processing stateless client requests. The next article in this series compares the stateful session bean with the servlet and HTTP session APIs.

No State network

You can divide a WEB application protocol into two broad categories: stateless and stateful. The status of the Protocol refers to the ability to "remember" the transmission of the message next time. A stateful protocol can create a context based on a client's previous request. Stateless protocols have no context; Each request is a separate connection to the server.

HTTP is a good example of a stateless protocol based on client-server requests and responses. In HTTP, information about client-server interactions in this request is not maintained for the next request.

Of course, due to the inability to maintain state, the Internet will only become a beautiful encyclopedia, electronic Yellow Pages and shockwave.com on the cool animation games. As a result, there are some techniques for simulating stateful sessions on HTTP. Stateful information can be stored in an HTML form field or in the user's machine cookie, or it can be attached to a hyperlink. The application developer then manages, tracks, and maintains the state of the client to ensure that the session process is smooth, secure, and fascinating.

Application of the servlet

The servlet architecture is designed as a flexible, platform-independent component model that executes on the server and processes requests from clients. The Servlet is flexible because they are configured uniquely for the combination of the server's deployment descriptor (which is server-specific) and the WEB Application Deployment descriptor (which is defined by the Java EE specification and is not server-independent, such as Web.xml). The Servlet is not platform-dependent because it can run on any OS (thanks to the JVM) and can be run on any Java EE Web Server (thanks to the Java EE Standard). Finally, the servlet architecture is a component model because it enables developers to write comprehensive components that implement specific interfaces. These components are then assembled at run time to handle client requests.

Although the servlet typically handles HTTP requests, the servlet architecture is not protocol-independent. The Servlet interface defines the basic methods needed to communicate with the servlet, without regard to network protocols. For simplicity and because the HTTP servlet is the most commonly used type, we will only discuss the HTTP servlet. In fact, if you extend a custom servlet class from HttpServlet, you can easily use and process HTTP traffic without worrying about parsing HTTP request streams, extracting parameters, or any other typical HTTP processing activity that involves details.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.