Servlets: An excellent choice for server-side processing

Source: Internet
Author: User
Tags perl interpreter thread

Do you know how much you desire the next generation of platform products? It can be said that you put all the future on it. The additional features promised by the manufacturer in this product must allow you to keep up with the competition in the industry, and its troubleshooting program solves your day-to-day problems, and its functionality has matured long before you ask for it. Have you ever thought about simply moving your existing application to the next platform that has everything you want, and everything is still working? This is exactly what servlets to do for you.

The main reason why the Servlets API is important is that only APIs have a wide range of vendor support, while enabling you to build efficient, sophisticated online applications. It is primarily supported by a number of Web servers, such as the Javaweb Server (JWS) of the Java Soft Company and the website Pro server of O ' Reilly & Associates. For other popular servers, such as Netscape's Enterprise and Fast track server, Microsoft's Internet Information Server (IIS), StarNine's WebSTAR, and Apache , the servlet engine has been added by companies such as Gefion Software, live software, new Atlanta and IBM. In the high-end domain, application servers such as ATG Dynamo and Sun Microsystems Net dynamics all have servlet support, and these servers have load balancing and mature management capabilities. You can move a servlet-based application from one operating system Web server to another Web server on another operating system, although they use a different processor architecture. And you can use a basic Web server, develop applications on your own Mac or PC, and deploy them on the most powerful server pool with high-end application servers. The platform is according to your request and decide!

Unless there are other reasons why people must use Servlets, it is useless and pointless to talk about its broad support here. Some of its most important features include multithreading, durability, easy access to other network resources, and flexibility.

Parallel requests to the servlet are performed in a separate thread using the same servlet paradigm. It is more efficient than starting a new process for each request, loading a Perl interpreter and Perl scripts, and executing them until the request is complete and then releasing all the system resources. Java thread support also makes the development of servlets easier, servlets use a worker thread to keep collecting information, monitoring resources, or taking on other tasks that last a long time. This worker thread can be started when the servlet is started and can collect status reports about the task with a regular servlet request.

Persistence is, in some ways, related to multithreaded features. A parallel request can be handled with a thread without having to enable the new processing process because, once the servlet is loaded with Java VM processing, it will be north a Lin-锩 grandma to Practice  Jin Martingale and Torr cutter R. Kusanagi Ervlet can hold information between requests. Persistence can greatly improve processing performance and simplify tasks that are complex in a CGI based solution. For example, a servlet that accesses a database can hold a set of open database connections for all requests. Another better way is to use a connection pool manager to manage a set of database connections for multiple database servlets. Another example of persistence is dialogue tracking. A conversation is a target that is generated by the server when a customer requests the servlet for the first time. Since then all servlets requested by the same customer will have access to the same conversation target. In this way, a servlet can put information into a conversation target and another servlet can read it. By sharing information about a customer through a conversation target, a set of servlets can be combined to form an application, such as an online storage application that uses a conversation target to track the goods of a freight car. Dialog tracing is part of the Servlet API and is implemented by all compliant servlet engines.

Most companies have legacy systems that require constant access. Web applications built with Servlets can use the full suite of Java APIs to access legacy systems or other network resources. Access to all major databases through JDBC, directory services through Jndi, and advanced distributed services via RMI and Java IDL are achievable. Almost all the work done above can be handled by sockets or JNI.

Servlets can also be used in many different ways. The Servlet API defines the servlet interface and life cycle, but leaves developers with a great space to create an effective, flexible servlet engine. There are typically three types of servlet applications supported: As a substitute for CGI, as a substitute for server-side scripting and SSI Servlets. They all have a reason for their application and can be applied to different environments.

As a substitute for CGI, the servlet mimics the design and use of most CGI scripts. When implemented in Java, the servlet can perform a task and produce an entire page of HTML, showing the results. Typically, this servlet is invoked directly with a URL like http://www.ourcompany.com/servlet//DoSomethingNice. This is the most common servlet currently applied, and is especially useful for situations where the generated HTML is fairly simple and does not need to change frequently.

Replacing server-side scripting with a servlet means writing a Web page with static HTML and Java code to perform a task and generate HTML for the dynamic part of a Web page. This Web page uses special file extensions, such as jhtml, and is processed by a Web page compilation feature that converts Web pages into Java servlet source files, compiles, and executes them. The next time the Web page receives a request, it can invoke the compiled code directly. Recently there has been a large number of revisions to the compiled version of the page, called the Java Servlet pages or JSP. This is useful if your Web developers understand the basics of HTML and Java at the same time, and you just want to add a bit of dynamic content. An example is an SSI servlet or servlet Bean that reads and embeds Java code from the database to display the results or to display the "Sorry for not finding records" message.

You can also use the (servlet) flag on a Web page to embed a call for a servlet to activate the servlet. The servlet that is activated in this way is called a server-side containing (server Side include) or SSS servlet, similar to a servlet that replaces CGI. The difference is that if the SSI servlet produces HTML output, it produces only a small number of HTML-generated pages. Web pages with (servlet) tags are usually given shtml file extensions and, in addition to (servlet) tags, include the HTML markup of the rules to define page layouts and static content. When a Web page receives a request, the server side contains (server Side include) functionality to parse the file and return all the rules ' HTML to the customer intact. It replaces (servlet) markup with the HTML generated by the servlet (if any). It is best to use this method if a Web page developer knows only HTML but not programming; there is no code in the Web page, and only regular HTML and HTML-like tags can invoke servlets to produce dynamic content. SSI Servlets can be purchased or developed by in-house programmers.

When we started designing our "Instant online" (Instantonline) products, we sought a platform-independent technology that would allow us to leverage the infrastructure provided by Web servers and application servers without having to scramble for another proprietary server-side engine. Now that we have servlets, we know that we have found what we want. This is the choice we do not regret.

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.