Seven Tips for improving JSP applications

Source: Internet
Author: User
Seven Tips for improving JSP applications-general Linux technology-Linux programming and kernel information. The following is a detailed description. Are you often complained about slow response to JSP pages? Have you ever wondered whether your WEB applications will be able to withstand the increasing traffic volume when the number of customer visits increases dramatically? This article describes some very practical methods to adjust JSP and servlet. It can make your servlet and JSP page response faster and more scalable. In addition, when the number of users increases, the system load will show a smooth and long trend. In this article, I will use some practical examples and configuration methods to unexpectedly improve the performance of your application. Some tuning techniques are implemented in your programming work. Other technologies are related to the configuration of application servers. In this article, we will describe in detail how to improve the overall performance of your application by adjusting the servlet and JSP pages. Before reading this article, let's assume that you have basic servlet and JSP knowledge.

Method 1: cache data in the servlet init () method

After the application server initializes the servlet instance and provides services for client requests, it will call the init () method of the servlet. In the lifecycle of a servlet, The init () method is called only once. By caching some static data in the init () method or completing some time-consuming operations that only need to be executed once, the system performance can be greatly improved.

For example, establishing a JDBC connection pool in the init () method is an optimal example. Suppose we use the DataSource interface of jdbc2.0 to obtain the database connection. In general, we need to obtain the specific data source through JNDI. We can imagine that in a specific application, if every SQL request needs to execute a JNDI query, the system performance will drop sharply. The solution is the following code, which caches DataSource so that the next SQL call can continue to use it:
QUOTE:

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.